/* TOOL02｜Dino Transcript Studio
 * Shares the editorial grid, paper tones, and typography of Dino Voice Studio (TOOL01) & dinohappy.com.
 */
:root {
  --ink: #252420;
  --gold: #94773f;
  --gold-soft: #f5efe2;
  --line: #dedbd4;
  --muted: #6f6b63;
  --panel: #f7f6f2;
  --surface: #ffffff;
  --danger: #862f34;
  --danger-bg: #fdf2f2;
  --ok: #266047;
  --ok-bg: #eef7f2;
  --warn: #7d5514;
  --warn-bg: #fbf5e7;
  --display: Georgia, "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Inter", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
  background: var(--panel);
  font: 16px/1.55 var(--sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Header matching TOOL01 */
.masthead {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(14px, 3vw, 28px);
  max-width: 60rem;
  width: 100%;
  margin-inline: auto;
}

.masthead .brand-logo {
  display: block;
  object-fit: contain;
  width: 44px;
  height: 44px;
  flex: none;
}

.masthead-title {
  min-width: 0;
  margin-right: auto;
}

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.15rem, 2.8vw, 1.75rem);
  letter-spacing: 0.015em;
  line-height: 1.2;
}

.masthead p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.wide-help {
  position: relative;
  font-size: 0.85rem;
}

.wide-help summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 600;
  min-height: 40px;
  display: flex;
  align-items: center;
  list-style: none;
}

.wide-help[open] {
  position: relative;
}

.wide-help p {
  margin: 6px 0;
  max-width: 20rem;
  color: var(--muted);
}

/* Workspace Tabs matching TOOL01 */
.workspace-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
  background: var(--panel);
  max-width: 60rem;
  width: 100%;
  margin: 0 auto 14px;
}

.workspace-nav button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  min-height: 46px;
  padding: 8px 6px;
  font: 600 0.92rem/1.2 var(--sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.workspace-nav button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 -2px var(--gold);
}

.badge {
  font-size: 0.75rem;
  background: var(--gold-soft);
  color: #6b5221;
  padding: 1px 6px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}

main {
  width: min(100%, 60rem);
  margin-inline: auto;
  padding-inline: clamp(10px, 2.5vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.view-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: clamp(14px, 2.5vw, 22px);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.section-head h2, .section-head h3 {
  margin: 0;
  font-family: var(--display);
  letter-spacing: 0.04em;
}

.section-head h2 { font-size: 1.15rem; }
.section-head h3 { font-size: 1rem; }

.tag {
  font-size: 0.78rem;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}

.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: #b7dec9; }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: #e6d1a5; }
.tag.err { background: var(--danger-bg); color: var(--danger); border-color: #e6b8bc; }

.hint {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.caption {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Privacy Banner */
.privacy-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #c9decb;
  border-left: 3px solid var(--ok);
  background: var(--ok-bg);
  font-size: 0.88rem;
}

.privacy-banner[data-mode="cloud"] {
  border-color: #e6d1a5;
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

.privacy-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  margin-top: 6px;
  flex: none;
}

.privacy-banner[data-mode="cloud"] .privacy-dot {
  background: var(--warn);
}

.privacy-banner strong { display: block; font-size: 0.92rem; }
.privacy-banner p { margin: 2px 0 0; color: var(--muted); }

/* Dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 24px 16px;
  border: 1.5px dashed #b9b1a3;
  background: var(--panel);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone-cta {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
}

.dropzone-sub {
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
}

/* Form Controls */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
}

select, input[type="text"], input[type="url"], input[type="password"], textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  min-height: 44px;
  padding: 8px 10px;
  font: 0.94rem/1.4 var(--sans);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.sub-panel {
  border: 1px solid #e6d1a5;
  background: #fcfaf4;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.sub-panel h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 0.98rem;
  color: var(--warn);
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
  cursor: pointer;
}

.consent-row.compact {
  margin-bottom: 10px;
}

.consent-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--gold);
  flex: none;
}

/* Callouts */
.callout {
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  border: 1px solid var(--line);
}

.callout-warn {
  background: var(--warn-bg);
  border-color: #e6d1a5;
  color: var(--warn);
}

.callout-error {
  background: var(--danger-bg);
  border-color: #e6b8bc;
  color: var(--danger);
}

/* Buttons matching TOOL01 */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button.primary, button.secondary {
  min-height: 44px;
  padding: 8px 16px;
  font: 600 0.93rem/1.2 var(--sans);
  border-radius: 3px;
  cursor: pointer;
}

button.primary {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
}

button.primary:disabled {
  background: #9f9b93;
  border-color: #9f9b93;
  cursor: not-allowed;
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid #aaa49a;
}

button.secondary:disabled {
  color: #a7a298;
  border-color: var(--line);
  cursor: not-allowed;
}

button.secondary[aria-pressed="true"] {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: #6b5221;
}

button.small {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 0.82rem;
}

/* Progress & Metrics */
.progress-block {
  margin-bottom: 10px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.86rem;
  margin-bottom: 4px;
}

progress {
  width: 100%;
  height: 8px;
  appearance: none;
  border: 0;
  background: var(--panel);
}

progress::-webkit-progress-bar { background: #ece9e1; }
progress::-webkit-progress-value { background: var(--gold); }
progress::-moz-progress-bar { background: var(--gold); }

.status-text {
  margin: 8px 0 12px;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 8px 10px;
  background: var(--panel);
  border-left: 2px solid var(--gold);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 0;
}

.metrics-grid > div {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.metrics-grid dt {
  font-size: 0.76rem;
  color: var(--muted);
}

.metrics-grid dd {
  margin: 2px 0 0;
  font-size: 0.86rem;
  font-weight: 600;
  word-break: break-word;
}

/* Live preview during chunked run */
.live-preview {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.live-preview-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.live-seg {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  font-size: 0.88rem;
  padding: 6px 8px;
  background: var(--panel);
  border-left: 2px solid var(--line);
}

.live-seg .tc {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--gold);
  white-space: nowrap;
}

/* Review View */
.media-preview {
  margin-bottom: 12px;
  background: #171614;
  padding: 8px;
  text-align: center;
}

.media-preview video {
  max-width: 100%;
  max-height: 240px;
}

.media-preview audio {
  width: 100%;
}

.replace-bar {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.replace-bar input { margin-top: 0; }

.segment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.empty-state {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
  border: 1px dashed var(--line);
}

.seg-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  padding: 10px 12px;
  background: #fff;
}

.seg-card.needs-review {
  border-left-color: var(--warn);
  background: #fffdf8;
}

.seg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.seg-tc-btn {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--gold-soft);
  color: #6b5221;
  border: 1px solid #dfd2b5;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
}

.seg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.seg-orig {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 6px;
}

.seg-edit {
  min-height: 54px;
  margin-top: 0;
  font-size: 0.96rem;
}

/* Export View */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.export-item {
  border: 1px solid var(--line);
  padding: 12px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.export-item h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1rem;
}

.preview-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.code-box {
  margin: 0;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font: 0.78rem/1.45 var(--mono);
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 640px) {
  .replace-bar {
    grid-template-columns: 1fr 1fr;
  }
  .masthead .brand-logo {
    width: 38px;
    height: 38px;
  }
}
