:root {
  color-scheme: light;
  font-family: "Yu Gothic UI", "Hiragino Sans", system-ui, sans-serif;
  color: #27231f;
  background: #f3eee6;
  --ink: #27231f;
  --ink-soft: #6f675f;
  --line: #d8cec1;
  --paper: #fffdfa;
  --paper-deep: #eee5da;
  --accent: #a54236;
  --accent-dark: #7e2d25;
  --focus: #2f6f9f;
  --success: #2f7257;
  --warning: #9a611e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper-deep); }
button, select, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button, input, select, textarea { border-radius: 6px; }
button { padding: 8px 11px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
button:hover:not(:disabled) { border-color: #aa9c8d; background: #fff; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #6da6ce88;
  outline-offset: 1px;
}
input, select, textarea { border: 1px solid var(--line); background: #fff; }
input { min-width: 0; padding: 8px 10px; }
[hidden] { display: none !important; }

.app-header {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 15px 26px;
  color: #fffaf2;
  background: #282522;
  border-bottom: 4px solid #c46c52;
}
.brand { min-width: 0; }
.eyebrow, .step-label { margin: 0 0 4px; color: #d9b7a8; font-size: 11px; font-weight: 700; letter-spacing: .16em; }
h1, h2 { margin: 0; font-family: Georgia, "Yu Mincho", serif; }
h1 { overflow: hidden; font-size: clamp(20px, 3vw, 29px); text-overflow: ellipsis; white-space: nowrap; }
h2 { font-size: 23px; }
.project-meta { margin: 5px 0 0; color: #cfc8be; font-size: 12px; }
.save-area { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.save-area button { white-space: nowrap; }
.status { color: #cfc8be; font-size: 13px; }
.status.dirty { color: #ffd38a; }
.status.saved { color: #9fe1bd; }
.primary { border-color: var(--accent); color: #fff; background: var(--accent); font-weight: 700; }
.primary:hover:not(:disabled) { border-color: var(--accent-dark); background: var(--accent-dark); }
kbd { padding: 1px 4px; border: 1px solid currentColor; border-radius: 3px; font-size: 11px; opacity: .75; }

.welcome-screen { display: grid; min-height: calc(100vh - 90px); place-items: center; padding: 28px 18px; }
.welcome-card {
  width: min(620px, 100%);
  padding: clamp(25px, 5vw, 44px);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 24px 60px #5c49372b;
}
.welcome-card > p:not(.step-label, .form-error) { color: var(--ink-soft); line-height: 1.7; }
.field { display: grid; gap: 5px; min-width: 0; color: var(--ink-soft); font-size: 12px; }
.field > span:first-child { font-weight: 700; }
.welcome-card .field { margin: 24px 0 17px; }
.file-drop {
  display: grid;
  gap: 7px;
  padding: 30px 20px;
  border: 2px dashed #bd9e8f;
  border-radius: 10px;
  color: var(--accent-dark);
  background: #fbf4ec;
  text-align: center;
  cursor: pointer;
}
.file-drop:hover, .file-drop.dragging { border-color: var(--accent); background: #fff5ec; }
.file-drop span { color: var(--ink-soft); font-size: 13px; }
.file-input { width: 100%; margin-top: 10px; padding: 8px; color: var(--ink-soft); background: #fff; }
.file-input::file-selector-button { margin-right: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #f7f1e9; cursor: pointer; }
.form-error { margin: 14px 0 0; color: #a32727; font-weight: 700; }
.welcome-notes { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; color: var(--ink-soft); font-size: 11px; }

.workspace { display: grid; grid-template-columns: minmax(420px, 40vw) minmax(520px, 1fr); min-height: calc(100vh - 90px); }
.player-panel { position: sticky; top: 0; align-self: start; display: grid; gap: 12px; max-height: 100vh; padding: 18px; overflow: auto; }
.panel { border: 1px solid var(--line); border-radius: 9px; background: var(--paper); box-shadow: 0 7px 18px #5b493519; }
.player-section { padding: 13px; }
.player-frame { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; border-radius: 7px; background: #171513; }
#youtube-player, #youtube-player iframe { width: 100%; height: 100%; }
.player-placeholder { position: absolute; inset: 0; display: grid; align-content: center; gap: 7px; padding: 28px; color: #f3e9dc; text-align: center; }
.player-placeholder span { color: #bfb4a9; font-size: 12px; line-height: 1.6; }
.player-error { margin: 9px 2px 0; padding: 8px 10px; border-radius: 5px; color: #7d2424; background: #ffeaea; font-size: 12px; }
.player-error a { color: inherit; font-weight: 700; }
.player-tools { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.current-time { margin-left: auto; color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.settings-panel { padding: 0 13px 13px; }
.settings-panel summary { padding: 12px 2px; color: var(--ink); font-weight: 700; cursor: pointer; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-wide { grid-column: 1 / -1; }
.field-action { align-content: end; }
.input-with-button { display: flex; gap: 6px; }
.input-with-button input { flex: 1; }
.input-with-button button { flex: none; }
.field small { color: var(--ink-soft); line-height: 1.4; }

.compact-panel { padding: 12px 13px; }
.summary, .toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.summary { padding: 9px 11px; border-radius: 6px; background: #eee5da; font-size: 12px; }
.summary span { white-space: nowrap; }
.toolbar-row { justify-content: space-between; margin-top: 9px; }
.toolbar-row label { display: flex; align-items: center; gap: 4px; color: var(--ink-soft); font-size: 12px; }
.toolbar-row input { width: 36px; padding: 4px; text-align: center; }
.shortcut-help { margin: 9px 1px 0; color: var(--ink-soft); font-size: 11px; line-height: 1.8; }

.transcript-panel { min-width: 0; padding: 18px 22px 80px 0; }
.transcript-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 13px; padding: 5px 3px; }
.transcript-heading .step-label { color: var(--accent); }
.transcript-heading > p { max-width: 390px; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.column-headings { display: grid; grid-template-columns: 88px 145px 1fr; padding: 0 13px 7px; color: var(--ink-soft); font-size: 11px; }
.turn-list { display: grid; gap: 8px; }
.turn-card {
  --speaker-color: #777;
  display: grid;
  grid-template-columns: 88px 145px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 11px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--speaker-color);
  border-radius: 7px;
  background: var(--paper);
  transition: background .15s, box-shadow .15s;
}
.turn-card.active { background: #fff5df; box-shadow: 0 0 0 2px #d6a84b; }
.turn-card.modified { border-right: 4px solid #4d82aa; }
.turn-card.flagged { background-image: linear-gradient(90deg, #fff2cc66, transparent 40%); }
.turn-card.short-turn .duration { color: #a33b31; font-weight: 700; }
.turn-card.overlap-candidate { background-image: linear-gradient(90deg, #e9d6ff99, transparent 52%); }
.turn-card.overlap-candidate .duration { color: #68418c; font-weight: 700; }
.time-button { padding: 7px 3px; border: 0; color: var(--accent); background: transparent; font-variant-numeric: tabular-nums; font-weight: 700; }
.speaker-select { width: 100%; padding: 7px 8px; border-color: var(--speaker-color); }
.turn-content { min-width: 0; }
.text-editor { width: 100%; min-height: 58px; resize: vertical; padding: 8px 10px; line-height: 1.65; }
.text-editor:focus { border-color: var(--focus); }
.turn-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 7px; }
.turn-actions select, .turn-actions button { padding: 5px 7px; font-size: 11px; }
.duration { margin-left: auto; color: var(--ink-soft); font-size: 11px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 10; max-width: min(420px, calc(100vw - 36px)); padding: 12px 15px; border-radius: 7px; color: #fff; background: #292521; box-shadow: 0 10px 28px #0004; font-size: 13px; }

@media (max-width: 1080px) {
  .workspace { display: block; }
  .player-panel { position: relative; max-height: none; }
  .transcript-panel { padding: 5px 18px 70px; }
}

@media (max-width: 700px) {
  .app-header { align-items: flex-start; padding: 13px 15px; }
  .app-header { display: block; }
  .save-area { justify-content: flex-start; margin-top: 12px; }
  .status { width: 100%; }
  .welcome-notes, .transcript-heading { display: block; }
  .welcome-notes span { display: block; margin-top: 5px; }
  .transcript-heading > p { margin-top: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .column-headings { display: none; }
  .turn-card { grid-template-columns: 84px 1fr; }
  .turn-content { grid-column: 1 / -1; }
}
