:root {
  --paper: #efe6d4;
  --paper-deep: #e4d6bc;
  --ink: #1d1914;
  --ink-soft: #5b5348;
  --rule: #c9b89a;
  --seal: #b42318;
  --seal-soft: #d4533a;
  --moss: #2f4a3c;
  --panel: rgba(255, 251, 243, 0.78);
  --shadow: 0 18px 50px rgba(58, 39, 16, 0.12);
  --mono: "IBM Plex Mono", "Source Code Pro", "SFMono-Regular", Consolas, monospace;
  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "SimSun", "Times New Roman", serif;
  --sans: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(180, 35, 24, 0.08), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(47, 74, 60, 0.08), transparent 46%),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(91, 83, 72, 0.05) 32px),
    var(--paper);
  font-family: var(--sans);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
  opacity: 0.08;
  mix-blend-mode: multiply;
}

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

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 18px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  width: 52px;
  height: 52px;
  border: 2px solid var(--seal);
  color: var(--seal);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.12em;
  transform: rotate(-8deg);
  background: rgba(180, 35, 24, 0.06);
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.brand p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  border: 1px solid var(--rule);
  background: var(--panel);
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.pill.ok { border-color: #6d8a74; color: var(--moss); }
.pill.warn { border-color: var(--seal-soft); color: var(--seal); }

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(91, 83, 72, 0.18);
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(8px);
}

.panel h2 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.14em;
}

.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 16px 12px;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  letter-spacing: 0.08em;
}

.tab.active {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--seal);
}

.record-stage {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 18px 0 8px;
}

.reel {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  border: 8px solid #2a241c;
  background:
    radial-gradient(circle at 50% 50%, #f3ead6 0 18px, transparent 19px),
    repeating-conic-gradient(from 0deg, #3c3328 0 8deg, #201c16 8deg 16deg);
  box-shadow: inset 0 0 0 18px #c4a574, 0 10px 24px rgba(0, 0, 0, 0.18);
  position: relative;
}

.reel.spinning {
  animation: spin 1.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.timer {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.08em;
}

.hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.actions, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button, .file-btn {
  appearance: none;
  border: 1px solid #2a241c;
  background: #2a241c;
  color: #f7f0e3;
  padding: 10px 16px;
  font: inherit;
  letter-spacing: 0.08em;
  cursor: pointer;
}

button.ghost, .file-btn {
  background: transparent;
  color: var(--ink);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.danger {
  background: var(--seal);
  border-color: var(--seal);
}

.file-btn input {
  display: none;
}

.file-name {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.progress-box {
  margin-top: 16px;
  min-height: 52px;
  border: 1px dashed var(--rule);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
}

.progress-box.busy {
  border-style: solid;
  background: rgba(255, 251, 243, 0.9);
}

.transcript, .story, .thinking {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--rule);
  background: #fffdf8;
  color: var(--ink);
  padding: 14px;
  font: inherit;
  line-height: 1.8;
  resize: vertical;
}

.thinking {
  min-height: 140px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-soft);
  background:
    repeating-linear-gradient(0deg, transparent, transparent 21px, rgba(91, 83, 72, 0.06) 22px),
    #f7f1e4;
  white-space: pre-wrap;
}

.story {
  min-height: 280px;
  font-family: var(--serif);
  font-size: 16px;
  white-space: pre-wrap;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  font-weight: 600;
}

.muted { color: var(--ink-soft); font-size: 12px; }

.footnote {
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.8;
}

.footnote code {
  font-family: var(--mono);
  background: rgba(42, 36, 28, 0.06);
  padding: 1px 5px;
}

.error {
  color: var(--seal);
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .masthead { flex-direction: column; align-items: flex-start; }
  .status-pills { justify-content: flex-start; }
  .brand h1 { font-size: 28px; }
}
