/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  --bg: #0b0c0e;
  --surface: #15171b;
  --surface-2: #1c1f25;
  --border: #2a2d34;
  --border-strong: #3a3e47;
  --text: #f3f3ef;
  --text-muted: #9a9da6;
  --text-faint: #6c6f78;
  --accent: #d7ff3d;
  --accent-ink: #0b0c0e;
  --danger: #ff6b6b;

  --cat-art: #ff9a4d;
  --cat-film: #7dd3fc;
  --cat-food: #ffd23d;
  --cat-literature: #c9a2ff;
  --cat-music: #d7ff3d;
  --cat-outdoors: #4ade80;
  --cat-walks: #f472b6;

  --font-display: -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-body: -apple-system, "system-ui", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --radius-sm: 2px;
  --radius-md: 3px;
  --container: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Utility ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 18px;
  font-weight: 700;
  z-index: 100;
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  left: 12px;
  top: 12px;
}

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

button {
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 28px clamp(20px, 4vw, 56px) 20px;
}

.header-top {
  max-width: var(--container);
  margin: 0 auto 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 255, 61, 0.18);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .brand-mark {
    animation: blip 2.4s ease-in-out infinite;
  }
}

@keyframes blip {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 3px rgba(215, 255, 61, 0.18); }
  50% { opacity: 0.55; box-shadow: 0 0 0 6px rgba(215, 255, 61, 0.06); }
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0;
}

.brand-dot {
  color: var(--accent);
}

.tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.controls {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.field-search {
  flex: 1 1 260px;
  min-width: 200px;
}

.field-search input,
.field-filter select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-body);
  height: 44px;
}

.field-search input::placeholder {
  color: var(--text-faint);
}

.field-search input:hover,
.field-filter select:hover {
  border-color: var(--text-faint);
}

.field-filter select {
  min-width: 170px;
  color-scheme: dark;
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.pill-toggle:hover {
  border-color: var(--text-faint);
}

.pill-toggle .icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: color 120ms ease;
}

.pill-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pill-toggle[aria-pressed="true"] .icon {
  color: var(--accent-ink);
}
.pill-toggle[aria-pressed="true"] .icon path {
  fill: var(--accent-ink);
}

.toggle-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 12px;
}

.pill-toggle[aria-pressed="true"] .toggle-count {
  background: rgba(11, 12, 14, 0.18);
}

/* ---------- Main ---------- */
main {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px clamp(20px, 4vw, 56px) 60px;
}

.results-summary {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 0 0 22px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day-section {
  margin-bottom: 36px;
}

.day-heading {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 15px;
  letter-spacing: 0.06em;
  font-weight: 900;
  color: var(--text);
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.day-heading .day-count {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.item-row {
  background: var(--surface);
  display: grid;
  grid-template-columns: 92px 1fr auto auto auto;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  transition: background-color 120ms ease;
}

.item-row:hover {
  background: var(--surface-2);
}

.item-time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.item-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub .saved-flag {
  color: var(--accent);
  font-weight: 700;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
  justify-self: start;
}

.badge-art { color: var(--cat-art); }
.badge-film { color: var(--cat-film); }
.badge-food { color: var(--cat-food); }
.badge-literature { color: var(--cat-literature); }
.badge-music { color: var(--cat-music); }
.badge-outdoors { color: var(--cat-outdoors); }
.badge-walks { color: var(--cat-walks); }

.item-price {
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  justify-self: end;
}

.open-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.open-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.empty-title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 18px;
  margin: 0 0 8px;
}

.empty-hint {
  color: var(--text-muted);
  margin: 0 0 20px;
}

.reset-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.reset-btn:hover {
  filter: brightness(1.08);
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 56px) 48px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------- Detail panel ---------- */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 8, 0.6);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
  overscroll-behavior: contain;
}

.detail-backdrop[hidden] {
  display: none;
}

.detail {
  width: min(460px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  padding: 24px clamp(20px, 4vw, 32px) 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (prefers-reduced-motion: no-preference) {
  .detail {
    animation: slide-in 220ms ease-out;
  }
}

@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.detail-category {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.close-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.close-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.close-btn svg {
  width: 16px;
  height: 16px;
}

.detail-title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  text-wrap: balance;
}

.detail-meta {
  margin: 0 0 24px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.meta-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  margin: 0;
}

.meta-row dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
}

.meta-row dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.detail-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
  margin-bottom: 28px;
}

.detail-actions {
  display: flex;
}

.save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  height: 48px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.save-btn:hover {
  background: rgba(215, 255, 61, 0.1);
}

.save-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.save-btn .icon path {
  transition: fill 120ms ease;
}

.save-btn[aria-pressed="true"] .icon path {
  fill: var(--accent-ink);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .item-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "time badge"
      "main main"
      "price open";
    row-gap: 8px;
  }
  .item-time { grid-area: time; }
  .badge { grid-area: badge; justify-self: end; }
  .item-main { grid-area: main; }
  .item-price { grid-area: price; justify-self: start; }
  .open-btn { grid-area: open; justify-self: end; }

  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .field-filter select,
  .pill-toggle {
    width: 100%;
    justify-content: center;
  }

  .detail {
    width: 100%;
  }
}
