:root {
  --ink: #12151c;
  --muted: #667085;
  --line: #d9dee8;
  --surface: #ffffff;
  --soft: #f5f7fb;
  --accent: #0f8f7f;
  --accent-strong: #0a6d62;
  --warning: #a15c00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(18, 21, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 143, 127, 0.12), transparent 35%),
    linear-gradient(315deg, rgba(183, 83, 35, 0.12), transparent 32%),
    #eef2f7;
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 25px;
}

.status-pill {
  min-width: 132px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(18, 21, 28, 0.08);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.api-host {
  width: min(260px, 38vw);
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.api-host input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
}

.drive-connect {
  align-self: end;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #192b4a;
  color: white;
  cursor: pointer;
  font-weight: 900;
}

.drive-connect:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status-pill.ready {
  border-color: rgba(15, 143, 127, 0.35);
  color: var(--accent-strong);
}

.status-pill.missing {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.tab,
.primary,
.ghost {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  border: 1px solid transparent;
}

.tab span {
  color: #9aa4b2;
  font-size: 12px;
  font-weight: 900;
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(18, 21, 28, 0.08);
}

.workspace {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(217, 222, 232, 0.8);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  display: none;
  padding: 20px;
}

.panel.is-active {
  display: block;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(350px, 450px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.control-stack {
  display: grid;
  gap: 15px;
}

.section-head p {
  color: var(--muted);
  line-height: 1.55;
}

label {
  display: grid;
  gap: 8px;
  color: #303744;
  font-size: 15px;
  font-weight: 800;
}

label span {
  color: var(--muted);
  font-weight: 700;
}

textarea,
select,
input[type="text"],
input[type="url"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

select {
  min-height: 44px;
  padding: 0 12px;
}

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

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 20px rgba(15, 143, 127, 0.22);
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled {
  cursor: progress;
  opacity: 0.7;
}

.secondary {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #192b4a;
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.ghost {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.clue-source-box,
.image-clue-box,
.transcription-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.box-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.box-title h3 {
  margin: 0;
  font-size: 17px;
}

.box-title span {
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(15, 143, 127, 0.1);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

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

.clue-grid label {
  font-size: 13px;
}

.clue-grid input {
  width: 100%;
  min-height: 42px;
  padding: 0 9px;
}

.file-input {
  min-height: 46px;
  padding: 10px;
  border: 1px dashed #aeb8c9;
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 14px;
}

.file-note {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.drive-note.ready {
  color: var(--accent-strong);
  font-weight: 800;
}

.drive-note.missing {
  color: #b42318;
  font-weight: 800;
}

.transcript-text {
  min-height: 108px;
  background: white;
  font-size: 14px;
}

.result-surface,
.news-output,
.animation-wrap {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.result-surface {
  display: grid;
  place-items: center;
  overflow: hidden;
}

.checkerboard {
  background-image:
    linear-gradient(45deg, #e8edf5 25%, transparent 25%),
    linear-gradient(-45deg, #e8edf5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8edf5 75%),
    linear-gradient(-45deg, transparent 75%, #e8edf5 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.result-surface img {
  display: block;
  max-width: 100%;
  max-height: 460px;
  object-fit: contain;
}

.empty-state {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.animation-wrap {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 320px;
  border-radius: 8px;
  background: #111827;
  color: white;
  isolation: isolate;
}

.ratio-16-9 {
  aspect-ratio: 16 / 9;
}

.ratio-9-16 {
  aspect-ratio: 9 / 16;
  max-height: 580px;
  margin: 0 auto;
}

.ratio-1-1 {
  aspect-ratio: 1 / 1;
  max-height: 560px;
  margin: 0 auto;
}

.stage-bg,
.stage-subject,
.stage-title,
.stage-caption {
  position: absolute;
}

.stage-bg {
  inset: -18%;
  background:
    radial-gradient(circle at 22% 28%, rgba(246, 188, 82, 0.7), transparent 23%),
    radial-gradient(circle at 82% 18%, rgba(15, 143, 127, 0.8), transparent 24%),
    linear-gradient(130deg, #172033, #3d1f2d 48%, #0d4f4a);
}

.stage-subject {
  left: 10%;
  bottom: 18%;
  display: grid;
  place-items: center;
  width: min(34%, 260px);
  aspect-ratio: 1;
  border: 4px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 56px;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.stage-title {
  right: 8%;
  top: 20%;
  max-width: 54%;
  font-size: clamp(28px, 5vw, 62px);
  line-height: 1.05;
  font-weight: 900;
}

.stage-caption {
  right: 7%;
  bottom: 10%;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  font-weight: 900;
}

.stage.playing .stage-bg {
  animation: bgDrift 6s ease-in-out both;
}

.stage.playing .stage-subject {
  animation: subjectMove 6s cubic-bezier(0.2, 0.7, 0.1, 1) both;
}

.stage.playing .stage-title {
  animation: titleReveal 6s ease both;
}

.stage.playing .stage-caption {
  animation: captionPulse 1s steps(2, end) 6;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.spec-box {
  min-height: 110px;
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
}

.news-output {
  padding: 24px;
  overflow: auto;
  line-height: 1.8;
}

.output-stack {
  display: grid;
  gap: 14px;
}

.output-stack .news-output {
  min-height: 220px;
}

.output-label {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(15, 143, 127, 0.1);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.news-output h3 {
  margin: 0 0 14px;
  font-size: 28px;
  line-height: 1.2;
}

.news-output .meta {
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 800;
}

.news-output p {
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 5;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #151922;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes bgDrift {
  from {
    transform: scale(1) translateX(-2%);
    filter: saturate(0.9);
  }
  to {
    transform: scale(1.12) translateX(3%);
    filter: saturate(1.35);
  }
}

@keyframes subjectMove {
  0% {
    transform: translateX(-18%) scale(0.82);
    opacity: 0;
  }
  18%,
  80% {
    opacity: 1;
  }
  100% {
    transform: translateX(18%) scale(1.05);
    opacity: 1;
  }
}

@keyframes titleReveal {
  0%,
  22% {
    transform: translateY(24px);
    opacity: 0;
  }
  42%,
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes captionPulse {
  50% {
    background: rgba(15, 143, 127, 0.86);
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(480px, 100%);
    padding: 0;
  }

  .topbar {
    position: static;
    display: grid;
    align-items: start;
    padding: 16px;
    background: rgba(238, 242, 247, 0.94);
    margin-bottom: 0;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .api-host {
    width: 100%;
  }

  h1 {
    font-size: 36px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 3;
    grid-template-columns: 1fr;
    padding: 10px 12px;
    background: rgba(238, 242, 247, 0.94);
    backdrop-filter: blur(14px);
  }

  .workspace {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .panel {
    padding: 16px;
  }

  .tool-grid,
  .row,
  .clue-grid {
    grid-template-columns: 1fr;
  }

  .result-surface,
  .news-output,
  .animation-wrap {
    min-height: 320px;
  }

  .stage {
    min-height: 260px;
  }

  .stage-title {
    right: 6%;
    max-width: 62%;
  }
}
