/* ═══════════════════════════════════════
   극장 — KR Market Sonification
   Dark theater theme
   ═══════════════════════════════════════ */

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

body {
  font-family: -apple-system, 'Pretendard', sans-serif;
  background: #080808;
  color: #ccc;
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 52px);
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid #1a1a1a;
  background: #0a0a0a;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.market-badges { display: flex; gap: 6px; }

.idx-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: #1a1a1a;
  color: #888;
  font-variant-numeric: tabular-nums;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sentiment-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sentiment-badge.euphoria  { background: #0f2918; color: #2ecc71; }
.sentiment-badge.bullish   { background: #0e2515; color: #27ae60; }
.sentiment-badge.mildBull  { background: #0d2012; color: #1e8449; }
.sentiment-badge.neutral   { background: #1a1a1a; color: #888; }
.sentiment-badge.mildBear  { background: #200d0d; color: #a93226; }
.sentiment-badge.bearish   { background: #250e0e; color: #c0392b; }
.sentiment-badge.panic     { background: #2a0c0c; color: #e74c3c; animation: pulse-panic 0.6s infinite alternate; }

@keyframes pulse-panic {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

.score-text {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.clock-text {
  font-size: 12px;
  color: #555;
  font-variant-numeric: tabular-nums;
}

/* ── Main Grid ── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.col-left {
  padding: 16px;
  overflow: auto;
}

.col-right {
  border-left: 1px solid #1a1a1a;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Panels ── */
.panel {
  background: #0e0e0e;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  padding: 12px;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* ── Gauge ── */
.gauge-bar-wrap {
  height: 8px;
  background: #1a1a1a;
  border-radius: 4px;
  overflow: hidden;
}

.gauge-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #c0392b, #333, #27ae60);
  transition: width 1s ease;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #444;
  margin-top: 4px;
}

/* ── Score Grid ── */
.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  background: #141414;
}

.score-label { font-size: 11px; color: #666; }
.score-val { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-item.up .score-val { color: #2ecc71; }
.score-item.down .score-val { color: #e74c3c; }
.score-item.flat .score-val { color: #888; }
.score-item.total .score-val { color: #ccc; }

/* ── Movers ── */
.movers-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 200px;
  overflow-y: auto;
}

.mover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: #111;
}

.mover-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aaa;
  max-width: 140px;
}

.mover-rate {
  font-weight: 700;
  min-width: 60px;
  text-align: right;
}

.mover-rate.up { color: #2ecc71; }
.mover-rate.down { color: #e74c3c; }

.mover-market {
  font-size: 10px;
  color: #555;
  min-width: 36px;
  text-align: right;
}

/* ── Music Info ── */
.music-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.music-label { font-size: 11px; color: #555; }
.music-val { font-size: 12px; font-weight: 600; color: #aaa; }

.bgm-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.bgm-skip-btn {
  background: none;
  border: 1px solid #333;
  color: #888;
  font-size: 14px;
  width: 32px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  padding: 0;
  flex-shrink: 0;
}
.bgm-skip-btn:hover {
  border-color: #555;
  color: #ccc;
}

.vol-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #222;
  border-radius: 2px;
  outline: none;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #666;
  cursor: pointer;
}

/* ── Curtain Art ── */
.curtain-panel {
  text-align: center;
  padding: 8px;
}

.curtain-art {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.3;
  color: #444;
  white-space: pre;
  transition: color 0.5s;
}

.curtain-art.euphoria, .curtain-art.bullish { color: #2ecc71; }
.curtain-art.mildBull { color: #1e8449; }
.curtain-art.mildBear { color: #a93226; }
.curtain-art.bearish { color: #c0392b; }
.curtain-art.panic { color: #e74c3c; animation: pulse-panic 0.4s infinite alternate; }

/* ── Filter Bar (Accordion) ── */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-card {
  border: 1px solid #1a1a1a;
  border-radius: 10px;
  background: #0c0c0c;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.filter-card.open {
  background: #0a0a12;
  border-color: rgba(100, 100, 170, 0.2);
  box-shadow: 0 2px 20px rgba(80, 80, 150, 0.06);
}

/* ── Card Header (clickable) ── */
.fc-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 72px;
}
.fc-header:hover { background: rgba(255,255,255,0.015); }

.fc-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.fc-info {
  flex: 1;
  min-width: 0;
}
.fc-title {
  font-size: 16px;
  font-weight: 700;
  color: #555;
  line-height: 1.2;
}
.filter-card.open .fc-title { color: #e0e0e0; }
.fc-header:hover .fc-title { color: #888; }

.fc-sub {
  font-size: 10px;
  font-weight: 500;
  color: #333;
  letter-spacing: 0.8px;
  margin-left: 8px;
}
.filter-card.open .fc-sub { color: #555; }

.fc-desc {
  font-size: 11px;
  color: #383838;
  margin-top: 3px;
  line-height: 1.4;
}
.filter-card.open .fc-desc { color: #666; }

.fc-etf {
  font-size: 10px;
  color: #2a2a3a;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}
.filter-card.open .fc-etf { color: #556; }

.fc-stats {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
  align-items: center;
}
.fc-stat {
  text-align: right;
  line-height: 1.2;
}
.fc-stat-label {
  font-size: 9px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.fc-stat-val {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #666;
}
.filter-card.open .fc-stat-label { color: #666; }
.filter-card.open .fc-stat-val { color: #aaa; }
.fc-stat-val.up { color: #2ecc71 !important; }
.fc-stat-val.down { color: #e74c3c !important; }

.fc-chevron {
  font-size: 14px;
  color: #333;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.filter-card.open .fc-chevron {
  transform: rotate(180deg);
  color: #666;
}

/* ── Card Body (expandable heatmap) ── */
.fc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.filter-card.open .fc-body {
  max-height: 3000px;
}
.fc-body-inner {
  padding: 0 16px 16px;
}

/* ── Heatmap ── */
.heatmap-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 14px;
  padding: 40px 0;
}

.heatmap-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #555;
  padding: 10px 0 6px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.heatmap-grid {
  display: grid;
  gap: 3px;
}

.heatmap-grid.kospi {
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
}
.heatmap-grid.kosdaq {
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
}

.hm-cell {
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  cursor: default;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.hm-cell:hover {
  transform: scale(1.06);
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.hm-cell .hm-name {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  max-width: 100%;
}

.hm-cell .hm-rate {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  font-variant-numeric: tabular-nums;
}

/* Size tiers */
.hm-cell.tier-lg { min-height: 56px; padding: 8px 6px; }
.hm-cell.tier-lg .hm-name { font-size: 11px; }
.hm-cell.tier-lg .hm-rate { font-size: 13px; }
.hm-cell.tier-md { min-height: 42px; }
.hm-cell.tier-sm { min-height: 32px; }
.hm-cell.tier-sm .hm-name { font-size: 9px; }
.hm-cell.tier-sm .hm-rate { font-size: 10px; }

/* ── Closed Banner ── */
/* ── Market Phase Banners ── */
.market-banner {
  text-align: center;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  border-top: 1px solid #1a1a1a;
}
.phase-closed {
  background: #0e0e0e;
  color: #555;
}
.phase-premarket {
  background: linear-gradient(90deg, #0e0e0e, #1a1510, #0e0e0e);
  color: #b8a070;
  animation: pulse-soft 3s ease-in-out infinite;
}
.phase-auction {
  background: linear-gradient(90deg, #0e0e0e, #1a1515, #0e0e0e);
  color: #d4a050;
  animation: pulse-warm 1.5s ease-in-out infinite;
}
.phase-closing {
  background: linear-gradient(90deg, #0e0e0e, #1a1012, #0e0e0e);
  color: #e07050;
  animation: pulse-warm 1s ease-in-out infinite;
}
.phase-afterhours {
  background: linear-gradient(90deg, #0e0e0e, #10101a, #0e0e0e);
  color: #7888a8;
}
@keyframes pulse-soft {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
@keyframes pulse-warm {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* Phase-specific curtain art colors */
.curtain-art.phase-premarket { color: #806840; }
.curtain-art.phase-auction { color: #c49040; }
.curtain-art.phase-closing { color: #d06040; }
.curtain-art.phase-afterhours { color: #607090; }

/* ── Mobile — 7:3 two-column like Charlassic ── */
@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr 120px;
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
  }

  .col-left { padding: 6px; }

  .col-right {
    padding: 6px 5px;
    gap: 6px;
    overflow-x: hidden;
  }

  .app-header { padding: 6px 10px; flex-wrap: wrap; gap: 4px; }
  .logo { font-size: 14px; }
  .market-badges { gap: 3px; }
  .idx-badge { font-size: 9px; padding: 2px 5px; }
  .sentiment-badge { font-size: 10px; padding: 3px 6px; }
  .score-text { font-size: 14px; }
  .clock-text { font-size: 10px; }

  .panel { padding: 8px 7px; border-radius: 6px; min-width: 0; overflow: hidden; }
  .panel-title { font-size: 10px; margin-bottom: 6px; letter-spacing: 0.5px; }

  /* Gauge */
  .gauge-bar-wrap { height: 7px; }
  .gauge-labels { font-size: 9px; margin-top: 4px; }

  /* Score grid */
  .score-grid { gap: 4px; }
  .score-item { padding: 5px 6px; border-radius: 4px; }
  .score-label { font-size: 10px; }
  .score-val { font-size: 13px; }

  /* Movers */
  .movers-list { max-height: 160px; gap: 3px; }
  .mover-row { padding: 4px 5px; font-size: 11px; }
  .mover-name { font-size: 11px; max-width: 64px; }
  .mover-rate { font-size: 11px; min-width: 48px; }
  .mover-market { display: none; }

  /* Music panel */
  .music-row { padding: 3px 0; }
  .music-label { font-size: 10px; }
  .music-val { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
  .bgm-controls { gap: 4px; margin-top: 5px; }
  .bgm-skip-btn { width: 26px; height: 22px; font-size: 11px; flex-shrink: 0; }
  .vol-slider { height: 3px; min-width: 0; }

  /* Curtain */
  .curtain-panel { padding: 6px; }
  .curtain-art { font-size: 7px; line-height: 1.2; }

  /* Heatmap accordion compact */
  .filter-bar { gap: 3px; }
  .fc-header { padding: 6px 8px; min-height: 40px; gap: 6px; }
  .fc-icon { font-size: 16px; width: 22px; }
  .fc-title { font-size: 12px; }
  .fc-sub { font-size: 8px; margin-left: 4px; }
  .fc-desc { display: none; }
  .fc-etf { display: none; }
  .fc-stats { gap: 6px; }
  .fc-stat-val { font-size: 11px; }
  .fc-stat-label { font-size: 8px; }
  .fc-body-inner { padding: 0 6px 8px; }

  .heatmap-grid.kospi { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .heatmap-grid.kosdaq { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
  .hm-cell .hm-name { font-size: 8px; }
  .hm-cell .hm-rate { font-size: 9px; }
  .hm-cell.tier-lg { min-height: 38px; padding: 4px 3px; }
  .hm-cell.tier-lg .hm-name { font-size: 9px; }
  .hm-cell.tier-lg .hm-rate { font-size: 10px; }
  .hm-cell.tier-md { min-height: 30px; }
  .hm-cell.tier-sm { min-height: 24px; }

  /* Market banner compact */
  .market-banner { padding: 6px 8px; font-size: 11px; }
}
