:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ec;
  --text: #1b1f24;
  --muted: #6a7380;
  --accent: #2f6feb;
  --accent-bg: #e8f0ff;
  --done: #9aa3ad;
  --done-bg: #eef1f5;
  --danger: #d14343;
  --warn-bg: #fff8e6;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar-head {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar h1 {
  font-size: 15px;
  margin: 0 0 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.total-progress { display: flex; flex-direction: column; gap: 6px; }
.total-bar {
  background: var(--done-bg);
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
}
.total-bar > div {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .25s ease;
}
.total-label { font-size: 12px; display: flex; justify-content: space-between; }

nav#video-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.video-item {
  display: block;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  user-select: none;
}
.video-item:hover { background: #f9fafb; }
.video-item.active {
  background: var(--accent-bg);
  border-left-color: var(--accent);
}
.video-item .v-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 4px;
}
.video-item .v-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.video-item .v-bar {
  background: var(--done-bg);
  height: 3px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.video-item .v-bar > div {
  height: 100%;
  background: var(--accent);
  width: 0;
}
.video-item.done { opacity: 0.6; }
.video-item.done .v-bar > div { background: var(--done); }

.sidebar-actions {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.btn:hover { background: #f3f5f9; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: #1e5bd6; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fdecec; }

.footer-note { font-size: 11px; padding: 0 12px 10px; margin: 0; }
.muted { color: var(--muted); }

/* Main */
.main {
  padding: 24px 32px 80px;
  max-width: 1100px;
}
.main-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.main-head h2 {
  font-size: 22px;
  margin: 0;
  font-weight: 700;
}
.main-head-right { display: flex; gap: 16px; align-items: center; }
.toggle { font-size: 12px; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.video-progress { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.video-bar {
  width: 120px;
  height: 6px;
  background: var(--done-bg);
  border-radius: 4px;
  overflow: hidden;
}
.video-bar > div {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .25s ease;
}

/* Panels */
.panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 24px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}
.panel > summary {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform .15s;
}
.panel[open] > summary::before { transform: rotate(90deg); display: inline-block; }
.panel .md, .panel ul { padding: 4px 18px 14px; }
.panel ul { margin: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 6px; font-weight: 600; }
.md h3 { font-size: 14px; }
.md h4 { font-size: 13px; color: var(--muted); }
.md ul, .md ol { padding-left: 22px; margin: 4px 0; }
.md li { margin: 2px 0; }
.md p { margin: 6px 0; }
.md code { background: #eef1f5; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.md pre {
  background: #1e232a;
  color: #e6ebf2;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}
.md pre code { background: none; color: inherit; padding: 0; }
.md table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.md th, .md td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.md th { background: #f3f5f9; font-weight: 600; }
.md blockquote {
  margin: 6px 0;
  padding: 6px 12px;
  background: var(--warn-bg);
  border-left: 3px solid #f2b84b;
  border-radius: 3px;
}

/* Cuts */
.cuts-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.cuts-head h3 { margin: 0; font-size: 15px; }
.cut {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 14px 14px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 34px 60px 1fr;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: background .15s, opacity .15s;
}
.cut.done {
  background: var(--done-bg);
  opacity: 0.6;
}
.cut.done .cut-action,
.cut.done .cut-script {
  text-decoration: line-through;
  color: var(--done);
}
.cut-check {
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}
.cut-check input[type=checkbox] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
}
.cut-num {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding-top: 2px;
}
.cut-body { display: flex; flex-direction: column; gap: 8px; }
.cut-action, .cut-script {
  padding: 8px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}
.cut-action {
  background: #eef4ff;
  border-left: 3px solid var(--accent);
  font-size: 13px;
}
.cut-action::before {
  content: "🎬 操作";
  display: block;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: .05em;
}
.cut-script {
  background: #fff7e6;
  border-left: 3px solid #f0a82b;
  font-size: 14px;
}
.cut-script::before {
  content: "🎤 台詞";
  display: block;
  font-size: 11px;
  color: #c47b00;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: .05em;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1b1f24;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  animation: fadein .2s;
  z-index: 100;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Responsive */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 16px; }
}
