@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #0e1115;
  --panel: #161a20;
  --panel-2: #1d222a;
  --line: #2c323c;
  --line-strong: #444c58;
  --text: #eceee6;
  --muted: #a6aeb8;
  --signal: #d7ff3f;
  --signal-ink: #0e1115;
  --warn: #ffb35c;

  --c-Art: #ff8a5c;
  --c-Film: #7cc4ff;
  --c-Food: #ffd166;
  --c-Literature: #c9a7ff;
  --c-Music: #ff79b4;
  --c-Outdoors: #6ee7a8;
  --c-Walks: #e9e4cf;

  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --pad: clamp(16px, 3vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--ink); scroll-padding-top: 120px; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 700;
  text-decoration: none;
}
.skip:focus { top: 12px; }

.shell {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

/* ---------- Masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--line);
}
.masthead-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  padding-top: 28px;
  padding-bottom: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-right: auto;
}
.brand-mark {
  width: 56px;
  height: 56px;
  flex: none;
  color: var(--text);
}
.wordmark {
  font-size: 56px;
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: -0.045em;
  text-transform: lowercase;
}
.wordmark span { color: var(--signal); }
.tagline {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
}
.stats > div {
  padding: 8px 18px;
  border-left: 1px solid var(--line);
  min-width: 96px;
}
.stats > div:first-child { border-left: 0; }
.stats dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stats dd {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.plan-jump {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 8px 0 16px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.plan-jump:hover { border-color: var(--signal); }
.plan-jump-count {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 14px;
}
.plan-jump.has-items .plan-jump-count {
  background: var(--signal);
  color: var(--signal-ink);
}

/* ---------- Controls ---------- */

.controls-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(14, 17, 21, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px auto auto;
  align-items: end;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.field { display: grid; gap: 6px; }
.field label, .field-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.input-shell, .select-shell {
  position: relative;
  display: flex;
  align-items: center;
}
.input-shell svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.input-shell input,
.select-shell select {
  width: 100%;
  min-height: 48px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  font-size: 16px;
}
.input-shell input { padding: 0 14px 0 42px; }
.input-shell input::placeholder { color: #7d8691; }
.input-shell input:hover,
.select-shell select:hover { border-color: #5d6674; }
.input-shell input:focus-visible,
.select-shell select:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 0;
  border-color: var(--signal);
}
.select-shell select {
  appearance: none;
  padding: 0 40px 0 14px;
}
.select-shell::after {
  content: "";
  position: absolute;
  right: 16px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}
.select-shell option { background: var(--panel); color: var(--text); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px 0 12px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  font-weight: 600;
  white-space: nowrap;
}
.toggle:hover { border-color: #5d6674; }
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border: 2px solid var(--muted);
  flex: none;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: var(--muted);
  transition: transform 160ms ease;
}
.toggle[aria-pressed="true"] {
  border-color: var(--signal);
}
.toggle[aria-pressed="true"] .toggle-track { border-color: var(--signal); }
.toggle[aria-pressed="true"] .toggle-thumb {
  background: var(--signal);
  transform: translateX(16px);
}
.toggle-count {
  font-family: var(--mono);
  font-size: 13px;
  padding: 2px 7px;
  background: var(--panel-2);
}
.toggle[aria-pressed="true"] .toggle-count {
  background: var(--signal);
  color: var(--signal-ink);
}

.result-count {
  align-self: center;
  justify-self: end;
  padding-top: 18px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 32px;
  padding-top: 28px;
  padding-bottom: 48px;
  align-items: start;
}
.board-area:focus { outline: none; }

.board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.day {
  border-top: 3px solid var(--text);
}
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
}
.day-name {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}
.day-date {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.day-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

/* hour ruler aligned with span bars */
.ruler {
  position: relative;
  height: 22px;
  margin: 0 0 4px 92px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.ruler span {
  position: absolute;
  bottom: 4px;
  transform: translateX(-50%);
}
.ruler span:first-child { transform: none; }
.ruler span:last-child { transform: translateX(-100%); }

.slots { display: grid; }

.slot {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 12px 16px 0;
  border-bottom: 1px solid var(--line);
  transition: background-color 140ms ease;
}
.slot:hover { background: var(--panel); }
.slot:focus-within { background: var(--panel); }

.slot-time {
  font-family: var(--mono);
  line-height: 1.25;
  padding-left: 4px;
}
.slot-time .start {
  display: block;
  font-size: 20px;
  color: var(--text);
}
.slot-time .end {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.slot-main { min-width: 0; }

.cat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.cat::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--cat, var(--muted));
  flex: none;
}

.slot-title {
  margin-top: 4px;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.open {
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  line-height: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}
.open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.open:focus-visible { outline: none; }
.open:focus-visible::after {
  outline: 3px solid var(--signal);
  outline-offset: -3px;
}
.slot:hover .open { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--signal); }

.slot-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}
.slot-meta .price { color: var(--text); font-weight: 600; }
.slot-meta .free { color: var(--signal); }

.span-bar {
  position: relative;
  height: 6px;
  margin-top: 12px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px calc(100% / 7));
}
.span-bar i {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--cat, var(--text));
}

.slot-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}
.saved-tag {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: var(--signal);
  color: var(--signal-ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.saved-tag svg { width: 10px; height: 12px; }

.day-empty {
  padding: 24px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

/* ---------- Empty state ---------- */

.empty {
  padding: 56px 32px;
  border: 1px dashed var(--line-strong);
  text-align: left;
}
.empty-code {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--warn);
}
.empty-title {
  margin-top: 10px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.empty-text {
  margin-top: 10px;
  max-width: 48ch;
  color: var(--muted);
}
.empty .btn { margin-top: 22px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  font-weight: 700;
  font-size: 16px;
}
.btn:hover { border-color: var(--text); }
.btn-signal {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--signal-ink);
}
.btn-signal:hover { background: #e6ff85; border-color: #e6ff85; }

/* ---------- Shortlist panel ---------- */

.plan {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 124px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
}
.plan:focus { outline: none; }
.plan:focus-visible { outline: 3px solid var(--signal); }
.plan-inner { padding: 22px 22px 24px; }
.plan-kicker {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.plan-title {
  margin-top: 2px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.plan-empty {
  margin-top: 14px;
  color: var(--muted);
}
.plan-empty strong { color: var(--text); font-weight: 600; }
.plan-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  border: 1px solid var(--line);
}
.plan-summary > div { padding: 10px 12px; }
.plan-summary > div + div { border-left: 1px solid var(--line); }
.plan-summary dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.plan-summary dd { font-size: 22px; font-weight: 700; }

.plan-day { margin-top: 20px; }
.plan-day h3 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.plan-list li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.plan-time {
  font-family: var(--mono);
  font-size: 14px;
  padding-top: 2px;
}
.plan-open {
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  font-weight: 600;
  line-height: 1.3;
}
.plan-open:hover { text-decoration: underline; text-decoration-color: var(--signal); text-underline-offset: 3px; }
.plan-where {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.clash {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--warn);
}
.plan-remove {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.plan-remove:hover { color: var(--text); border-color: var(--text); }
.plan-remove svg { width: 12px; height: 12px; }

/* ---------- Footer ---------- */

.foot {
  padding-top: 24px;
  padding-bottom: 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.foot p { max-width: 80ch; }

/* ---------- Detail dialog ---------- */

.detail {
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}
.detail::backdrop {
  background: rgba(6, 8, 10, 0.72);
}
.detail[open] { animation: drawer-in 220ms cubic-bezier(.2,.7,.2,1); }

@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.detail-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 16px 28px;
  border-bottom: 1px solid var(--line);
  border-top: 6px solid var(--cat, var(--signal));
}
.detail-close {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line-strong);
  font-weight: 600;
}
.detail-close:hover { border-color: var(--text); }
.detail-close svg { width: 14px; height: 14px; }
.detail-close kbd {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  padding: 1px 5px;
}

.detail-scroll {
  flex: 1;
  overflow: auto;
  padding: 28px 28px 32px;
}
.detail-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.detail-when {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  font-family: var(--mono);
}
.detail-when .big {
  font-size: 28px;
  color: var(--signal);
}
.detail-when .when-day { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-when .dur { font-size: 14px; color: var(--muted); }

.detail .ruler { margin: 22px 0 4px; }
.detail .span-bar { margin: 0; height: 10px; }

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 24px;
  border-top: 1px solid var(--line);
}
.facts > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.facts > div:nth-child(odd) { padding-right: 12px; }
.facts > div:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
.facts dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { font-size: 17px; font-weight: 600; margin-top: 2px; }

.detail-body-label {
  margin-top: 28px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-body {
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.6;
  max-width: 60ch;
}
.detail-body p + p {
  margin-top: 16px;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--panel-2);
  border-left: 3px solid var(--cat, var(--signal));
}

.detail-foot {
  display: grid;
  gap: 10px;
  padding: 16px 28px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.detail-foot .btn { width: 100%; }
.save-btn[aria-pressed="true"] {
  background: transparent;
  border-color: var(--signal);
  color: var(--signal);
}
.save-btn[aria-pressed="true"]:hover { background: rgba(215, 255, 63, 0.08); }
.save-btn svg { width: 18px; height: 18px; }
.detail-note {
  font-size: 14px;
  color: var(--muted);
  min-height: 1.5em;
}
.detail-note.warn { color: var(--warn); }

.detail-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detail-nav .btn { min-height: 44px; font-weight: 600; font-size: 15px; padding: 0 12px; }
.detail-nav .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.detail-nav .btn:disabled:hover { border-color: var(--line-strong); }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .stats { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .board { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  html { scroll-padding-top: 190px; }
  .layout { grid-template-columns: 1fr; gap: 28px; padding-top: 20px; }
  .plan { position: static; max-height: none; }
  .controls {
    grid-template-columns: 1fr auto;
    gap: 10px 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .field-search { grid-column: 1 / -1; }
  .field label, .field-label { font-size: 11px; }
  .field-toggle .field-label { display: none; }
  .result-count {
    grid-column: 1 / -1;
    justify-self: start;
    padding-top: 0;
    font-size: 12px;
  }
}

@media (max-width: 560px) {
  html { scroll-padding-top: 16px; }
  .controls-wrap { position: static; }
  .masthead-inner { gap: 12px; padding-top: 16px; padding-bottom: 14px; }
  .brand { gap: 12px; }
  .brand-mark { width: 38px; height: 38px; }
  .wordmark { font-size: 38px; }
  .tagline { font-size: 11px; margin-top: 6px; letter-spacing: 0.03em; }
  .plan-jump { padding: 0 6px 0 10px; min-height: 44px; }
  .plan-jump-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .plan-jump::before {
    content: "";
    width: 14px; height: 18px;
    background: currentColor;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  }
  .input-shell input, .select-shell select, .toggle { min-height: 44px; }
  .toggle { padding: 0 10px; gap: 8px; }
  .day-name { font-size: 32px; }
  .ruler { margin-left: 70px; }
  .slot { grid-template-columns: 58px minmax(0, 1fr); gap: 12px; padding: 14px 8px 14px 0; }
  .slot-time .start { font-size: 17px; }
  .slot-title { font-size: 19px; }
  .slot-meta { font-size: 14px; }
  .saved-tag { font-size: 10px; padding: 2px 6px; }
  .empty { padding: 36px 20px; }
  .empty-title { font-size: 26px; }

  .detail {
    width: 100vw;
    height: auto;
    max-height: 92vh;
    max-height: 92dvh;
    margin: auto 0 0 0;
    border-left: 0;
    border-top: 1px solid var(--line-strong);
  }
  .detail[open] { animation-name: sheet-in; }
  .detail-inner { max-height: 92vh; max-height: 92dvh; }
  .detail-top { padding: 12px 14px 12px 20px; }
  .detail-close kbd { display: none; }
  .detail-scroll { padding: 20px 20px 24px; }
  .detail-title { font-size: 30px; }
  .detail-when .big { font-size: 22px; }
  .detail-body { font-size: 17px; }
  .facts { grid-template-columns: 1fr; }
  .facts > div:nth-child(n) { padding: 10px 0; border-left: 0; }
  .detail-foot { padding: 12px 20px 16px; }
}

@keyframes sheet-in {
  from { transform: translateY(48px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
