.app-header {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
[hidden] { display: none !important; }
.workflow-view { min-height: calc(100vh - 46px); padding: 24px; background: var(--bg); }
.login-view { min-height: 100vh; display: grid; place-items: center; }
.login-panel { width: min(420px, calc(100vw - 32px)); display: grid; gap: 16px; padding: 24px; border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 6px; background: var(--panel); box-shadow: 0 16px 40px rgba(24, 91, 122, .12); }
.login-panel h1, .page-toolbar h1 { margin: 0; font-size: 20px; }
.brand-large { font-size: 20px; }
.page-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-toolbar button { margin-left: auto; }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: var(--panel); }
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th, .table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.table-wrap tbody tr { cursor: pointer; }
.table-wrap tbody tr:hover { background: #e9f9ff; }
.create-project-form { width: min(760px, 100%); display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); background: var(--panel); }
.create-project-form label { display: grid; grid-template-columns: 120px minmax(0, 1fr); align-items: center; gap: 10px; }
.create-project-status { min-height: 22px; padding: 8px 10px; border-radius: 6px; color: #075985; background: #e0f2fe; }
.create-project-status:empty { display: none; }
.create-project-status[data-error="true"] { color: #991b1b; background: #fee2e2; }
.project-actions button { min-height: 42px; font-size: 14px; }
#editorView[data-readonly="true"] .audio-block:not(.source) { pointer-events: none; }
.brand { color: var(--text); font-size: 16px; }
.brand span { color: var(--muted); font-size: 12px; font-weight: 400; }
.app-header input { width: 104px; }
.app-shell {
  height: calc(100vh - 46px);
  min-height: 624px;
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(1020px, 1fr);
  overflow: auto;
}
.project-panel {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel-2);
  padding: 10px;
}
.panel-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  margin-bottom: 10px;
}
.panel-section h2 { margin: 0; font-size: 14px; }
.panel-section label { display: grid; gap: 5px; color: var(--muted); }
.project-list { display: grid; gap: 8px; }
.project-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  cursor: pointer;
}
.project-item:hover { border-color: var(--blue); }
.editor-panel {
  min-width: 1020px;
  min-height: 0;
  display: grid;
  grid-template-rows: 44px minmax(280px, 1fr) minmax(300px, 42vh);
  background: var(--bg);
}
.editor-toolbar,
.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.editor-toolbar #projectTitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#statusText {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.worktop {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, .9fr) minmax(560px, 1.25fr);
  gap: 10px;
  padding: 10px;
}
.media-preview-shell,
.line-panel,
.timeline-workspace {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}
.media-preview-shell {
  position: relative;
  display: grid;
  overflow: hidden;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #dff6ff;
}
#videoPreview {
  width: 100%;
  min-height: 0;
  height: 100%;
  background: #15263b;
  object-fit: contain;
  pointer-events: none;
}
.preview-status {
  position: absolute;
  inset: 0 0 42px;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(248, 253, 255, .88);
  color: var(--muted);
  text-align: center;
  z-index: 2;
}
.preview-status:not(:empty) { display: grid; }
.audio-preview-state {
  display: none;
  align-content: center;
  gap: 7px;
  padding: 24px;
  background: linear-gradient(135deg, #e4fbff, #fff0f7);
}
.audio-preview-label { color: var(--muted); }
.audio-preview-name {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-preview-shell[data-media-kind="audio"] { grid-template-rows: minmax(0, 1fr) auto; }
.media-preview-shell[data-media-kind="audio"] #videoPreview { display: none; }
.media-preview-shell[data-media-kind="audio"] .audio-preview-state { display: grid; }
.preview-readout {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.preview-readout > :last-child { text-align: right; }
.audio-preview-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #ccecf7;
}
#audioPreviewFill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pink);
}
.line-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
}
.line-filters { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 5px 10px; border-bottom: 1px solid var(--line); background: #f8fdff; }
.line-filters select { min-width: 132px; min-height: 28px; padding: 3px 28px 3px 7px; }
.line-filters button { min-height: 28px; margin-left: auto; }
.line-list-header,
.line-row { display: grid; grid-template-columns: 34px 70px minmax(0, 1fr); }
.line-list-header {
  position: relative;
  z-index: 2;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.line-list { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.line-row {
  gap: 8px;
  align-items: center;
  height: 66px;
  box-sizing: border-box;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
.line-row.selected { background: #e9f9ff; box-shadow: inset 3px 0 var(--pink); }
.line-index, .line-time { color: var(--muted); font-size: 12px; line-height: 1.5; }
.line-main { min-width: 0; display: grid; grid-template-columns: minmax(96px, 1fr) auto; align-items: center; gap: 8px; }
.line-subtitle { min-width: 0; overflow: hidden; font-size: 15px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.missing-subtitle-input { width: 100%; min-width: 260px; padding: 6px 8px; border: 1px solid #f2a9c9; border-radius: 4px; background: #fff7fb; color: var(--text); font-weight: 600; }
.line-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.line-controls-group { min-width: 0; flex-wrap: nowrap; justify-content: flex-end; gap: 4px; }
.line-controls label { display: inline-flex; align-items: center; color: var(--muted); white-space: nowrap; }
.line-controls select, .line-controls button { min-height: 32px; padding: 4px 6px; }
.line-controls select { min-width: 104px; max-width: 132px; padding-right: 28px; }
.line-controls button { min-width: 42px; }
.line-controls button[data-action="regenerate"] { min-width: 66px; }
.line-controls button:disabled { cursor: not-allowed; opacity: .55; }
.timeline-workspace { display: grid; grid-template-rows: 40px minmax(0, 1fr); border-width: 1px 0 0; }
.timeline-toolbar { padding-inline: 12px; }
.icon-button { width: 30px; min-width: 30px; padding: 0; font-size: 15px; }
.toggle-button.active { border-color: var(--pink); background: #ffe8f3; color: #b51862; }
.role-confidence { max-width: 104px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.mode-switch { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); }
.mode-switch button { min-height: 26px; background: transparent; color: var(--muted); }
.mode-switch button.active { background: var(--blue); color: #fff; }
.workspace-tabs { display: flex; gap: 4px; padding: 5px 8px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.workspace-tabs button { min-height: 28px; background: transparent; color: var(--muted); }
.workspace-tabs button.active { background: var(--blue); color: #fff; }
.line-panel { grid-template-rows: auto auto auto minmax(0, 1fr); }
.role-settings-panel { grid-row: 2 / 5; min-height: 0; overflow: auto; }
.role-settings-panel[hidden], .line-list-header[hidden], .line-list[hidden] { display: none; }
.voice-role-row { display: grid; grid-template-columns: 72px 112px 130px minmax(130px, 1fr) 48px 210px 48px; align-items: center; gap: 6px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.voice-role-row select, .voice-role-row input { min-width: 0; width: 100%; min-height: 30px; }
.voice-role-row datalist { display: none; }
.voice-role-row select { padding-right: 28px; }
.speaker-slot-bindings { display: grid; gap: 8px; padding: 8px; }
.speaker-slot-bindings h3 { margin: 0 0 4px; }
.speaker-slot-row { display: grid; grid-template-columns: 80px 110px 90px minmax(140px, 1fr); align-items: center; gap: 8px; padding: 7px; border: 1px solid #d7e5ee; background: #fff; }
.line-load-more { width: calc(100% - 12px); margin: 8px 6px; }
.manual-role-references { display: grid; gap: 10px; padding: 8px; }
.manual-role-references h3 { margin: 0; }
.manual-role-card { border: 1px solid #d7e5ee; background: #fff; padding: 8px; }
.manual-role-card > div:first-child { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.manual-role-card em { margin-left: auto; font-style: normal; color: #64748b; }
.reference-candidates { display: grid; gap: 5px; }
.reference-candidates > div { display: grid; grid-template-columns: minmax(180px, 1fr) 110px 100px; align-items: center; gap: 6px; }
.reference-candidates span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-shortcut-help { margin-left: auto; color: #64748b; font-size: 12px; white-space: nowrap; }
.speed-badge { display:inline-block; margin-left:6px; padding:1px 5px; border-radius:9px; color:#087f5b; background:#d3f9d8; font-size:11px; font-weight:700; }
.speed-badge.warning { color:#b42318; background:#fee4e2; }
