:root {
  color-scheme: light;
  --ink: #20201f;
  --muted: #6f6e69;
  --line: #e7e5df;
  --paper: #ffffff;
  --canvas: #f7f6f2;
  --soft: #eeece6;
  --green: #16784a;
  --green-soft: #daf3e5;
  --group: #dce7ff;
  --blue: #315fc4;
  --shadow: 0 1px 2px rgba(25, 25, 22, .08), 0 12px 32px rgba(25, 25, 22, .06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }
main { flex: 1; }
button, input { font: inherit; }
button { min-height: 44px; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(49, 95, 196, .28); outline-offset: 2px; }

.topbar {
  height: 68px;
  padding: 0 clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(247, 246, 242, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 11px; font-weight: 700; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--ink); border-radius: 9px; }
.quiet-button { border: 0; background: transparent; color: var(--muted); padding: 0 8px; cursor: pointer; }
.quiet-button:hover { color: var(--ink); }

main { width: min(1440px, 100%); margin: 0 auto; padding: clamp(34px, 6vw, 78px) clamp(16px, 4vw, 56px) 64px; }
.welcome { max-width: 790px; padding: clamp(8px, 5vw, 64px) 0; }
.eyebrow { color: var(--green); text-transform: uppercase; letter-spacing: .11em; font-size: 12px; font-weight: 750; margin-bottom: 12px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(42px, 7vw, 76px); line-height: .98; letter-spacing: -.055em; margin-bottom: 24px; }
.intro { font-size: clamp(18px, 2.2vw, 22px); line-height: 1.5; color: var(--muted); max-width: 600px; margin-bottom: 38px; }
.name-form label { display: block; font-size: 14px; font-weight: 650; margin-bottom: 8px; }
.name-row { display: flex; max-width: 620px; gap: 10px; }
.name-row input { min-width: 0; flex: 1; height: 52px; border: 1px solid #c9c7c0; background: var(--paper); border-radius: 10px; padding: 0 15px; }
.name-row button, .primary-button { border: 0; background: var(--ink); color: white; border-radius: 10px; padding: 0 20px; font-weight: 680; cursor: pointer; }
.name-row button:hover, .primary-button:hover { background: #000; }
.privacy-note { color: var(--muted); font-size: 13px; margin: 13px 0 0; }

.planner-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.planner-heading h1 { font-size: clamp(36px, 5vw, 56px); margin-bottom: 10px; }
.planner-heading p { color: var(--muted); margin-bottom: 0; line-height: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); padding-bottom: 6px; }
.legend span { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend-dot { width: 13px; height: 13px; border-radius: 4px; background: var(--green-soft); box-shadow: inset 0 0 0 1px rgba(22,120,74,.3); }
.legend-dot.group { background: var(--group); box-shadow: inset 0 0 0 1px rgba(49,95,196,.22); }
.legend-number { min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; display: grid; place-items: center; background: var(--paper); color: var(--blue); box-shadow: inset 0 0 0 1px var(--line); font-size: 9px; font-weight: 800; font-style: normal; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.mode-switch { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 14px; background: #e8e6df; border-radius: 11px; }
.mode-switch button { min-width: 112px; border: 0; border-radius: 8px; padding: 0 14px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 680; cursor: pointer; }
.mode-switch button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(25,25,22,.12); }
.heat-scale { display: flex; align-items: center; gap: 7px; width: fit-content; margin: -5px 2px 14px; color: var(--muted); font-size: 11px; font-weight: 650; }
.heat-scale i { width: 92px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, hsl(220 68% 94%), hsl(220 68% 58%)); }
.planner[data-mode="view"] .actionbar, .planner[data-mode="view"] .status { display: none; }
.calendars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.month { background: var(--paper); border-radius: 14px; padding: 18px 14px 15px; box-shadow: var(--shadow); }
.month h2 { font-size: 19px; letter-spacing: -.02em; margin: 0 4px 17px; }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekdays { margin-bottom: 5px; }
.weekdays span { text-align: center; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.day-placeholder { min-width: 0; aspect-ratio: 1; }
.day {
  min-width: 0;
  min-height: 40px;
  aspect-ratio: 1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 570;
  touch-action: manipulation;
}
.day:hover { background: var(--soft); }
.day.has-group { background: hsl(220 68% var(--heat-lightness, 92%)); color: #183567; }
.day.heat-strong:not([aria-pressed="true"]) { color: white; }
.day[aria-pressed="true"] { background: var(--green); color: white; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.day .day-count { position: absolute; right: 3px; top: 3px; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 99px; display: grid; place-items: center; background: rgba(255,255,255,.86); color: var(--blue); font-size: 9px; font-weight: 800; }
.day[aria-pressed="true"] .day-count { color: var(--green); }
.person-dots { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; justify-content: center; gap: 2px; pointer-events: none; }
.person-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--person-color); box-shadow: 0 0 0 1px rgba(255,255,255,.9); }
.day[aria-pressed="true"] .person-dot { box-shadow: 0 0 0 1px rgba(255,255,255,.85); }
.day.view-mode:hover { background: #e8eefb; }
.planner[data-mode="edit"] .days, .planner[data-mode="edit"] .day { touch-action: pan-y; user-select: none; -webkit-user-select: none; }

.actionbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; }
.selection-count { color: var(--muted); font-size: 14px; }
.action-buttons { display: flex; gap: 10px; }
.primary-button, .secondary-button { padding: 0 18px; }
.secondary-button { border: 1px solid #c9c7c0; background: var(--paper); color: var(--ink); border-radius: 10px; font-weight: 650; cursor: pointer; }
.secondary-button:hover { background: var(--soft); }
.status { min-height: 24px; color: var(--green); font-size: 14px; font-weight: 650; text-align: right; margin: 8px 2px 0; }
.status.error { color: #a52a2a; }

.overview { background: var(--paper); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); position: sticky; top: 92px; }
.overview-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.overview h2 { font-size: 22px; letter-spacing: -.025em; margin-bottom: 15px; }
.count-pill { min-width: 30px; height: 30px; padding: 0 8px; display: grid; place-items: center; border-radius: 99px; background: var(--soft); font-size: 13px; font-weight: 750; }
.people-list { display: grid; gap: 8px; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--person-color, var(--soft)); color: white; font-weight: 750; font-size: 12px; }
.person-row.current .avatar { box-shadow: 0 0 0 3px var(--green-soft); }
.person-meta { min-width: 0; flex: 1; }
.person-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; font-weight: 650; }
.person-days { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; line-height: 1.45; padding: 10px 0; }
.best-days { margin-top: 24px; }
.best-days h3 { font-size: 14px; margin-bottom: 10px; }
.best-days-list { display: grid; gap: 10px; }
.trip-window { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
.trip-window.unanimous { border-color: rgba(22,120,74,.42); background: linear-gradient(145deg, #e9f8ef, #fff9dd); }
.trip-window-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.trip-rank { color: var(--green); font-size: 12px; font-weight: 800; }
.trip-duration { padding: 3px 7px; border-radius: 99px; background: var(--paper); color: var(--muted); font-size: 10px; font-weight: 750; }
.trip-window h4 { margin: 0 0 5px; font-size: 14px; line-height: 1.35; }
.trip-window p { margin: 4px 0 0; font-size: 11px; line-height: 1.4; }
.trip-score { color: var(--green); font-weight: 750; }
.trip-people { color: var(--ink); }
.trip-unavailable { color: #8b3d33; }
.trip-party { color: #966000; font-weight: 800; }

.day-dialog { width: min(420px, calc(100vw - 28px)); border: 0; border-radius: 16px; padding: 22px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 80px rgba(20,20,18,.28); }
.day-dialog::backdrop { background: rgba(20,20,18,.46); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.dialog-head h2 { font-size: 23px; letter-spacing: -.025em; margin-bottom: 16px; }
.icon-button { width: 44px; min-width: 44px; border: 0; border-radius: 50%; background: var(--soft); color: var(--ink); font-size: 25px; line-height: 1; cursor: pointer; }
.dialog-people { display: flex; flex-wrap: wrap; gap: 8px; }
.person-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 11px 6px 7px; border-radius: 999px; background: var(--canvas); font-size: 14px; font-weight: 650; }
.person-chip-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--person-color); color: white; display: grid; place-items: center; font-size: 9px; font-weight: 800; }

.party-fire { position: fixed; z-index: 1001; left: 0; right: 0; bottom: -18px; height: clamp(74px, 19vw, 132px); display: flex; justify-content: space-around; align-items: end; pointer-events: none; overflow: hidden; }
.party-fire span { width: clamp(28px, 8vw, 72px); aspect-ratio: .72; background-image: radial-gradient(circle at 50% 73%, #fff7a3 0 15%, #ffc21c 16% 34%, #ff7417 35% 58%, #d52a0b 59% 76%, #7b1205 77%); clip-path: polygon(50% 0, 66% 25%, 82% 39%, 100% 68%, 84% 100%, 16% 100%, 0 68%, 20% 42%, 34% 25%); filter: drop-shadow(0 -8px 12px rgba(255,73,0,.38)); transform-origin: 50% 100%; animation: flame-dance .34s ease-in-out var(--flame-delay) infinite alternate; }
@keyframes flame-dance { from { transform: translateY(9px) rotate(-5deg) scale(.9, var(--flame-scale)); } to { transform: translateY(-4px) rotate(5deg) scale(1.08, var(--flame-scale)); } }
.party-shake main, .party-shake .topbar { animation: party-shake .65s cubic-bezier(.36,.07,.19,.97); }
@keyframes party-shake {
  0%,100% { transform: translate3d(0,0,0) rotate(0); }
  15% { transform: translate3d(-5px,2px,0) rotate(-.35deg); }
  30% { transform: translate3d(6px,-2px,0) rotate(.35deg); }
  45% { transform: translate3d(-4px,1px,0) rotate(-.25deg); }
  60% { transform: translate3d(4px,2px,0) rotate(.25deg); }
  75% { transform: translate3d(-2px,-1px,0) rotate(-.12deg); }
}

.honeypot { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
footer { padding: 22px clamp(18px, 4vw, 56px) 34px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .overview { position: static; }
  .people-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
}

@media (max-width: 780px) {
  .planner-heading { display: block; }
  .legend { margin-top: 18px; }
  .calendars { grid-template-columns: 1fr; }
  .month { padding: 20px 16px 17px; }
  .day { min-height: 44px; }
  .actionbar { align-items: stretch; flex-direction: column; }
  .action-buttons { display: grid; grid-template-columns: 1fr; }
  .status { text-align: left; }
}

@media (max-width: 520px) {
  .topbar { height: 60px; }
  main { padding-top: 30px; }
  h1 { font-size: 42px; }
  .name-row { display: grid; }
  .name-row button { height: 50px; }
  .people-list { grid-template-columns: 1fr; }
  .month { border-radius: 12px; }
  .day { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .party-fire { display: none !important; }
  .party-shake main, .party-shake .topbar { animation: none !important; }
}
