/* Free source preparation shares the existing production shell tokens. */
.dseg { color: var(--shell-text); font-size: 14px; line-height: 1.6; }
.dseg *, .dseg *::before, .dseg *::after { box-sizing: border-box; }
.dseg h2, .dseg h3, .dseg p { margin: 0; }
.dseg h2 { font-size: 20px; line-height: 1.4; }
.dseg h3 { font-size: 16px; }
.dseg-heading { margin: 20px 0; }
.dseg-heading p, .dseg-note, .dseg-episode-heading span, .dseg-episodes span { color: var(--shell-muted); }
.dseg-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.dseg-episodes { display: grid; gap: 8px; position: sticky; top: 16px; }
.dseg button, .dseg textarea, .dseg input { font: inherit; }
.dseg button, .dseg input, .dseg summary { min-height: 44px; }
.dseg button { cursor: pointer; }
.dseg button:disabled { opacity: .6; cursor: not-allowed; }
.dseg button:focus-visible, .dseg textarea:focus-visible, .dseg input:focus-visible, .dseg summary:focus-visible { outline: 2px solid var(--shell-accent); outline-offset: 3px; }
.dseg .secondary, .dseg-episodes button { color: var(--shell-text); background: var(--shell-panel-2); border: 1px solid color-mix(in srgb, var(--shell-text) 18%, transparent); border-radius: 8px; padding: 8px 12px; box-shadow: none; }
.dseg .primary { color: var(--shell-accent-ink); background: var(--shell-accent); border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; font-weight: 700; box-shadow: none; }
.dseg-episode-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: center; }
.dseg-episode-row input { appearance: auto; min-height: 0; width: 16px; height: 16px; margin: 0; accent-color: var(--shell-accent); cursor: pointer; }
.dseg-episode-row button { display: grid; gap: 4px; text-align: left; overflow-wrap: anywhere; }
.dseg-episodes .dseg-generate-checked { width: 100%; text-align: center; }
.dseg-episodes [data-dseg-checked-count] { color: var(--shell-muted); font-size: 12px; min-height: 19px; }
.dseg-episodes [aria-current="true"] { border-color: var(--shell-accent); background: color-mix(in srgb, var(--shell-accent) 10%, var(--shell-panel)); }
.dseg-episodes span { font-size: 12px; }
.dseg-main { min-width: 0; max-width: 920px; display: grid; gap: 16px; }
.dseg-episode-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.dseg-oneclick { display: grid; gap: 12px; padding: 20px; background: var(--shell-panel); border: 1px solid color-mix(in srgb, var(--shell-text) 12%, transparent); border-radius: 12px; }
.dseg-oneclick .dseg-actions { margin-top: 0; }
.dseg-fee-note { font-size: 12px; }
.dseg-adjustments { border-top: 1px solid color-mix(in srgb, var(--shell-text) 12%, transparent); padding-top: 8px; }
.dseg-adjustments > summary { display: list-item; cursor: pointer; min-height: 44px; padding: 8px 0; color: var(--shell-muted); }
.dseg-adjustments[open] > summary { margin-bottom: 12px; }
.dseg-adjustments > .dseg-note { margin-bottom: 12px; }
.dseg-segments { display: grid; gap: 20px; }
.dseg-segment { padding: 16px; border: 1px solid color-mix(in srgb, var(--shell-text) 12%, transparent); border-radius: 12px; background: var(--shell-panel); min-width: 0; }
.dseg-segment-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dseg-segment-head label { font-weight: 600; }
.dseg-duration { display: flex; align-items: center; gap: 8px; }
.dseg-duration input { width: 72px; padding: 8px; color: var(--shell-text); background: var(--shell-panel-2); border: 1px solid color-mix(in srgb, var(--shell-text) 20%, transparent); border-radius: 8px; }
.dseg textarea, .dseg-source { display: block; margin: 0; width: 100%; min-height: 200px; padding: 16px; color: var(--shell-text); background: var(--shell-panel-2); border: 1px solid color-mix(in srgb, var(--shell-text) 12%, transparent); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.85; font-size: 15px; }
.dseg textarea { resize: vertical; }
.dseg-source { max-height: 560px; overflow: auto; }
.dseg-range-actions, .dseg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dseg-commit { padding: 16px 0; border-top: 1px solid color-mix(in srgb, var(--shell-text) 14%, transparent); }
.dseg-error { color: var(--shell-danger); padding: 12px; background: color-mix(in srgb, var(--shell-danger) 9%, var(--shell-panel)); border-radius: 8px; }
.dseg-empty, .dseg-loading { padding: 24px; border-radius: 12px; background: var(--shell-panel); display: grid; gap: 12px; }
.dseg-loading div { height: 72px; background: var(--shell-panel-2); border-radius: 8px; }
.dseg-empty button { justify-self: start; }
.dseg-advanced { margin-top: 20px; color: var(--shell-muted); }
.dseg-advanced summary { display: list-item; cursor: pointer; padding: 8px 0; }
body:not(.project-advanced-mode) [data-legacy-storyboard] { display: none !important; }
@media (max-width: 700px) {
  .dseg-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .dseg-episodes { position: static; grid-template-columns: minmax(0, 1fr); }
  .dseg-segment { padding: 12px; }
  .dseg textarea { min-height: 240px; }
  .dseg-actions button { width: 100%; white-space: normal; }
}

.dseg-editor-heading { display: grid; gap: 6px; margin-bottom: 16px; }
.dseg-editor-card { display: grid; gap: 12px; }
.dseg-editor-card textarea { min-height: 360px; margin-top: 8px; }
.dseg-editor-card summary { cursor: pointer; color: var(--shell-muted); }
.dseg-editor-card .dseg-source { min-height: 0; max-height: 260px; }
