:root {
  --bg: #0c0c0e;
  --surface: #141417;
  --surface2: #1c1c21;
  --surface3: #252529;
  --border: #2a2a30;
  --text: #e8e8ec;
  --text-dim: #888898;
  --text-faint: #444458;
  --accent: #c8a84b;
  --accent-dim: #7a6529;
  --row-h: 42px;
  --time-scale: 1.5; /* px per minute */
  --label-w: 160px;
  --header-h: 56px;
  --font-body: 13px;
  --font-ui: 11px;
  --font-small: 11px;
  --font-tiny: 10px;
  --font-tab: 12px;
  --font-logo: 18px;
  --font-logo-sub: 12px;
  --font-tooltip-title: 14px;
  --font-bookmark-title: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: var(--font-body);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* HEADER */
#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--header-h);
}
.logo {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  font-size: var(--font-logo);
  color: var(--accent);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.logo span { color: var(--text-dim); font-size: var(--font-logo-sub); font-weight: 400; margin-left: 6px; }

/* DAY TABS */
.day-tabs {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  flex: 1 1 auto;
  min-width: 0;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  padding: 6px 11px;
  border-radius: 4px;
  cursor: pointer;
  font-size: var(--font-tab);
  white-space: nowrap;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  font-weight: 500;
  position: relative;
}
.day-tab:hover {
  background: rgba(200,168,75,0.12);
  border-color: rgba(200,168,75,0.28);
  color: var(--accent);
}
.day-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.day-tab.active:hover {
  background: rgba(122,101,41,0.92);
  border-color: #dcc37a;
  color: #f2e0a6;
  box-shadow: inset 0 0 0 1px rgba(255,244,204,0.08);
}
.day-tab.has-search-match::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ff6b57;
  box-shadow: 0 0 10px rgba(255,107,87,0.85);
}

/* CONTROLS BAR */
#controls {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.search-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 240px;
}
.search-shell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.035);
}
.search-shell:focus-within {
  border-color: rgba(200,168,75,0.45);
  box-shadow: 0 0 0 1px rgba(200,168,75,0.12);
}
.search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--font-ui);
  font-family: inherit;
}
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.search-input::placeholder {
  color: var(--text-faint);
}
.search-clear-btn {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font-size: var(--font-ui);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.search-clear-btn:hover {
  color: var(--text);
  border-color: rgba(200,168,75,0.35);
}
.search-clear-btn.hidden {
  visibility: hidden;
  pointer-events: none;
}
.filter-label { color: var(--text-dim); font-size: var(--font-ui); white-space: nowrap; }
.venue-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.vf-btn {
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.vf-btn:hover { border-color: var(--accent-dim); color: var(--text); }
.vf-btn.active { background: var(--surface3); border-color: var(--accent); color: var(--accent); }

.sep { width: 1px; background: var(--border); height: 20px; margin: 0 4px; flex-shrink: 0; }

.bookmark-btn {
  padding: 4px 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--font-ui);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.bookmark-btn:hover { border-color: var(--accent); color: var(--accent); }
.bookmark-btn.has-items { border-color: var(--accent-dim); color: var(--accent); }

/* DENSITY CONTROLS */
.density-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.density-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.density-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.density-btn:hover { color: var(--text); }
.density-btn.active {
  background: rgba(200,168,75,0.16);
  border-color: rgba(200,168,75,0.5);
  color: var(--accent);
}
.density-hint {
  min-width: 64px;
  font-size: var(--font-tiny);
  color: var(--text-faint);
  white-space: nowrap;
}
@media (max-width: 1480px) {
  .density-hint {
    display: none;
  }
}

@media (max-width: 960px) {
  #app-header {
    height: auto;
    padding: 10px 12px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px 12px;
  }

  .logo {
    flex: 1 1 auto;
    min-width: 0;
  }

  .logo span {
    display: none;
  }

  .density-controls {
    margin-left: 0;
    flex-shrink: 0;
  }

  .bookmark-btn {
    margin-left: auto;
  }

  .day-tabs {
    order: 4;
    flex: 1 0 100%;
    width: 100%;
    padding-bottom: 2px;
  }
}

/* BOOKMARK HIGHLIGHT BUTTON */
.bm-highlight-btn {
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--font-ui);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.bm-highlight-btn:hover { border-color: var(--accent); color: var(--accent); }
.bm-highlight-btn.active {
  background: rgba(200,168,75,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* TIMETABLE AREA */
#timetable-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* VENUE LABELS */
#venue-labels {
  width: var(--label-w);
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.venue-label-spacer {
  height: 32px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
#venue-label-scroll {
  flex: 1;
  overflow: hidden;
}
.venue-label {
  height: var(--row-h);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: var(--font-small);
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  gap: 6px;
}
.venue-label .vgroup-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.venue-label:hover { background: var(--surface2); color: var(--text); }

/* GROUP SEPARATOR */
.venue-group-header {
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: var(--font-tiny);
  color: var(--text-faint);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.venue-group-header-timeline {
  height: 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: relative;
}

/* TIMELINE SCROLL AREA */
#timeline-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
}
#timeline-content {
  position: relative;
}

/* MOBILE NOTICE */
.mobile-notice {
  position: fixed;
  left: 50%;
  bottom: 16px;
  width: min(calc(100vw - 24px), 380px);
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  z-index: 260;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.mobile-notice.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.mobile-notice-card {
  padding: 14px 16px 16px;
  border: 1px solid rgba(200,168,75,0.34);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(33,33,38,0.96), rgba(20,20,23,0.98));
  box-shadow: 0 16px 36px rgba(0,0,0,0.42);
  backdrop-filter: blur(10px);
}
.mobile-notice-kicker {
  font-size: var(--font-tiny);
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.mobile-notice-title {
  font-size: calc(var(--font-body) * 1.08);
  line-height: 1.45;
  color: var(--text);
  font-weight: 700;
}
.mobile-notice-copy {
  margin-top: 6px;
  font-size: var(--font-ui);
  line-height: 1.6;
  color: var(--text-dim);
}
.mobile-notice-close {
  margin-top: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(200,168,75,0.28);
  background: rgba(200,168,75,0.08);
  color: var(--accent);
  font-size: var(--font-ui);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.mobile-notice-close:hover {
  border-color: rgba(200,168,75,0.48);
  background: rgba(200,168,75,0.14);
  color: #f2e0a6;
}

/* TIME AXIS */
#time-axis {
  height: 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
}
.time-mark {
  position: absolute;
  bottom: 0;
  font-size: var(--font-tiny);
  color: var(--text-faint);
  transform: translateX(-50%);
  padding-bottom: 4px;
  white-space: nowrap;
  pointer-events: none;
}
.time-mark.full-hour { color: var(--text-dim); }

/* GRID LINES */
#grid-lines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
}
.grid-line-hour {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
  opacity: 0.6;
}
.grid-line-half {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
  opacity: 0.25;
}

/* ROWS */
.row-wrapper {
  position: relative;
  height: var(--row-h);
  border-bottom: 1px solid var(--border);
}
.row-wrapper:hover { background: rgba(255,255,255,0.02); }

/* FILM BLOCKS */
.film-block {
  position: absolute;
  top: 4px;
  height: calc(var(--row-h) - 8px);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: filter 0.1s, transform 0.1s;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border: 1px solid rgba(0,0,0,0.2);
  z-index: 1;
  min-width: 4px;
}
.film-block-link {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 6px;
  color: inherit;
  text-decoration: none;
  z-index: 1;
}
.film-block.has-bookmark-toggle .film-block-link {
  padding-right: 30px;
}
.film-block-link:focus-visible {
  outline: 1px solid rgba(255,255,255,0.9);
  outline-offset: -2px;
}
.film-block.no-detail-action {
  cursor: default;
}
.film-block.no-detail-action:hover {
  filter: brightness(1.08);
  transform: none;
}
.film-block.has-bookmark-toggle {
  padding-right: 30px;
}
.film-block:hover {
  filter: brightness(1.25);
  transform: scaleY(1.05);
  z-index: 100;
}
.film-block.bookmark-hovering:hover {
  filter: none;
  transform: none;
  z-index: 100;
}
.film-title-text {
  font-size: var(--font-small);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
  flex: 1;
}
.film-bookmark-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s, color 0.15s, transform 0.15s, filter 0.15s;
  z-index: 2;
}
.film-bookmark-toggle:hover {
  opacity: 1;
  color: #fff2b3;
  transform: scale(1.08);
  filter: drop-shadow(0 0 5px rgba(255,242,179,0.72));
}
.film-bookmark-toggle.is-active {
  color: #f4d56a;
}
.film-bookmark-toggle.is-active:hover {
  color: #ffe27d;
  filter: drop-shadow(0 0 6px rgba(255,226,125,0.85));
}
.film-bookmark-icon {
  width: 17px;
  height: 17px;
  display: block;
  pointer-events: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.film-bookmark-toggle.is-active .film-bookmark-icon {
  fill: currentColor;
}

/* TOOLTIP */
#tooltip {
  position: fixed;
  background: #1e1e26;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 12px 14px;
  max-width: 280px;
  z-index: 1000;
  pointer-events: none;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#tooltip.visible { display: block; }
.tt-section { font-size: var(--font-tiny); color: var(--accent); font-weight: 700; letter-spacing: 0.05em; margin-bottom: 4px; }
.tt-title { font-size: var(--font-tooltip-title); font-family: 'Nanum Myeongjo', serif; font-weight: 700; color: #fff; margin-bottom: 6px; line-height: 1.3; }
.tt-meta { font-size: var(--font-small); color: var(--text-dim); line-height: 1.8; }
.tt-meta strong { color: var(--text); }
.tt-shorts { font-size: var(--font-tiny); color: var(--text-dim); margin-top: 4px; line-height: 1.6; }
.tt-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.tt-tag { font-size: var(--font-tiny); padding: 2px 6px; border-radius: 10px; background: var(--surface3); color: var(--text-dim); }
.tt-tag.gv { background: rgba(200,168,75,0.2); color: var(--accent); }
.tt-bookmark-hint { font-size: var(--font-tiny); color: var(--text-faint); margin-top: 6px; text-align: right; }

/* DETAIL CHOOSER */
#detail-chooser-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100vw - 32px));
  max-height: min(72vh, 640px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.42);
  z-index: 220;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -48%) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#detail-chooser-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.dc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.dc-heading {
  min-width: 0;
}
.dc-heading h3 {
  font-size: var(--font-tooltip-title);
  font-family: 'Nanum Myeongjo', serif;
  color: var(--text);
  margin-bottom: 4px;
}
.dc-subtitle {
  font-size: var(--font-tiny);
  color: var(--text-dim);
  line-height: 1.6;
}
.dc-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: var(--font-logo);
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}
.dc-close:hover {
  color: var(--text);
  transform: scale(1.05);
}
#detailChooserList {
  padding: 12px 18px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dc-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.dc-item:hover {
  background: var(--surface3);
  border-color: rgba(200,168,75,0.32);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}
.dc-item-title {
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}
.dc-item-meta {
  font-size: var(--font-tiny);
  color: var(--accent);
}

/* BOOKMARKS PANEL */
#bookmarks-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
#bookmarks-panel.open { transform: translateX(0); }
.bp-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.bp-header h3 {
  font-size: var(--font-tooltip-title);
  color: var(--accent);
  font-family: 'Nanum Myeongjo', serif;
  white-space: nowrap;
}
.bp-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.bp-clear,
.bp-download {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: var(--font-tiny);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.bp-download {
  border: 1px solid rgba(200,168,75,0.28);
  background: rgba(200,168,75,0.08);
  color: var(--accent);
}
.bp-download:hover {
  border-color: rgba(200,168,75,0.5);
  background: rgba(200,168,75,0.14);
}
.bp-clear {
  border: 1px solid rgba(224,92,122,0.24);
  background: rgba(224,92,122,0.08);
  color: #f0a9b8;
}
.bp-clear:hover {
  border-color: rgba(224,92,122,0.45);
  background: rgba(224,92,122,0.14);
  color: #ffd0d8;
}
.bp-clear:disabled,
.bp-download:disabled {
  opacity: 0.45;
  cursor: default;
}
.bp-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: var(--font-logo); }
#bookmarks-list { flex: 1; overflow-y: auto; padding: 8px; }
.bm-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.bm-color { width: 4px; border-radius: 2px; flex-shrink: 0; align-self: stretch; }
.bm-info { flex: 1; }
.bm-day-heading { font-size: calc(var(--font-tiny) * 1.2); color: var(--accent); font-weight: 700; padding: 8px 4px 4px; letter-spacing: 0.05em; }
.bm-title { font-size: var(--font-bookmark-title); font-weight: 600; color: var(--text); margin-bottom: 2px; }
.bm-meta {
  font-size: calc(var(--font-tiny) * 1.2);
  color: var(--text-dim);
  line-height: 1.55;
}
.bm-remove { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: var(--font-bookmark-title); flex-shrink: 0; }
.bm-remove:hover { color: #e05; }
.bp-empty { text-align: center; color: var(--text-faint); font-size: var(--font-body); padding: 40px 20px; line-height: 1.8; }

/* LEGEND */
.legend {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.legend-item {
  display: flex; align-items: center; gap: 4px;
  font-size: calc(var(--font-tiny) * 1.1); color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  background: transparent;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}
.legend-item:hover { background: var(--surface3); }
.legend-item.dimmed { opacity: 0.35; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* SCROLLBAR */
#timeline-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
#timeline-scroll::-webkit-scrollbar-track { background: var(--bg); }
#timeline-scroll::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* NOW LINE */
.now-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: rgba(255,80,80,0.7);
  z-index: 5;
  pointer-events: none;
}

/* OVERLAY for panels */
#overlay {
  display: none;
  position: fixed; inset: 0;
  z-index: 150;
  background: rgba(0,0,0,0.4);
}
#overlay.open { display: block; }
