:root {
  --wine: #7f294a;
  --wine-dark: #5c1734;
  --cream: #fffaf4;
  --paper: #fffdf9;
  --ink: #402735;
  --muted: #806977;
  --line: rgba(108, 49, 76, .15);
  --shadow: 0 20px 60px rgba(79, 31, 52, .16);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Cormorant Garamond", serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(221, 154, 181, .28), transparent 35%),
    radial-gradient(circle at 100% 15%, rgba(255, 218, 178, .3), transparent 36%),
    linear-gradient(145deg, #fffaf5, #f8edf1 65%, #fff9f2);
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  background: rgba(255, 249, 245, .78); border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: .95; }
.eyebrow { margin: 0 0 4px; font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.back-link, .today-button, .round-button, .small-add-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.82); color: var(--wine);
  border-radius: 999px; box-shadow: 0 8px 22px rgba(84,35,57,.08); text-decoration: none; cursor: pointer;
}
.back-link { width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.6rem; }
.today-button { padding: 10px 15px; font-weight: 700; }
.calendar-shell { width: min(1040px, calc(100% - 24px)); margin: 22px auto; display: grid; gap: 18px; }
.next-event-card {
  border-radius: 24px; padding: 22px; color: white;
  background: linear-gradient(135deg, #873151, #b95073);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.next-event-card::after { content: "♥"; position: absolute; right: 18px; top: -22px; font-size: 9rem; opacity: .11; }
.next-event-card h2 { margin: 4px 0 6px; font-size: 2rem; }
.next-event-card p { margin: 5px 0; }
.hidden { display: none !important; }
.calendar-card, .agenda-card {
  background: rgba(255,253,249,.9); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: var(--shadow); padding: clamp(14px, 3vw, 26px);
}
.calendar-toolbar { display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; gap: 12px; margin-bottom: 14px; }
.calendar-toolbar h2 { text-align: center; margin: 0; font-size: clamp(1.7rem, 5vw, 2.3rem); text-transform: capitalize; }
.round-button { width: 44px; height: 44px; font-size: 2rem; line-height: 1; }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.weekday-row { margin-bottom: 7px; text-align: center; color: var(--muted); font-size: .78rem; font-weight: 700; }
.calendar-day {
  min-height: 92px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.75);
  padding: 8px; text-align: left; cursor: pointer; position: relative; overflow: hidden; color: var(--ink);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.calendar-day:active { transform: scale(.97); }
.calendar-day.outside { opacity: .36; }
.calendar-day.selected { border-color: rgba(127,41,74,.58); box-shadow: inset 0 0 0 2px rgba(127,41,74,.12); }
.calendar-day.today .day-number { background: var(--wine); color: white; }
.day-number { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; font-weight: 700; }
.day-dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.event-dot { width: 8px; height: 8px; border-radius: 50%; }
.day-preview { display: block; margin-top: 5px; font-size: .69rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--wine-dark); }
.rose { --event-color: #c94f77; } .gold { --event-color: #d29b36; } .blue { --event-color: #4a87bd; } .green { --event-color: #4e9b76; } .violet { --event-color: #8959ad; }
.event-dot, .event-card::before, .detail-badge { background: var(--event-color); }
.agenda-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.agenda-heading h2 { margin: 0; font-size: 1.8rem; }
.small-add-button { padding: 9px 14px; font-weight: 700; }
.day-events { display: grid; gap: 11px; margin-top: 17px; }
.event-card {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: white;
  padding: 15px 15px 15px 21px; cursor: pointer; box-shadow: 0 9px 26px rgba(79,31,52,.07);
}
.event-card::before { content:""; position:absolute; left:0; top:0; bottom:0; width:6px; }
.event-card h3 { margin: 0 0 4px; font-size: 1.35rem; }
.event-card p { margin: 3px 0; color: var(--muted); }
.empty-state { text-align: center; padding: 30px 12px; color: var(--muted); }
.floating-add {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 25;
  width: 62px; height: 62px; border: 0; border-radius: 50%; color: white; font-size: 2.2rem; cursor: pointer;
  background: linear-gradient(145deg, #ad4166, #741f42); box-shadow: 0 16px 38px rgba(102,29,60,.38);
}
.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: end center; }
.modal.open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(48,24,35,.53); backdrop-filter: blur(7px); }
.modal-panel {
  width: min(620px, 100%); max-height: 92vh; overflow-y: auto; position: relative; z-index: 1;
  background: var(--paper); border-radius: 28px 28px 0 0; padding: 28px 20px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -18px 60px rgba(47,22,33,.3);
  animation: slideUp .25s ease both;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.modal-close { position: absolute; right: 14px; top: 12px; width: 40px; height: 40px; border:0; border-radius:50%; background:#f3e7eb; color:var(--wine); font-size:1.6rem; cursor:pointer; }
.modal-panel h2 { margin: 0 0 18px; font-size: 2rem; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid rgba(98,47,70,.2); border-radius: 13px; padding: 12px 13px; background: white; color: var(--ink); outline: none; }
input:focus, textarea:focus, select:focus { border-color: rgba(127,41,74,.6); box-shadow: 0 0 0 3px rgba(127,41,74,.09); }
textarea { resize: vertical; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions, .detail-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 5px; }
.primary-button, .secondary-button, .danger-button, .google-button {
  border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
}
.primary-button { color: white; background: linear-gradient(135deg, #a03c61, #711d40); }
.secondary-button { color: var(--wine); background: #f2e5ea; }
.danger-button { color: #9d2134; background: #fde8eb; margin-right: auto; }
.google-button { color: #244b8e; background: #e8f0fe; }
.form-status { min-height: 1.2em; color: var(--muted); }
.detail-panel h2 { font-size: 2.2rem; margin: 14px 0 8px; }
.detail-badge { display:inline-block; width:44px; height:8px; border-radius:999px; }
.detail-meta { display: grid; gap: 7px; color: var(--muted); font-size: 1.08rem; }
.detail-description { white-space: pre-wrap; line-height: 1.55; font-size: 1.15rem; }
@media (min-width: 760px) {
  .calendar-shell { grid-template-columns: 1.45fr .75fr; align-items: start; }
  .next-event-card { grid-column: 1 / -1; }
  .agenda-card { position: sticky; top: 104px; }
  .modal { place-items: center; padding: 24px; }
  .modal-panel { border-radius: 28px; max-height: 88vh; }
}
@media (max-width: 620px) {
  .calendar-day { min-height: 65px; padding: 5px; border-radius: 12px; }
  .day-preview { display: none; }
  .weekday-row, .calendar-grid { gap: 4px; }
  .topbar { grid-template-columns: 44px 1fr auto; padding-inline: 10px; }
  .today-button { padding: 9px 11px; }
  .two-columns { grid-template-columns: 1fr; }
}
