:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #697386;
  --line: #dfe3e8;
  --paper: #fff;
  --canvas: #f5f6f8;
  --accent: #3157d5;
  --accent-dark: #213f9e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #9ab0ff; outline-offset: 2px;
}
.site-header {
  min-height: 58px; padding: 0 24px; display: flex; align-items: center;
  justify-content: space-between; background: #111827; color: #fff;
}
.site-header a { color: #fff; text-decoration: none; }
.site-header nav { display: flex; gap: 20px; align-items: center; font-size: 14px; }
.site-header form { margin: 0; }
.nav-button { padding: 0; border: 0; background: none; color: #fff; cursor: pointer; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 750; letter-spacing: .03em; font-size: 18px;
}
.brand-mark { display: block; flex-shrink: 0; border-radius: 7px; }
.auth-logo { display: block; width: min(200px, 100%); height: auto; margin: 0 0 8px; }
.dashboard { max-width: 1080px; margin: 0 auto; padding: 48px 24px; }
.page-heading, .editor-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
h1 { margin: 4px 0 18px; font-size: clamp(24px, 3vw, 36px); }
.eyebrow { margin: 0; color: var(--accent); font-size: 13px; font-weight: 700; }
.deck-list { display: grid; gap: 14px; }
.deck-card {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
}
.deck-card h2 { margin: 0 0 8px; font-size: 19px; }
.deck-card p { margin: 7px 0; color: var(--muted); }
.pill, .source-mark {
  display: inline-block; padding: 3px 7px; border-radius: 99px; background: #edf1ff;
  color: #2948ab; font-size: 11px; font-weight: 700;
}
.button {
  display: inline-flex; justify-content: center; align-items: center; min-height: 38px;
  padding: 8px 14px; border: 1px solid #bdc5d0; border-radius: 7px; background: #fff;
  color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 650;
}
.button:hover { background: #f2f4f7; }
.button.primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { color: #fff; border-color: #b42318; background: #b42318; }
.button:disabled { opacity: .55; cursor: wait; }
.muted { color: var(--muted); }
.empty-state { margin: 50px auto; padding: 50px; max-width: 640px; text-align: center; background: #fff; border-radius: 14px; }
.quality-filters, .management-actions {
  display: flex; gap: 8px; align-items: end; flex-wrap: wrap;
}
.quality-filters { margin-bottom: 28px; padding: 14px; background: #fff; border-radius: 10px; }
.quality-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.quality-filters select, .management-actions input { padding: 8px; border: 1px solid #bdc5d0; border-radius: 6px; }
.management-list { display: grid; gap: 10px; margin-bottom: 32px; }
.management-row {
  display: flex; justify-content: space-between; gap: 18px; align-items: center;
  padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.management-row > details { flex: 1; min-width: 0; }
.management-row > details > summary { cursor: pointer; }
.management-row p { margin: 5px 0; color: var(--muted); font-size: 12px; }
.editor {
  --studio-bg: #10131b;
  --studio-panel: #171b25;
  --studio-panel-raised: #1d2230;
  --studio-line: #2b3242;
  --studio-text: #f3f5f8;
  --studio-muted: #929bad;
  min-height: calc(100vh - 58px); padding: 20px 24px 28px;
  color: var(--studio-text); background:
    radial-gradient(circle at 48% -20%, #293354 0, transparent 34%),
    var(--studio-bg);
}
.editor-heading { min-height: 92px; }
.editor-heading h1 { margin: 3px 0 8px; font-size: clamp(22px, 2.2vw, 31px); letter-spacing: -.02em; }
.editor-title .eyebrow { margin-top: 5px; color: #8ea5ff; font-size: 10px; letter-spacing: .16em; }
.editor-statuses, .editor-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-chip {
  display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px;
  border: 1px solid #343c4f; border-radius: 99px; color: #b7c0d0;
  background: #171c27b8; font-size: 11px; font-weight: 650;
}
.status-dot { width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #43d19e; box-shadow: 0 0 8px #43d19e; }
.quality-chip { color: #a9e7cf; }
.issue-chip { color: #ffd48d; }
.back-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.editor .back-link { color: var(--studio-muted); }
.editor .button {
  border-color: #3a4356; background: #252b39; color: var(--studio-text);
  box-shadow: 0 1px 1px #0003;
}
.editor .button:hover { border-color: #59647c; background: #303747; }
.editor .button.primary { border-color: #5577ff; background: linear-gradient(135deg, #5577ff, #7657e8); color: #fff; }
.editor .button.ghost { background: transparent; }
.add-track { position: relative; }
.add-track summary { list-style: none; }
.add-track form {
  position: absolute; z-index: 10; right: 0; top: 48px; width: min(380px, 90vw);
  padding: 20px; border: 1px solid var(--studio-line); border-radius: 14px;
  background: #1b202c; box-shadow: 0 24px 70px #0009;
}
.add-track label { display: grid; gap: 5px; margin-bottom: 10px; color: var(--studio-muted); font-size: 12px; }
.add-track .checkbox-row {
  display: flex; align-items: flex-start; gap: 8px; grid-template-columns: none;
  color: #c5cee0; font-weight: 600; line-height: 1.4;
}
.add-track .checkbox-row input { width: 16px; height: 16px; margin-top: 2px; accent-color: #6884ff; }
.add-track input, .add-track select {
  width: 100%; padding: 9px; border: 1px solid #3b4457; border-radius: 7px;
  background: #11151e; color: var(--studio-text);
}
.editor .embed-manager {
  margin-top: 14px; border: 1px solid var(--studio-line); border-radius: 12px;
  background: #171b25cc; color: var(--studio-text);
}
.job-progress {
  margin-top: 12px; padding: 12px 16px; border: 1px solid #42517a;
  border-radius: 10px; background: #18213a; color: #dce4ff; font-size: 12px;
}
.job-progress > div:first-child { display: flex; justify-content: space-between; gap: 12px; }
#job-progress-list { display: grid; gap: 4px; margin-top: 8px; color: #aebbe3; }
.job-progress-row { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor .embed-manager > summary { padding: 12px 16px; color: #bdc5d3; cursor: pointer; font-size: 13px; font-weight: 700; }
.embed-manager-body { display: grid; gap: 18px; padding: 0 18px 18px; }
.embed-manager form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.editor .embed-manager label { display: grid; gap: 5px; color: var(--studio-muted); font-size: 12px; }
.editor .embed-manager input, .editor .embed-manager textarea {
  padding: 8px; border: 1px solid #3b4457; border-radius: 6px; background: #11151e; color: var(--studio-text);
}
.embed-manager h2 { margin: 0 0 8px; font-size: 15px; }
.editor #embed-token-result { padding: 14px; border: 1px solid #7b6532; border-radius: 8px; background: #332c1d; }
#embed-token-result label { margin-top: 10px; }
.token-list { display: grid; gap: 8px; }
.token-row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 12px; border: 1px solid var(--studio-line); border-radius: 8px;
}
.editor .token-row p { margin: 5px 0; color: var(--studio-muted); font-size: 12px; }
.pill.inactive { color: #697386; background: #eef0f3; }
.workspace {
  display: grid; grid-template-columns: 168px minmax(380px, 1fr) minmax(380px, 450px);
  height: max(650px, calc(100vh - 205px)); margin-top: 14px;
  border: 1px solid var(--studio-line); border-radius: 16px; overflow: hidden;
  background: var(--studio-panel); box-shadow: 0 24px 70px #0005;
}
.timeline {
  padding: 12px; overflow-y: auto; border-right: 1px solid var(--studio-line);
  background: #121620; scrollbar-color: #414a60 transparent;
}
.timeline-heading {
  position: sticky; z-index: 2; top: -12px; display: flex; justify-content: space-between;
  margin: -12px -12px 10px; padding: 13px 14px; border-bottom: 1px solid var(--studio-line);
  background: #121620ed; backdrop-filter: blur(10px); color: #8f98aa; font-size: 10px;
  letter-spacing: .16em;
}
.timeline-heading strong { color: #dce1ea; font-size: 11px; letter-spacing: 0; }
.slide-thumb {
  position: relative; width: 100%; margin-bottom: 12px; padding: 5px;
  border: 2px solid transparent; border-radius: 9px; background: #1b202b;
  cursor: pointer; transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.slide-thumb:hover { transform: translateY(-1px); border-color: #49546b; }
.slide-thumb.selected { border-color: #6f8cff; box-shadow: 0 0 0 2px #5577ff22, 0 8px 20px #0005; }
.slide-thumb img { display: block; width: 100%; border-radius: 5px; background: #080a0f; }
.slide-thumb .page-number {
  position: absolute; z-index: 1; top: 7px; left: 7px; min-width: 20px; padding: 2px 5px;
  border-radius: 4px; background: #111827dd; color: #fff; font-size: 11px;
}
.slide-thumb .quality-badges {
  position: absolute; z-index: 1; display: flex; gap: 3px; top: 7px; right: 7px; left: auto; padding: 0;
  background: transparent;
}
.quality-badge { padding: 2px 5px; border-radius: 4px; color: #fff; font-size: 10px; }
.error-badge { background: #b42318; }
.warning-badge { background: #b76e00; }
.stage { display: grid; min-width: 0; grid-template-rows: auto 1fr auto; background: #0d1017; }
.stage-toolbar, .stage-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 18px; border-bottom: 1px solid var(--studio-line);
  background: #151923; color: var(--studio-muted); font-size: 11px;
}
.stage-toolbar > div:first-child { display: grid; gap: 2px; }
.stage-toolbar strong { color: #e9ecf2; font-size: 13px; }
.stage-kicker { color: #75809a; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.zoom-controls { display: flex; align-items: center; gap: 4px; }
.zoom-controls button {
  min-width: 28px; height: 28px; padding: 0 7px; border: 1px solid #343c4d;
  border-radius: 6px; background: #202633; color: #c8cfda; cursor: pointer;
}
.zoom-controls button:hover { background: #2b3343; }
#zoom-label { min-width: 42px; text-align: center; }
.stage-viewport {
  display: grid; overflow: auto; place-items: center; padding: 32px;
  background-color: #0d1017;
  background-image: radial-gradient(#2b3140 1px, transparent 1px);
  background-size: 18px 18px;
}
.stage-viewport img {
  display: block; width: 100%; max-width: 1080px; max-height: calc(100vh - 310px);
  object-fit: contain; background: white; box-shadow: 0 18px 60px #000b;
  transition: width .18s ease, max-width .18s ease;
}
.stage-footer { border-top: 1px solid var(--studio-line); border-bottom: 0; }
.script-panel { overflow-y: auto; border-left: 1px solid var(--studio-line); background: var(--studio-panel); }
.inspector-tabs {
  position: sticky; z-index: 4; top: 0; display: grid; grid-template-columns: 1fr 1fr;
  padding: 8px; border-bottom: 1px solid var(--studio-line); background: #171b25ed;
  backdrop-filter: blur(12px);
}
.inspector-tab {
  padding: 9px; border: 0; border-radius: 7px; background: transparent;
  color: var(--studio-muted); cursor: pointer; font-size: 12px; font-weight: 750;
}
.inspector-tab.selected { background: #272e3d; color: #fff; box-shadow: inset 0 0 0 1px #343e52; }
.tab-count {
  display: inline-grid; min-width: 18px; height: 18px; margin-left: 4px; place-items: center;
  border-radius: 99px; background: #68491c; color: #ffd68d; font-size: 10px;
}
.inspector-panel { padding: 18px; }
.quality-panel h2, .panel-heading h2 { margin: 3px 0 0; font-size: 17px; }
#quality-issue-list { display: grid; gap: 8px; margin: 12px 0; }
.quality-issue { padding: 12px; border: 1px solid #343c4d; border-left: 4px solid #697386; border-radius: 8px; background: #1d2330; }
.quality-issue[data-severity="error"] { border-color: #b42318; }
.quality-issue[data-severity="warning"] { border-color: #b76e00; }
.quality-issue h3 { margin: 0 0 5px; font-size: 13px; }
.quality-issue p { margin: 4px 0; font-size: 12px; white-space: pre-wrap; }
.quality-issue-meta { color: var(--muted); font-size: 11px; }
.track-tabs { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 12px; }
.track-tab {
  white-space: nowrap; padding: 8px 10px; border: 1px solid #343c4d; border-radius: 7px;
  background: #121620; color: var(--studio-muted); cursor: pointer;
}
.track-tab.selected { color: #fff; border-color: #637fff; background: #263257; font-weight: 700; }
.source-mark { margin-left: 4px; padding: 2px 5px; }
.panel-meta, .audio-box > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-meta { margin: 6px 0 16px; }
.track-settings {
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px;
  margin: -6px 0 15px; padding: 10px; border: 1px solid #30384a; border-radius: 8px;
  background: #121721;
}
.track-settings label { display: grid; gap: 4px; color: var(--studio-muted); font-size: 11px; }
.track-settings select {
  padding: 7px; border: 1px solid #3b4457; border-radius: 6px;
  background: #11151e; color: var(--studio-text);
}
#track-settings-status { grid-column: 1 / -1; color: #62d8a8; font-size: 11px; }
.editor .status { color: var(--studio-muted); font-size: 11px; }
.editor .text-button { padding: 0; border: 0; background: none; color: #8ea5ff; cursor: pointer; font-size: 12px; }
.script-label { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; font-weight: 700; }
#character-count { color: var(--studio-muted); font-size: 11px; font-weight: 500; }
textarea { width: 100%; resize: vertical; padding: 12px; border: 1px solid #bdc5d0; border-radius: 7px; line-height: 1.7; }
.editor #script {
  min-height: 250px; border-color: #343d50; background: #10141d; color: #edf0f5;
  box-shadow: inset 0 2px 8px #0004; resize: vertical;
}
.editor #script:focus { border-color: #6884ff; outline: 2px solid #6884ff33; }
.script-hint {
  margin: 0 0 8px; color: #8a93a3; font-size: 11px; font-weight: 500; line-height: 1.55;
}
.script-hint code {
  padding: 1px 5px; border-radius: 4px; background: #1a2130; color: #c9d4ff; font-size: 11px;
}
.script-tools { display: flex; justify-content: flex-end; margin-top: 6px; }
.action-row { display: flex; gap: 8px; margin-top: 10px; }
.audio-box {
  margin-top: 20px; padding: 16px; border: 1px solid #30384a;
  border-radius: 11px; background: #121721;
}
.audio-box h2 { margin: 3px 0 0; font-size: 15px; }
.record-box { margin: 12px 0; display: grid; gap: 8px; }
.record-box .checkbox-row {
  display: flex; gap: 8px; align-items: flex-start; color: #9aa6bd; font-size: 13px;
}
.record-box .checkbox-row input { width: 16px; height: 16px; margin-top: 2px; accent-color: #6884ff; }
.file-button { display: inline-flex; align-items: center; cursor: pointer; }
#record-status { color: #9aa6bd; }
#record-status.error { color: #ff8b82; }
#elevenlabs-voice-settings { display: grid; gap: 8px; margin: 8px 0; }
#elevenlabs-voice-settings[hidden],
#openrouter-voice-settings[hidden] { display: none; }
.track-settings { display: grid; gap: 8px; align-items: start; }
.waveform { display: flex; height: 42px; align-items: center; gap: 3px; margin: 14px 0; overflow: hidden; }
.waveform i { width: 3px; height: 18%; border-radius: 3px; background: #637fff; opacity: .65; }
.waveform i:nth-child(3n) { height: 70%; }
.waveform i:nth-child(4n) { height: 42%; }
.waveform i:nth-child(5n) { height: 92%; }
audio { width: 100%; margin: 12px 0; }
.editor .error { min-height: 1em; margin: 5px 0; color: #ff8b82; font-size: 12px; white-space: pre-wrap; }
.editor .notice { min-height: 1.2em; color: #62d8a8; font-size: 13px; }
.messages { max-width: 1080px; margin: 14px auto 0; padding: 0 24px; color: #276749; }
.messages p { padding: 10px 14px; border-radius: 7px; background: #e8f7ee; }
.narrow { max-width: 680px; }
.auth-page { display: grid; min-height: calc(100vh - 58px); place-items: center; padding: 24px; }
.form-card { display: grid; gap: 16px; width: 100%; padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.auth-page .form-card { max-width: 430px; }
.form-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
.form-card input, .form-card select { width: 100%; padding: 10px; border: 1px solid #bdc5d0; border-radius: 6px; color: var(--ink); }
.form-card .errorlist { margin: 0; padding-left: 20px; color: #b42318; }
.warning { padding: 12px; border-radius: 7px; background: #fff8df; }
.danger-zone { border-color: #e8aaa6; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 100px 1fr; height: auto; }
  .script-panel { grid-column: 1 / -1; min-height: 520px; border-left: 0; border-top: 1px solid var(--studio-line); }
  .stage { min-height: 480px; }
  .stage-viewport img { max-height: 410px; }
}
@media (max-width: 540px) {
  .site-header { padding: 0 14px; }
  .editor { padding: 10px; }
  .editor-heading { align-items: flex-start; flex-direction: column; }
  .editor-tools { width: 100%; justify-content: flex-end; }
  .workspace { grid-template-columns: 76px 1fr; }
  .stage { min-height: 340px; }
  .stage-toolbar { align-items: flex-start; flex-direction: column; }
  .stage-viewport { padding: 12px; }
  .stage-footer span:first-child { display: none; }
  .inspector-panel { padding: 14px; }
  .deck-card, .page-heading { align-items: flex-start; flex-direction: column; }
}
