/* クロラボ 動画台本スタジオ — スタイル（ライト・読みやすさ優先） */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #1f2933;
  --ink-soft: #5b6b7b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #eef2ff;
  --bg: #f4f6f9;
  --card: #ffffff;
  --danger: #dc2626;
}

html, body { height: 100%; }
body {
  font-family: 'Hiragino Sans', 'Segoe UI', 'Yu Gothic', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
}

#app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }

/* ---- buttons ---- */
.btn {
  font-family: inherit; font-size: 15px; font-weight: 700;
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid transparent; background: #fff; color: var(--ink);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: #fff; color: var(--accent); border-color: var(--line); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c2c2; }
.btn-sm { font-size: 15px; padding: 6px 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- sidebar ---- */
.sidebar {
  background: var(--card); border-right: 1px solid var(--line);
  padding: 18px 16px; display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
}
.brand { font-size: 17px; font-weight: 800; }
.video-list { list-style: none; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.video-item {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  cursor: pointer; font-size: 14px; line-height: 1.5; background: #fff;
}
.video-item:hover { border-color: var(--accent); }
.video-item.active { background: var(--accent-soft); border-color: var(--accent); }
.video-item .vi-title { font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-item .vi-meta { font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
.io { display: flex; gap: 8px; }
.io .btn { flex: 1 1 0; text-align: center; }
.import-label { display: inline-block; }
.hint { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }

/* ---- main ---- */
.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--card);
}
.tabs { display: flex; gap: 6px; }
.tab {
  font-family: inherit; font-size: 15px; font-weight: 700;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 8px; padding: 8px 16px; cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.topbar-actions { display: flex; gap: 8px; }

.panel { padding: 24px; overflow-y: auto; flex: 1 1 auto; }
.empty { padding: 60px 24px; color: var(--ink-soft); text-align: center; }

/* ---- edit form ---- */
.form-wrap { max-width: 860px; margin: 0 auto; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; font-family: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff;
}
.field textarea { line-height: 1.8; resize: vertical; }
.field textarea.mono { min-height: 180px; }
.field textarea.script { min-height: 320px; }
.field .help { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-title { font-size: 17px; font-weight: 800; color: var(--accent); margin: 26px 0 12px; border-left: 4px solid var(--accent); padding-left: 10px; }
.saved-tag { font-size: 14px; color: #15803d; }

/* ---- preview（トークスクリプト表示） ---- */
.preview-wrap { max-width: 780px; margin: 0 auto; }
.pv-title { font-size: clamp(18px,3vw,24px); font-weight: 800; line-height: 1.5; margin-bottom: 24px; }
.pv-sec-h { font-size: 18px; font-weight: 800; letter-spacing: 1px; color: var(--accent); border-left: 4px solid var(--accent); padding-left: 12px; margin: 30px 0 16px; }
.outline-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; }
.outline-box h3 { font-size: 17px; font-weight: 700; margin: 18px 0 8px; }
.outline-box h3:first-child { margin-top: 0; }
.outline-box ul { list-style: none; display: grid; gap: 6px; }
.outline-box li { font-size: 16px; color: var(--ink-soft); padding-left: 16px; position: relative; }
.outline-box li::before { content: "・"; position: absolute; left: 0; color: var(--accent); }

.tts-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.tts-bar select { font-family: inherit; font-size: 15px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.tts-bar label { font-size: 14px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.tts-status { font-size: 14px; color: var(--ink-soft); margin-left: auto; }

.scene { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 26px; margin-bottom: 14px; }
.scene-label { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .5px; color: var(--accent); background: var(--accent-soft); border-radius: 20px; padding: 3px 12px; margin-bottom: 12px; }
.scene p { font-size: 16px; line-height: 2.0; margin-bottom: 10px; }
.scene p:last-child { margin-bottom: 0; }
.scene .note { font-size: 14px; color: var(--ink-soft); background: #f8fafc; border-left: 3px solid var(--line); padding: 8px 12px; border-radius: 6px; }
.scene.reading { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,0.18); }

/* ---- アコーディオン共通 ---- */
.acc .acc-body { display: none; }
.acc.acc-open .acc-body { display: block; }
.acc-toggle {
  font-family: inherit; font-size: 15px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; margin-top: 8px;
}
.acc-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.acc-toolbar-label { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* ---- 画像 ---- */
.sec-images { margin-top: 12px; }
.sec-images--edit { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }
.sec-images--edit.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.sec-images-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.img-empty { font-size: 14px; color: var(--ink-soft); text-align: center; padding: 14px; }
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.img-thumb { position: relative; width: 110px; height: 80px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f1f5f9; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.img-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; padding: 0; }
.img-del:hover { background: rgba(0,0,0,.8); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 1000; cursor: zoom-out; padding: 24px; }
.lightbox[hidden] { display: none !important; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }

/* ---- 編集: セクションカード ---- */
.sections-edit { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.sec-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.sec-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sec-move { display: flex; flex-direction: column; gap: 2px; }
.sec-move .mv { font-size: 11px; line-height: 1; width: 26px; height: 20px; border: 1px solid var(--line); background: #fff; border-radius: 5px; cursor: pointer; color: var(--ink-soft); }
.sec-move .mv:disabled { opacity: .35; cursor: default; }
.sec-title { flex: 1 1 auto; font-family: inherit; font-size: 16px; font-weight: 700; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; color: var(--ink); }
.sec-del { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.sec-sub { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.sec-points { width: 100%; font-family: inherit; font-size: 16px; line-height: 1.8; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 72px; resize: vertical; color: var(--ink); }
.sec-talk { width: 100%; font-family: inherit; font-size: 16px; line-height: 1.9; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 160px; resize: vertical; color: var(--ink); margin-top: 8px; }
.add-section { margin-bottom: 14px; }

/* ---- 編集: クリックで textarea になるブロック ---- */
.ce { border: 1px dashed transparent; border-radius: 8px; padding: 8px 10px; cursor: text; transition: background .12s, border-color .12s; }
.ce:hover { border-color: var(--line); background: #fbfdff; }
.ce-empty { color: var(--ink-soft); }
.ce-placeholder { color: var(--ink-soft); font-size: 14px; }
.ce-points { list-style: none; display: grid; gap: 6px; }
.ce-points li { font-size: 16px; color: var(--ink); padding-left: 16px; position: relative; }
.ce-points li::before { content: "・"; position: absolute; left: 0; color: var(--accent); }
.ce-line { font-size: 16px; line-height: 1.95; margin-bottom: 8px; }
.ce-line:last-child { margin-bottom: 0; }
.ce-note { font-size: 14px; color: var(--ink-soft); background: #f8fafc; border-left: 3px solid var(--line); padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; }
.ce-note:last-child { margin-bottom: 0; }
.ce-editing { border-style: solid; border-color: var(--accent); background: #fff; padding: 0; }
.ce-ta { width: 100%; font-family: inherit; font-size: 16px; line-height: 1.95; border: none; border-radius: 8px; padding: 10px 12px; resize: vertical; color: var(--ink); outline: none; display: block; box-sizing: border-box; }

/* ---- プレビュー: セクション ---- */
.pv-sec { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; margin-bottom: 14px; }
.pv-sec-title { font-size: 17px; font-weight: 800; margin-bottom: 10px; }
.pv-points { list-style: none; display: grid; gap: 6px; margin-bottom: 4px; }
.pv-points li { font-size: 16px; color: var(--ink-soft); padding-left: 16px; position: relative; }
.pv-points li::before { content: "・"; position: absolute; left: 0; color: var(--accent); }
.pv-sec .acc-body { margin-top: 10px; }
.pv-sec .scene { border: none; background: transparent; padding: 0; margin: 0; box-shadow: none; }
.pv-sec .scene.reading { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; box-shadow: none; }

/* ---- jsonld ---- */
.jsonld-wrap { max-width: 860px; margin: 0 auto; }
.jsonld-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.jsonld-warn { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.jsonld-pre {
  background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 18px 20px;
  font-family: 'Consolas','SF Mono',monospace; font-size: 14px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}
.copied-tag { font-size: 14px; color: #15803d; }

/* ---- user chip / cloud status ---- */
.user-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 12px; padding: 8px 10px;
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; color: var(--ink-soft);
}
.user-chip:empty { display: none; }
.user-chip .user-name {
  font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cloud-status {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  background: #0f172a; color: #e2e8f0; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .25);
}
.cloud-status--error { background: #b91c1c; color: #fff; }
.boot-error { max-width: 520px; margin: 80px auto; padding: 24px; text-align: center; color: var(--ink-soft); font-size: 16px; }
.boot-error a { color: var(--accent); font-weight: 700; }

/* ---- 分析ビュー ---- */
.analyze-wrap { max-width: 900px; margin: 0 auto; padding: 4px; }
.an-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0; }
.an-head h2 { font-size: 18px; }
.an-head h3 { font-size: 17px; }
.an-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.an-time { font-size: 14px; color: var(--ink-soft); }
.an-hint { font-size: 14px; color: var(--ink-soft); margin: 4px 0 12px; }
.an-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.an-table th, .an-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.an-table th { background: #f8fafc; color: var(--ink-soft); font-weight: 700; font-size: 14px; }
.an-table th:not(:first-child), .an-table td.an-num { text-align: right; font-variant-numeric: tabular-nums; }
.an-table tr:last-child td { border-bottom: none; }
.an-num { font-weight: 700; }
.an-muted { color: var(--ink-soft); }
.an-divider { height: 1px; background: var(--line); margin: 22px 0 12px; }
.an-result { margin-top: 8px; }
.an-loading { padding: 16px; color: var(--ink-soft); font-weight: 600; }
.an-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 8px 0; }
.an-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.an-card h4 { font-size: 17px; margin-bottom: 8px; }
.an-card p { font-size: 16px; }
.an-card ul { margin: 4px 0 0 18px; }
.an-card li { font-size: 16px; margin: 3px 0; }
.an-next { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 10px 0; }
.an-next-title { font-weight: 700; font-size: 17px; color: var(--accent); }
.an-next-why { font-size: 14px; color: var(--ink-soft); margin: 3px 0; }

/* ---- チャンネル ---- */
.ch-wrap { max-width: 900px; margin: 0 auto 4px; }
.ch-set { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ch-input { flex: 1; min-width: 220px; font-family: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.ch-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.ch-thumb { width: 44px; height: 44px; border-radius: 50%; }
.ch-meta { flex: 1; min-width: 160px; }
.ch-title { font-weight: 700; font-size: 17px; }
.ch-stats { font-size: 14px; color: var(--ink-soft); }
.ch-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- ブランド統一（基準画像＋プロンプト） ---- */
.br-wrap { max-width: 900px; margin: 0 auto 4px; }
.br-block { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.br-bt { font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.br-pre { font-size: 16px; color: var(--ink); background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; line-height: 1.6; }
.br-ta { font-family: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); line-height: 1.6; box-sizing: border-box; }
.br-sec { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 10px; }
.br-sec:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.br-sk { font-weight: 700; font-size: 17px; color: var(--accent); margin-bottom: 6px; }

/* ---- 詳細アナリティクス ---- */
.ana-wrap { max-width: 900px; margin: 0 auto; }
.ana-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0; }
.ana-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.ana-val { font-size: 20px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.ana-label { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
@media (max-width: 560px) { .ana-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .row2 { grid-template-columns: 1fr; }
}
