:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #17171b;
  --surface-2: #1f1f24;
  --line: #2a2a30;
  --text: #f5f5f7;
  --text-dim: #97979f;
  --text-faint: #5c5c63;
  --red-live: #ff5470;

  --main: #f9addf;
  --main-text: #20101c;
  --plant: #e3f26e;
  --plant-text: #171a08;
  --howl: #f1885a;
  --howl-text: #1c0d04;
  --unfold: #eceaf0;
  --unfold-text: #0b0b0d;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  touch-action: pan-y;
}

button, input {
  font-family: inherit;
  color: inherit;
}

button {
  transition: transform 0.1s ease, opacity 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(0.95);
  opacity: 0.85;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.rise-in {
  animation: rise-in 0.28s ease-out both;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 18px 12px;
  background: linear-gradient(100deg, #f9addf 0%, #e3f26e 55%, #cdb8f4 100%);
  color: #17130f;
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.wordmark {
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.subdate {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 20px;
  background: rgba(11, 11, 13, 0.14);
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* ---------- Views ---------- */

.view {
  flex: 1;
  padding: 14px 16px calc(90px + var(--safe-bottom));
  overflow-y: auto;
}

.view[hidden] {
  display: none !important;
}

/* ---------- Now view ---------- */

.day-banner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  margin-bottom: 14px;
}

.day-banner .big {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.day-banner .sub {
  color: var(--text-dim);
  font-size: 13.5px;
  margin-top: 4px;
}

.card-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 0;
}

.stage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.01em;
}

.stage-card-body {
  padding: 10px 14px 11px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.status-row.is-live { color: var(--red-live); }

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.is-live .live-dot { animation: pulse 1.4s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.now-artist {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin-top: 3px;
}

.now-artist-name {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.artist-tag {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.predicted-tag {
  color: #e0b64a;
  border-color: rgba(224, 182, 74, 0.4);
  border-style: dashed;
}

.now-time {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  margin-top: 8px;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
}

.next-line {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-label {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-right: 3px;
}

.next-time {
  color: var(--text-dim);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.star-btn {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-faint);
  padding: 2px;
  flex-shrink: 0;
}

.star-btn.is-starred { color: #ffce54; }

.wrap-msg, .idle-msg {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Schedule view ---------- */

.stage-filter {
  display: flex;
  gap: 5px;
  padding-bottom: 12px;
}

.filter-chip {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 11.5px;
  padding: 8px 2px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.filter-chip.is-active {
  color: var(--main-text);
  border-color: transparent;
}

.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-divider {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-faint);
  margin: 14px 2px 2px;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  scroll-margin-top: 90px;
}

.set-row.is-past { opacity: 0.42; }
.set-row.is-current { border-color: var(--red-live); }

.set-stage-bar {
  width: 5px;
  align-self: stretch;
  border-radius: 999px;
  flex-shrink: 0;
}

.set-time {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  width: 80px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.set-main { flex: 1; min-width: 0; }

.set-artist {
  font-weight: 800;
  font-size: 15.5px;
}

.set-stage-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 1px;
}

.now-chip {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--red-live);
  margin-left: 6px;
}

.set-row.priority-must .set-artist {
  color: var(--red-live);
}

.set-row.priority-if-time {
  opacity: 0.6;
}

.priority-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.plan-note {
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: 5px;
}

.priority-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: 999px;
}

.priority-btn.is-active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---------- Lineup / search ---------- */

.search-wrap { margin-bottom: 10px; }

#searchInput {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 16px;
  outline: none;
}

#searchInput:focus { border-color: var(--text-dim); }

.lineup-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.toggle-btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px;
  border-radius: var(--radius-sm);
}

.toggle-btn.is-active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.clash-warning {
  background: rgba(255, 84, 112, 0.12);
  border: 1px solid rgba(255, 84, 112, 0.35);
  color: #ff9daf;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.lineup-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skipped-clashes {
  margin-top: 14px;
  color: var(--text-dim);
}

.skipped-clashes details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.skipped-clashes summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.skipped-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.skipped-list div {
  display: grid;
  gap: 2px;
  font-size: 12px;
}

.skipped-list strong { color: var(--text); }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 40px 20px;
  line-height: 1.5;
}

/* ---------- Map view ---------- */

#view-map {
  padding: 0 0 calc(90px + var(--safe-bottom));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-wrap {
  flex: 1;
  overflow-y: auto;
  background: #0b0b0d;
}

.map-link {
  display: block;
  line-height: 0;
}

#mapImg {
  display: block;
  width: 100%;
  height: auto;
}

.map-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 8px 0 0;
  margin: 0;
  background: var(--bg);
}

.water-note {
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 20px 0 0;
  padding: 0 20px 10px;
  background: var(--bg);
}

/* ---------- Tabbar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  background: rgba(23, 23, 27, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + var(--safe-bottom));
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
}

.tab-icon {
  display: flex;
  opacity: 0.65;
}

.tab-icon svg {
  width: 22px;
  height: 22px;
}

.tab.is-active { color: var(--text); }
.tab.is-active .tab-icon {
  opacity: 1;
  color: var(--main);
}
.tab.is-active .tab-icon svg {
  fill: color-mix(in srgb, currentColor 20%, transparent);
}

@media (min-width: 560px) {
  body { max-width: 480px; margin: 0 auto; }
  .tabbar { max-width: 480px; margin: 0 auto; }
}
