:root {
  --paper: #f2f4fb;
  --card: #ffffff;
  --ink: #0f1440;
  --muted: #474d7c;
  --line: #c4c9e6;
  --cobalt: #2538f5;
  --cobalt-deep: #1a27b8;
  --lime: #d6f23a;
  --warn: #a8231b;
  --warn-bg: #fff0ee;
  --sans: "Helvetica Neue", "Arial Nova", Arial, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  accent-color: var(--cobalt);
  caret-color: var(--cobalt);
  scrollbar-color: var(--cobalt) var(--paper);
}
body:has(dialog[open]) { overflow: hidden; }

::selection { background: var(--lime); color: var(--ink); }

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }
.masthead :focus-visible, .d-top :focus-visible { outline-color: var(--lime); }

.ico, .input-icon, .tag svg, .chip svg {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 32px; }

.skip {
  position: absolute; left: 16px; top: -64px; z-index: 50;
  background: var(--lime); color: var(--ink); font-weight: 700;
  padding: 12px 16px; border-radius: 10px; text-decoration: none;
}
.skip:focus { top: 16px; }

/* ---------- Masthead ---------- */
.masthead {
  position: relative;
  background: var(--cobalt);
  color: #fff;
  padding: 44px 0 40px;
  overflow: hidden;
  isolation: isolate;
}
.masthead::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.2) 1.6px, transparent 1.8px);
  background-size: 14px 14px;
  -webkit-mask-image: linear-gradient(100deg, transparent 35%, #000 100%);
  mask-image: linear-gradient(100deg, transparent 35%, #000 100%);
}
.mast-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 40px;
  align-items: end;
}
.mast-copy h1 {
  font-size: clamp(2.75rem, 7.4vw, 6rem);
  line-height: 0.92;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.mast-copy p {
  margin-top: 20px;
  max-width: 44ch;
  font-size: 1.125rem;
  color: #e4e7ff;
  text-wrap: pretty;
}

.tiles { display: flex; gap: 14px; }
.tile {
  display: flex; align-items: center; gap: 16px;
  min-width: 232px;
  padding: 16px 22px 16px 20px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  color: #fff;
  text-decoration: none;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.tile .num {
  font-size: clamp(3.5rem, 6.4vw, 5.5rem);
  line-height: 0.82;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--lime);
  font-variant-numeric: tabular-nums;
}
.tile .lbl strong { display: block; font-size: 1.1875rem; line-height: 1.2; }
.tile .lbl span { font-size: 0.9375rem; color: #e4e7ff; }
.tile:hover { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.tile:hover .num { color: var(--cobalt); }
.tile:hover .lbl span { color: #2a2f6b; }
.tile[aria-disabled="true"] { opacity: 0.6; cursor: default; }
.tile[aria-disabled="true"]:hover { background: transparent; border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.tile[aria-disabled="true"]:hover .num { color: var(--lime); }
.tile[aria-disabled="true"]:hover .lbl span { color: #e4e7ff; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 56px;
  padding-top: 36px;
  padding-bottom: 96px;
  align-items: start;
}

/* ---------- Tools ---------- */
.tools {
  position: sticky; top: 24px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 4px;
  margin: -4px;
  display: flex; flex-direction: column; gap: 18px;
}
.tools-title { font-size: 1.625rem; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }

.field label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 0.9375rem; }

.input-wrap { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

input[type="text"], select {
  width: 100%; height: 50px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 1rem;
}
input[type="text"] { padding-left: 44px; }
input[type="text"]::placeholder { color: #5b6190; opacity: 1; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f1440' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
}

.toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 50px;
  padding: 0 14px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-weight: 700;
  text-align: left;
  transition: background-color 0.15s, color 0.15s;
}
.toggle .count {
  margin-left: auto;
  min-width: 28px; padding: 1px 8px;
  border-radius: 999px;
  background: var(--ink); color: #fff;
  font-family: var(--mono); font-size: 0.875rem; text-align: center;
}
.toggle:hover { background: #e9ecfb; }
.toggle[aria-pressed="true"] { background: var(--lime); }
.toggle[aria-pressed="true"] .ico { fill: currentColor; }

/* Shortlist panel */
.plan {
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
}
.plan summary {
  list-style: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 48px 14px 16px;
  position: relative;
  border-radius: 14px;
}
.plan summary::-webkit-details-marker { display: none; }
.plan summary::after {
  content: ""; position: absolute; right: 16px; top: 50%;
  width: 20px; height: 20px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f1440' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.2s var(--ease);
}
.plan[open] summary::after { transform: translateY(-50%) rotate(180deg); }
.plan-name { font-weight: 800; font-size: 1.125rem; }
.plan-meta { color: var(--muted); font-size: 0.9375rem; }
.plan-body { padding: 0 16px 16px; }
.plan-empty { color: var(--muted); font-size: 0.9375rem; text-wrap: pretty; }
.plan-list { display: flex; flex-direction: column; }
.plan-item {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.plan-item:first-child { border-top: 0; padding-top: 4px; }
.plan-when { grid-column: 1 / -1; font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.plan-open {
  all: unset; box-sizing: border-box;
  cursor: pointer; font-weight: 700; line-height: 1.25;
  border-radius: 6px;
}
.plan-open:hover { color: var(--cobalt-deep); text-decoration: underline; text-underline-offset: 3px; }
.plan-open:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }
.plan-remove {
  align-self: start;
  width: 44px; height: 44px; margin: -10px -10px -10px 0;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%;
  color: var(--muted);
}
.plan-remove:hover { background: #e9ecfb; color: var(--ink); }
.plan-clash { grid-column: 1 / -1; font-size: 0.875rem; font-weight: 600; color: var(--warn); }
.plan-total {
  margin-top: 8px; padding-top: 12px;
  border-top: 1.5px solid var(--ink);
  display: flex; justify-content: space-between; gap: 8px;
  font-weight: 700;
}
.plan-total span:last-child { font-family: var(--mono); }

/* ---------- Main list ---------- */
.status { margin-bottom: 20px; color: var(--muted); font-size: 0.9375rem; min-height: 1.5em; }

.day { margin-bottom: 64px; scroll-margin-top: 16px; }
.day-head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px;
  margin-bottom: 14px;
}
.day-head h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.035em;
}
.day-head .date { font-family: var(--mono); font-size: 1rem; color: var(--muted); }
.day-head .n { margin-left: auto; font-size: 0.9375rem; color: var(--muted); }

.rows { isolation: isolate; }
.row {
  position: relative;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 20px;
  padding: 22px 60px 24px 0;
  border-top: 1.5px solid var(--ink);
}
.row::before {
  content: ""; position: absolute; inset: 0 -16px; z-index: -1;
  background: var(--card); border-radius: 16px;
  opacity: 0; transition: opacity 0.15s;
}
.row:hover::before { opacity: 1; }
.row:hover .t-start { color: var(--cobalt-deep); }

.time { font-family: var(--mono); font-variant-numeric: tabular-nums; padding-top: 4px; }
.t-start { font-size: 1.625rem; line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.t-start small { font-size: 0.9375rem; font-weight: 600; letter-spacing: 0; margin-left: 2px; }
.t-end { margin-top: 6px; font-size: 0.8125rem; color: var(--muted); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 0.875rem; color: var(--cobalt-deep);
}
.tag svg { width: 18px; height: 18px; }

.row h3 { margin: 6px 0 4px; font-size: clamp(1.25rem, 2.2vw, 1.75rem); line-height: 1.1; font-weight: 800; letter-spacing: -0.025em; text-wrap: balance; }
.open {
  all: unset; box-sizing: border-box;
  cursor: pointer;
}
.open::after { content: ""; position: absolute; inset: 0 -16px; border-radius: 16px; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--cobalt); outline-offset: -3px; }

.where { color: var(--muted); font-size: 0.9375rem; }
.sum { margin-top: 8px; max-width: 62ch; text-wrap: pretty; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 12px; min-height: 28px;
  border: 1.5px solid var(--ink); border-radius: 999px;
  font-size: 0.8125rem; font-weight: 700;
}
.chip.free { background: var(--lime); border-color: var(--lime); }

.quick {
  position: absolute; top: 18px; right: 0; z-index: 2;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--card); border: 2px solid var(--ink); border-radius: 50%;
  transition: background-color 0.15s, color 0.15s;
}
.quick:hover { background: var(--lime); }
.quick[aria-pressed="true"] { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.quick[aria-pressed="true"] .ico { fill: currentColor; }

.empty {
  padding: 40px 32px;
  border: 2px dashed var(--ink); border-radius: 20px;
  background: var(--card);
  max-width: 640px;
}
.empty h2 { font-size: 1.875rem; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; }
.empty p { margin: 12px 0 24px; color: var(--muted); max-width: 46ch; text-wrap: pretty; }

.btn {
  height: 50px; padding: 0 22px;
  background: var(--ink); color: #fff;
  border: 2px solid var(--ink); border-radius: 12px;
  font-weight: 700;
}
.btn:hover { background: var(--cobalt); border-color: var(--cobalt); }

.foot { border-top: 1.5px solid var(--ink); padding: 24px 0 40px; color: var(--muted); font-size: 0.9375rem; }

/* ---------- Detail drawer ---------- */
dialog.detail {
  border: 0; padding: 0;
  margin: 0 0 0 auto;
  width: min(620px, 100vw); max-width: 100vw;
  height: 100dvh; max-height: 100dvh;
  background: var(--paper); color: var(--ink);
  overflow: hidden;
}
dialog.detail:not([open]) { display: none; }
dialog.detail::backdrop { background: rgba(15, 20, 64, 0.6); }

.shell { display: flex; flex-direction: column; height: 100%; }

.d-top {
  position: relative; flex: none;
  background: var(--cobalt); color: #fff;
  padding: 20px 24px 28px;
}
.d-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.d-top .tag { color: var(--lime); font-size: 1rem; }
.d-top .tag svg { width: 22px; height: 22px; }
.close {
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 16px 0 18px;
  background: transparent; color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.7); border-radius: 999px;
  font-weight: 700;
}
.close:hover { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.d-top h2 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.d-scroll { flex: 1; overflow-y: auto; padding: 24px 24px 32px; overscroll-behavior: contain; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.facts dt { font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.facts dd { font-weight: 700; font-size: 1.0625rem; line-height: 1.3; margin-top: 2px; }
.facts .wide { grid-column: 1 / -1; }
.facts .sub { display: block; font-weight: 500; font-size: 0.9375rem; color: var(--muted); }

.bar { margin: 24px 0 8px; }
.bar-track { position: relative; height: 24px; background: #dfe3f6; border-radius: 999px; overflow: hidden; }
.bar-fill { position: absolute; top: 0; bottom: 0; background: var(--cobalt); border-radius: 999px; min-width: 10px; }
.bar-ticks { position: relative; height: 20px; margin-top: 6px; font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.bar-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.bar-ticks span:first-child { transform: none; }
.bar-ticks span:last-child { transform: translateX(-100%); }

.clash {
  margin-top: 16px; padding: 12px 14px;
  background: var(--warn-bg); color: var(--warn);
  border: 1.5px solid var(--warn); border-radius: 12px;
  font-weight: 600; font-size: 0.9375rem;
}
.clash:empty { display: none; }

.d-body { margin-top: 28px; }
.d-body p { font-size: 1.125rem; line-height: 1.6; max-width: 60ch; text-wrap: pretty; }
.d-body p + p, .d-body p + .access { margin-top: 18px; }
.access {
  padding: 16px 18px 18px;
  background: var(--card);
  border: 1.5px solid var(--ink); border-radius: 14px;
}
.access h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 800; margin-bottom: 6px; }
.access h3 svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.access p { font-size: 1.0625rem; }

.d-foot {
  flex: none;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1.5px solid var(--ink);
}
.save {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 56px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 14px;
  font-size: 1.0625rem; font-weight: 800;
  transition: background-color 0.15s, color 0.15s;
}
.save .ico { width: 22px; height: 22px; }
.save:hover { background: var(--ink); color: #fff; }
.save[aria-pressed="true"] { background: var(--lime); }
.save[aria-pressed="true"] .ico { fill: currentColor; }
.save[aria-pressed="true"]:hover { background: var(--ink); color: #fff; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  dialog.detail[open] { animation: drawer 0.38s var(--ease); }
  dialog.detail[open]::backdrop { animation: fade 0.3s ease-out; }
  .intro .day { animation: rise 0.5s var(--ease) both; }
  .intro .day:nth-of-type(2) { animation-delay: 0.08s; }
}
@keyframes drawer { from { transform: translateX(48px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Tablet / mobile ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); gap: 36px; }
  .tile { min-width: 0; }
  .mast-grid { grid-template-columns: 1fr; align-items: start; gap: 28px; }
}

@media (max-width: 899px) {
  .wrap { padding: 0 16px; }
  .masthead { padding: 28px 0 24px; }
  .mast-copy p { font-size: 1rem; margin-top: 12px; }
  .tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { gap: 12px; padding: 12px 14px; border-radius: 16px; }
  .tile .num { font-size: 3.25rem; }
  .tile .lbl strong { font-size: 1rem; }
  .tile .lbl span { font-size: 0.875rem; }

  .layout { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 24px; padding-bottom: 64px; }
  .tools { position: static; max-height: none; overflow: visible; gap: 14px; padding: 0; margin: 0; }
  .tools-title { font-size: 1.375rem; }
  .field label { margin-bottom: 4px; }

  .row { grid-template-columns: 66px minmax(0, 1fr); gap: 14px; padding: 18px 54px 20px 0; }
  .row::before { inset: 0 -10px; }
  .open::after { inset: 0 -10px; }
  .t-start { font-size: 1.25rem; }
  .t-start small { font-size: 0.8125rem; display: block; margin: 2px 0 0; }
  .t-end { font-size: 0.75rem; }
  .quick { top: 14px; right: -2px; }
  .day { margin-bottom: 44px; }

  dialog.detail { width: 100vw; }
  .d-top { padding: 14px 16px 22px; }
  .d-bar { margin-bottom: 14px; }
  .d-scroll { padding: 20px 16px 28px; }
  .d-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .facts { gap: 16px 14px; }
}

@keyframes drawer-up { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
  dialog.detail[open] { animation-name: drawer-up; }
}
