/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary: #1a56db;
  --c-primary-dark: #1e40af;
  --c-green: #059669;
  --c-green-light: #d1fae5;
  --c-red: #dc2626;
  --c-red-light: #fee2e2;
  --c-amber: #d97706;
  --c-amber-light: #fef3c7;
  --c-bg: #f8fafc;
  --c-card: #ffffff;
  --c-text: #1e293b;
  --c-text-muted: #64748b;
  --c-border: #e2e8f0;
  --c-nav-bg: rgba(255,255,255,0.92);
  --max-w: 960px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

html { scroll-behavior: smooth; scroll-padding-top: 64px; }

body {
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }

/* ===== Navbar ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--c-nav-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
  height: 56px;
}
.nav-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; height: 100%;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--c-primary); text-decoration: none; }
.nav-links { display: flex; gap: 4px; list-style: none; }
.nav-links a {
  display: block; padding: 6px 14px; border-radius: 6px;
  color: var(--c-text-muted); text-decoration: none; font-size: 0.9rem;
  transition: color .15s, background .15s;
}
.nav-links a:hover { color: var(--c-primary); background: #eff6ff; }
.nav-links a.active { color: var(--c-primary); background: #dbeafe; font-weight: 600; }

.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--c-text); border-radius: 2px; }

/* ===== Hero ===== */
.hero {
  text-align: center; padding: 72px 24px 56px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 50%, #fefce8 100%);
}
.hero h1 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); font-weight: 800; line-height: 1.35; max-width: 800px; margin: 0 auto 12px; }
.hero-venue { color: var(--c-text-muted); font-size: 1.05rem; margin-bottom: 24px; }
.hero-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.hero-tagline { color: var(--c-text-muted); font-size: 0.95rem; font-style: italic; }
.btn { display: inline-block; padding: 10px 22px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 0.95rem; transition: background .15s, transform .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-outline { border: 2px solid var(--c-primary); color: var(--c-primary); }
.btn-outline:hover { background: var(--c-primary); color: #fff; }

/* ===== Sections ===== */
.section { padding: 64px 0; }
.section-alt { background: var(--c-card); }
.section-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; }
.section-sub { color: var(--c-text-muted); margin-bottom: 32px; font-size: 0.95rem; }

/* ===== Abstract ===== */
.abstract-text { font-size: 1.02rem; line-height: 1.75; color: #334155; }
.abstract-text p { margin-bottom: 16px; }
.abstract-text strong { color: var(--c-text); }

.pipeline-diagram { text-align: center; margin-top: 32px; padding: 32px 0; }
.pipeline-step { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.step-box {
  padding: 16px 24px; border-radius: 10px; background: var(--c-card); border: 2px solid var(--c-border);
  font-weight: 600; font-size: 0.9rem; min-width: 110px; text-align: center;
}
.step-box.step-tts { background: #eff6ff; border-color: var(--c-primary); }
.step-arrow { font-size: 1.5rem; color: var(--c-text-muted); }
.pipeline-loop-label { margin-top: 12px; color: var(--c-text-muted); font-size: 0.9rem; }

/* ===== Results Tables ===== */
.table-tabs { display: flex; gap: 4px; margin-bottom: 24px; flex-wrap: wrap; }
.tab-btn {
  padding: 8px 18px; border: 1px solid var(--c-border); border-radius: 8px;
  background: var(--c-card); cursor: pointer; font-size: 0.9rem; font-family: var(--font);
  transition: all .15s; color: var(--c-text-muted);
}
.tab-btn.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.tab-btn:hover:not(.active) { border-color: var(--c-primary); color: var(--c-primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--c-border); }
.result-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; white-space: nowrap; }
.result-table thead { background: #f1f5f9; }
.result-table th { padding: 10px 14px; text-align: center; font-weight: 600; border-bottom: 2px solid var(--c-border); }
.result-table th:first-child { text-align: left; position: sticky; left: 0; background: #f1f5f9; z-index: 1; }
.result-table .sub-header th { font-weight: 500; font-size: 0.8rem; color: var(--c-text-muted); padding: 6px 14px; }
.result-table td { padding: 10px 14px; text-align: center; border-bottom: 1px solid #f1f5f9; }
.result-table td:first-child { text-align: left; font-weight: 600; position: sticky; left: 0; background: var(--c-card); z-index: 1; }
.result-table tbody tr:hover td { background: #f8fafc; }
.result-table tbody tr:hover td:first-child { background: #f8fafc; }

/* Score coloring — unified rank-based */
.score-1 { background: var(--c-green-light); color: var(--c-green); font-weight: 700; }        /* rank 1 (best) */
.score-2 { background: #ecfdf5; color: var(--c-green); text-decoration: underline; }           /* rank 2 */
.score-low { background: var(--c-red-light); color: var(--c-red); font-weight: 700; }          /* last rank */
.score-low2 { background: #fef2f2; color: var(--c-red); text-decoration: underline; }          /* 2nd-to-last */
.score-na { color: var(--c-text-muted); font-style: italic; }

/* ===== Figures ===== */
.figure-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.fig-card { cursor: pointer; border-radius: 10px; overflow: hidden; border: 1px solid var(--c-border); background: var(--c-card); transition: box-shadow .2s; }
.fig-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.fig-card img { width: 100%; height: auto; display: block; }
.fig-card figcaption { padding: 10px 14px; font-size: 0.85rem; color: var(--c-text-muted); }

.overview-figure {
  margin: 32px auto 0;
  padding: 16px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: var(--c-card);
  text-align: center;
}
.overview-figure img {
  width: 100%; height: auto; display: block;
  max-width: 920px; margin: 0 auto;
  cursor: zoom-in;
  border-radius: 4px;
}
.overview-figure figcaption {
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--c-text-muted);
  line-height: 1.55;
  text-align: left;
  max-width: 860px;
  margin-left: auto; margin-right: auto;
}
.overview-figure figcaption strong { color: var(--c-text); }

/* ===== Demos ===== */
.demo-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.demo-tab {
  padding: 10px 20px; border: 1px solid var(--c-border); border-radius: 8px;
  background: var(--c-card); cursor: pointer; font-size: 0.9rem; font-family: var(--font);
  transition: all .15s; color: var(--c-text-muted);
}
.demo-tab:hover { border-color: var(--c-primary); color: var(--c-primary); }
.demo-tab.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

.demo-utt { display: none; }
.demo-utt.active { display: block; }

.demo-text { margin-bottom: 20px; padding: 12px 16px; background: #f1f5f9; border-radius: 8px; font-size: 0.95rem; color: var(--c-text); }

.audio-grid { display: grid; grid-template-columns: 130px repeat(var(--demo-iter-cols, 3), 1fr); gap: 8px; align-items: center; margin-bottom: 28px; }
.audio-grid-header { font-weight: 700; font-size: 0.85rem; color: var(--c-text-muted); text-align: center; padding: 4px 0; }
.audio-model-label { font-weight: 600; font-size: 0.9rem; }
.audio-model-label.ref { color: var(--c-primary); }

.audio-cell { text-align: center; }
.audio-cell audio { width: 100%; min-width: 160px; height: 36px; }
.audio-cell audio::-webkit-media-controls-panel { background: #f8fafc; }

.play-col-btn {
  display: block; width: 100%; padding: 6px 0; border: none; border-radius: 6px;
  background: #eff6ff; color: var(--c-primary); cursor: pointer; font-size: 0.78rem;
  font-weight: 600; font-family: var(--font); margin-top: 4px; transition: background .15s;
}
.play-col-btn:hover { background: #dbeafe; }

/* ===== Detail Results - Charts ===== */
.detail-tab-content { display: none; }
.detail-tab-content.active { display: block; }

.metric-selector {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.metric-selector .metric-btn {
  padding: 8px 16px; border: 1px solid var(--c-border); border-radius: 8px;
  background: var(--c-card); cursor: pointer; font-size: 0.88rem; font-family: var(--font);
  transition: all .15s; color: var(--c-text-muted);
}
.metric-selector .metric-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.metric-selector .metric-btn.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

.model-toggles {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; align-items: center;
}
.model-toggles .toggle-actions {
  display: flex; gap: 4px; margin-right: 6px;
}
.model-toggles .toggle-action {
  padding: 4px 10px; border: 1px solid var(--c-border); border-radius: 6px;
  background: var(--c-card); cursor: pointer; font-size: 0.78rem; font-family: var(--font);
  color: var(--c-text-muted); transition: all .15s; white-space: nowrap;
}
.model-toggles .toggle-action:hover { border-color: var(--c-primary); color: var(--c-primary); }

.model-toggles .model-chip {
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
  font-size: 0.78rem; font-family: var(--font); font-weight: 500;
  border: 2px solid transparent; transition: all .15s; white-space: nowrap;
  color: #fff; opacity: 0.55;
}
.model-toggles .model-chip.on { opacity: 1; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.model-toggles .model-chip:hover { opacity: 0.85; }
.model-toggles .model-chip.on:hover { opacity: 1; }

.chart-wrap {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 20px;
}
.chart-wrap canvas {
  width: 100% !important;
  height: 420px !important;
}

/* ===== Footer ===== */
.footer { padding: 32px 0; text-align: center; border-top: 1px solid var(--c-border); color: var(--c-text-muted); font-size: 0.85rem; }

/* ===== Lightbox ===== */
.lightbox { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.88); align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox-img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 4px; }
.lightbox-close { position: absolute; top: 20px; right: 30px; color: #fff; font-size: 2rem; cursor: pointer; z-index: 201; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; background: var(--c-nav-bg); border-bottom: 1px solid var(--c-border);
    padding: 8px 24px;
  }
  .nav-links.open { display: flex; }
  .hero { padding: 48px 20px 36px; }
  .hero h1 { font-size: 1.35rem; }
  .section { padding: 40px 0; }
  .figure-grid { grid-template-columns: 1fr; }
  .audio-grid { grid-template-columns: 80px repeat(var(--demo-iter-cols, 3), 1fr); gap: 4px; font-size: 0.8rem; }
  .audio-cell audio { min-width: 90px; }
  .step-box { padding: 12px 14px; min-width: 70px; font-size: 0.78rem; }
  .chart-wrap canvas { height: 300px !important; }
}

@media (max-width: 480px) {
  .audio-grid { grid-template-columns: 1fr; gap: 12px; }
  .audio-grid-header { display: none; }
  .audio-cell audio { min-width: 200px; }
  .hero-buttons { flex-direction: column; align-items: center; }
}
