:root {
  color-scheme: light;
  --bg: #f4efe6;
  --paper: rgba(255, 252, 247, 0.92);
  --paper-strong: #fffaf1;
  --ink: #1f1a17;
  --muted: #6b625c;
  --line: rgba(80, 62, 42, 0.12);
  --accent: #1f7a5c;
  --accent-strong: #145642;
  --accent-soft: rgba(31, 122, 92, 0.14);
  --accent-warm: #c46d2d;
  --shadow: 0 20px 60px rgba(47, 34, 18, 0.12);
  --radius: 24px;
  --radius-sm: 16px;
  --font-ui: "IBM Plex Sans", "Noto Sans TC", sans-serif;
  --font-display: "Fraunces", "Noto Serif TC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(196, 109, 45, 0.16), transparent 32%),
    radial-gradient(circle at top right, rgba(31, 122, 92, 0.18), transparent 28%),
    linear-gradient(180deg, #f7f0e5 0%, #efe7db 100%);
  color: var(--ink);
  font-family: var(--font-ui);
}

code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero {
  padding: 24px 8px 20px;
}

.eyebrow,
.panel-kicker,
.status-label {
  margin: 0 0 8px;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.hero h1,
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 0.95;
  font-weight: 700;
}

.hero h1 {
  font-size: clamp(2.8rem, 8vw, 5.6rem);
  max-width: 8ch;
}

.hero-copy {
  max-width: 760px;
  margin: 20px 0 0;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--muted);
}

.uploader-panel,
.guide-panel,
.panel,
.summary-card {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.uploader-panel {
  padding: 22px;
  border-radius: 28px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  border-radius: 24px;
  border: 2px dashed rgba(31, 122, 92, 0.32);
  background:
    linear-gradient(135deg, rgba(31, 122, 92, 0.08), rgba(196, 109, 45, 0.08)),
    var(--paper-strong);
  text-align: center;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.dropzone.dragover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(31, 122, 92, 0.16), rgba(196, 109, 45, 0.12)),
    var(--paper-strong);
}

.dropzone input {
  display: none;
}

.dropzone-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

.dropzone-hint {
  margin-top: 14px;
  max-width: 560px;
  line-height: 1.7;
  color: var(--muted);
}

.uploader-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.demo-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-warm) 100%);
  color: #fffdf9;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(31, 122, 92, 0.22);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.demo-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(31, 122, 92, 0.26);
}

.demo-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.uploader-action-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  text-align: right;
}

.status-row {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 360px);
  gap: 24px;
  align-items: end;
  margin-top: 18px;
}

.status-value,
.progress-text,
.summary-meta,
.table-muted,
.panel-note {
  color: var(--muted);
}

.status-value,
.progress-text {
  margin: 0;
}

.progress-track {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.12);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-warm) 100%);
  transition: width 160ms ease;
}

.file-meta {
  margin-top: 14px;
  min-height: 24px;
  color: var(--muted);
}

.hidden {
  display: none;
}

.dashboard {
  margin-top: 26px;
}

.guide-panel {
  margin-top: 18px;
  padding: 24px;
  border-radius: 28px;
}

.guide-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}

.guide-actions {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.guide-head h2,
.guide-card h3 {
  margin: 0;
  font-family: var(--font-display);
}

.guide-copy {
  max-width: 420px;
  margin: 0;
  line-height: 1.7;
  color: var(--muted);
  text-align: right;
}

.guide-toggle {
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.guide-toggle:hover,
.guide-toggle[aria-expanded="true"] {
  transform: translateY(-1px);
  background: rgba(31, 122, 92, 0.2);
}

.guide-content {
  margin-top: 18px;
}

.guide-panel.is-collapsed {
  padding-bottom: 20px;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.guide-card {
  display: grid;
  gap: 16px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.guide-step {
  margin: 0 0 8px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.guide-card h3 {
  font-size: 1.6rem;
  line-height: 1.05;
}

.guide-card p:last-child {
  margin-bottom: 0;
  line-height: 1.8;
  color: var(--muted);
}

.guide-figure {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 16px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(80, 62, 42, 0.08);
  background: rgba(14, 19, 27, 0.06);
}

.guide-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: clamp(260px, 34vw, 360px);
  object-fit: contain;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.summary-card {
  padding: 18px;
  border-radius: 18px;
}

.summary-label,
.summary-value,
.summary-meta {
  margin: 0;
}

.summary-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.summary-value {
  margin-top: 10px;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 700;
}

.summary-meta {
  margin-top: 8px;
  line-height: 1.5;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.insights-panel {
  margin-top: 16px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.insight-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.insight-label,
.insight-value,
.insight-meta {
  margin: 0;
}

.insight-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.insight-value {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.2vw, 1.85rem);
  line-height: 1.05;
}

.insight-meta {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.insight-rows {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(80, 62, 42, 0.08);
}

.insight-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.insight-row-label {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.insight-row-value {
  font-size: 0.98rem;
  white-space: nowrap;
}

.panel {
  padding: 20px;
  border-radius: var(--radius);
}

.panel.wide {
  grid-column: span 2;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-note {
  max-width: 260px;
  line-height: 1.5;
  text-align: right;
}

.panel-note-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
}

.info-button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
  transform: translateY(-1px);
  background: rgba(31, 122, 92, 0.2);
}

.info-popover {
  margin: -4px 0 16px auto;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(80, 62, 42, 0.1);
  color: var(--muted);
  line-height: 1.7;
}

.chart {
  min-height: 280px;
}

.timeline-controls {
  margin: -4px 0 16px;
}

.timeline-controls-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.timeline-range-label,
.timeline-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.timeline-reset {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(80, 62, 42, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
}

.timeline-reset {
  padding: 0 16px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.timeline-reset:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(31, 122, 92, 0.08);
}

.timeline-reset:disabled {
  opacity: 0.55;
  cursor: default;
}

.svg-chart {
  width: 100%;
  height: auto;
  display: block;
}

.axis-text,
.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: var(--font-ui);
}

.chart-title {
  fill: var(--ink);
  font-size: 13px;
  font-family: var(--font-ui);
}

.daily-brush-chart {
  cursor: crosshair;
}

.brush-selection {
  fill: rgba(31, 122, 92, 0.18);
  stroke: rgba(31, 122, 92, 0.6);
  stroke-width: 1;
  pointer-events: none;
}

.reply-breakdown {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.reply-breakdown-head {
  color: var(--muted);
  font-size: 0.9rem;
}

.reply-breakdown-row {
  display: grid;
  grid-template-columns: minmax(84px, 112px) minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
}

.reply-breakdown-meta strong,
.reply-breakdown-meta span,
.reply-breakdown-share {
  display: block;
}

.reply-breakdown-meta span,
.reply-breakdown-share {
  color: var(--muted);
  font-size: 0.88rem;
}

.reply-breakdown-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(196, 109, 45, 0.12);
}

.reply-breakdown-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c46d2d 0%, #e09e62 100%);
}

.reply-side-note {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.reply-side-note-label {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reply-side-note-value {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1;
}

.reply-side-note-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.table-block {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.table-row.header {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

.table-row.table-row-wide {
  grid-template-columns: minmax(120px, 1.1fr) repeat(4, minmax(0, 1fr));
}

.table-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.table-cell strong {
  display: block;
  font-size: 1rem;
}

.mini-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.1);
  margin-top: 6px;
}

.mini-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-warm) 100%);
}

.terms-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.phrases-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.phrase-person {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.phrase-person-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.phrase-person-head h3,
.phrase-person-head p,
.phrase-label {
  margin: 0;
}

.phrase-person-head h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.phrase-person-head p,
.phrase-label {
  color: var(--muted);
}

.phrase-group + .phrase-group {
  margin-top: 16px;
}

.phrase-label {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.phrase-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.message-mix-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.calls-panel {
  display: grid;
  gap: 16px;
}

.signals-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.call-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.call-summary-card,
.call-block {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.call-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.call-list {
  display: grid;
  gap: 12px;
}

.call-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
}

.call-row-meta strong,
.call-row-meta span,
.call-row-share {
  display: block;
}

.call-row-meta span,
.call-row-share {
  color: var(--muted);
  font-size: 0.9rem;
}

.call-row-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.1);
}

.call-row-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-warm) 100%);
}

.call-row-bar.warm {
  background: rgba(196, 109, 45, 0.12);
}

.call-row-bar.warm > span {
  background: linear-gradient(90deg, #c46d2d 0%, #e09e62 100%);
}

.mix-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(80, 62, 42, 0.08);
}

.mix-list {
  display: grid;
  gap: 12px;
}

.mix-row {
  display: grid;
  grid-template-columns: minmax(90px, 120px) minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
}

.mix-meta strong,
.mix-meta span,
.mix-share {
  display: block;
}

.mix-meta span,
.mix-share {
  color: var(--muted);
  font-size: 0.9rem;
}

.mix-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.1);
}

.mix-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-warm) 100%);
}

.term-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.08);
  border: 1px solid rgba(31, 122, 92, 0.14);
}

.phrase-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(31, 122, 92, 0.08);
  border: 1px solid rgba(31, 122, 92, 0.14);
}

.phrase-chip.warm {
  background: rgba(196, 109, 45, 0.1);
  border-color: rgba(196, 109, 45, 0.2);
}

.term-chip strong {
  margin-right: 8px;
}

.phrase-chip strong {
  margin-left: 8px;
}

.empty-state {
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
}

.has-tooltip {
  cursor: pointer;
}

.tooltip {
  position: fixed;
  z-index: 1000;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 26, 23, 0.94);
  color: #fffaf1;
  box-shadow: 0 18px 40px rgba(22, 16, 10, 0.28);
  font-size: 0.92rem;
  line-height: 1.5;
  pointer-events: none;
  white-space: pre-line;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .insights-grid,
  .guide-steps,
  .chart-grid,
  .phrases-panel,
  .message-mix-panel,
  .signals-panel,
  .call-grid,
  .call-summary-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .status-row,
  .guide-head,
  .panel-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .guide-actions {
    justify-items: start;
  }

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

  .guide-copy,
  .uploader-action-hint,
  .panel-note {
    text-align: left;
    max-width: none;
  }

  .panel-note-row {
    justify-content: flex-start;
  }

  .info-popover {
    margin-left: 0;
    max-width: none;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-row {
    grid-template-columns: 1fr 1fr;
  }

  .table-row.table-row-wide {
    grid-template-columns: 1fr 1fr;
  }

  .guide-figure img {
    max-height: 280px;
  }
}

@media (max-width: 560px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .table-row {
    grid-template-columns: 1fr;
  }

  .table-row.table-row-wide {
    grid-template-columns: 1fr;
  }
}
