:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --line: #d4dce6;
  --line-strong: #bcc8d6;
  --text: #102033;
  --muted: #61748a;
  --brand: #155eef;
  --brand-soft: #e7efff;
  --positive: #1f8f5f;
  --positive-soft: #e7f7ef;
  --danger: #c94848;
  --danger-soft: #fdeeee;
  --warning: #b7791f;
  --shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  --soft-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(21, 94, 239, 0.08), transparent 30%),
    radial-gradient(circle at top right, rgba(31, 143, 95, 0.07), transparent 28%),
    var(--bg);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea { font: inherit; }

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

button:hover { filter: brightness(0.98); }
button:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: 0.6; }

button.ghost { background: var(--brand-soft); color: var(--brand); }
button.secondary { background: #dce8ff; color: #1744a0; }
button.positive-btn { background: var(--positive); }
button.danger-btn { background: var(--danger); }
button.warning-btn { background: #fff1da; color: var(--warning); }

.compact-btn { padding: 8px 12px; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
}

textarea { min-height: 80px; resize: vertical; }

label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid rgba(21, 94, 239, 0.2);
  border-radius: 8px;
  background: #eef6ff;
  color: #123c70;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

label::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand), var(--positive));
}

h1, h2, h3 { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.section-head h2,
.stack-head h3,
.workflow-head h3,
.section-subhead h3,
.list-row-card h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #123c70;
  font-weight: 850;
  letter-spacing: 0;
}

.section-head h2::before,
.stack-head h3::before,
.workflow-head h3::before,
.section-subhead h3::before,
.list-row-card h2::before {
  content: "";
  width: 6px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--brand), var(--positive));
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.08);
}

.app-shell {
  width: 100%;
  max-width: 1820px;
  margin: 0 auto;
  padding: 16px;
}

.card,
.panel-card,
.video-shell-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card,
.panel-card { padding: 16px; }

.top-card {
  margin-bottom: 10px;
  padding: 14px 16px;
}

.section-head,
.stack-head,
.video-header,
.section-subhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.top-grid,
.upload-grid,
.notes-grid,
.workspace-grid,
.lists-stack {
  display: grid;
  gap: 14px;
}

.top-grid {
  grid-template-columns: minmax(0, 1.65fr) 300px;
  align-items: start;
}

.top-grid.workflow-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.top-main {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.upload-grid {
  grid-template-columns: 160px 190px minmax(200px, 0.65fr) minmax(230px, 0.8fr) minmax(280px, 1fr);
  align-items: end;
}

.url-field {
  min-width: 0;
}

.batch-url-input {
  min-height: 42px;
  max-height: 90px;
  line-height: 1.35;
}

.import-batch-summary {
  width: fit-content;
  max-width: 100%;
  padding: 6px 9px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.button-row,
.status-pills,
.chip-group,
.time-button-row,
.tab-row,
.history-row,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field,
.field-stack,
.workbench-section {
  display: grid;
  gap: 6px;
}

.history-card { padding: 6px 8px; }

.folder-toolbar,
.review-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.folder-tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.folder-create-group {
  flex: 0 1 300px;
}

.folder-selection-group {
  flex: 1 1 620px;
  justify-content: flex-end;
}

.folder-toolbar select,
.folder-toolbar input {
  min-width: 0;
}

.folder-selection-group select {
  flex: 1 1 190px;
  max-width: 280px;
}

.folder-create-group input {
  flex: 1 1 150px;
}

.toolbar-label,
.folder-summary {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.folder-summary {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-toolbar button,
.review-toolbar button {
  flex: 0 0 auto;
}

.folder-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(170px, 210px);
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 7px;
  scrollbar-width: thin;
}

.folder-card {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.folder-card:hover,
.folder-card.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.folder-card.drag-over {
  border-color: var(--positive);
  background: var(--positive-soft);
  box-shadow: inset 0 0 0 2px var(--positive);
}

.folder-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.folder-card-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.folder-card-head > span,
.folder-card-stats,
.folder-card-preview {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.folder-card-head > span {
  flex: 0 0 auto;
}

.folder-card-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-summary {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.review-queue {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 3px;
}

.review-item {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
}

.review-item strong {
  color: var(--text);
}

.task-meta,
.review-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.status-badge.failed,
.status-badge.rejected,
.status-badge.returned,
.status-badge.needs_rework {
  background: #fff1da;
  color: var(--warning);
}

.status-badge.completed,
.status-badge.teacher_reviewed {
  background: #e6f7ef;
  color: var(--positive);
}

.review-card {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  position: sticky;
  top: 16px;
}

.review-panel-head .title-help {
  margin-top: 4px;
  max-width: none;
  text-align: left;
}

.review-note-input {
  min-height: 54px;
  max-height: 110px;
  padding: 8px 9px;
  font-size: 12px;
  line-height: 1.4;
}

.review-item.highlighted {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand), var(--soft-shadow);
}

.settings-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.36);
}

.settings-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-wide {
  grid-column: 1 / -1;
}

.secret-input-row {
  display: flex;
  gap: 8px;
}

.secret-input-row input {
  flex: 1;
}

.secret-input-row button {
  flex: 0 0 auto;
}

.field small {
  color: var(--muted);
}
.workflow-card {
  position: relative;
  z-index: auto;
  min-width: 0;
  max-height: clamp(180px, 36vh, 320px);
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.workflow-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.workflow-details {
  justify-self: end;
  max-width: 100%;
}

.workflow-details[open] {
  grid-column: 1 / -1;
  justify-self: stretch;
}

.workflow-details[open] summary {
  width: fit-content;
  margin-left: auto;
}

.workflow-details:not([open]) .workflow-detail-grid {
  display: none;
}

.workflow-details summary {
  list-style: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.workflow-details summary::-webkit-details-marker { display: none; }

.workflow-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
  max-height: clamp(140px, 28vh, 240px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.workflow-step-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
}

.workflow-step-card strong {
  color: var(--text);
  font-size: 13px;
}

.workflow-step-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.step-badge {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.mini-diagram {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.mini-diagram span {
  padding: 5px 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--brand);
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.workflow-list {
  margin: 6px 0 0;
  padding-left: 18px;
  line-height: 1.38;
  color: var(--muted);
  font-size: 12px;
  max-height: 145px;
  overflow-y: auto;
}

.history-row,
.h-scroll-list {
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.history-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 188px);
  gap: 6px;
}

.history-item,
.list-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.history-item,
.list-card {
  padding: 10px;
  text-align: left;
  color: var(--text);
}

.history-item {
  padding: 22px 40px 6px 8px;
  min-height: 82px;
  max-height: 98px;
  overflow: hidden;
}

.history-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.history-item.selected {
  border-color: var(--positive);
  box-shadow: inset 0 0 0 1px var(--positive);
}

.video-select-checkbox {
  position: absolute;
  top: 5px;
  right: 27px;
  z-index: 2;
  width: 17px;
  height: 17px;
  margin: 0;
  padding: 0;
  accent-color: var(--positive);
  cursor: pointer;
}

.history-item.annotated {
  border-color: rgba(31, 143, 95, 0.42);
}

.video-badge {
  position: absolute;
  left: 7px;
  top: 5px;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: calc(100% - 50px);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
}

.video-badge.annotated {
  background: var(--positive-soft);
  color: var(--positive);
}

.video-badge.empty {
  background: #edf2f7;
  color: var(--muted);
}

.history-item.dragging,
.list-card.dragging {
  opacity: 0.55;
}

.history-item.drop-target,
.list-card.drop-target {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.history-item .meta,
.list-card .meta,
.feedback-inline,
.guidance-help,
pre {
  color: var(--muted);
}

.history-item .meta,
.list-card .meta {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.18;
}

.history-item > strong,
.list-card > strong {
  display: block;
  padding-right: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}

.history-item .meta,
.timeline-card .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-inline {
  min-width: 220px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  text-align: center;
  font-size: 13px;
}

.workspace-grid {
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 14px;
  align-items: start;
  margin-bottom: 10px;
}

.workspace-grid.review-active {
  grid-template-columns: minmax(0, 1fr);
}

.workspace-grid.review-active .main-stage {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  align-items: start;
}

.workspace-grid.review-active .video-card {
  grid-column: 1;
  grid-row: 1;
}

.workspace-grid.review-active .review-card {
  grid-column: 2;
  grid-row: 1;
}

.workspace-grid.review-active .guidance-card,
.workspace-grid.review-active .notes-card {
  grid-column: 1 / -1;
}

.workspace-grid.review-active .workbench-card {
  display: none;
}

.main-stage {
  display: grid;
  gap: 12px;
}

.guidance-card,
.notes-card {
  display: grid;
  gap: 7px;
}

.guidance-card .section-head {
  align-items: center;
}

.title-help {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.guidance-title-help {
  flex: 1;
  max-width: 760px;
  padding: 6px 8px;
  border-left: 3px solid var(--positive);
  border-radius: 8px;
  background: #f1fbf5;
  text-align: left;
}

.notes-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.compact-textarea { min-height: 64px; }

.workbench-card {
  padding: 14px;
}

.workbench-card .compact-textarea,
.guidance-card .compact-textarea,
.notes-card .compact-textarea {
  min-height: 54px;
}

.guidance-card .compact-textarea {
  min-height: 48px;
}

.workbench-section {
  gap: 5px;
}

.status-pills { margin-bottom: 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 13px;
}

.video-shell-card {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0c1727;
  border-radius: 8px;
  overflow: hidden;
}

video::-webkit-media-controls-timeline {
  min-height: 14px;
}

video::-webkit-media-controls-panel {
  min-height: 42px;
}

video,
.video-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.video-frame {
  border: 0;
  background: #0c1727;
}

.bilibili-control-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.bilibili-control-overlay span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.douyin-progress-guard {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  place-items: end center;
  height: 72px;
  padding: 0 12px 10px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, transparent, rgba(8, 18, 31, 0.74));
  color: #fff;
  cursor: not-allowed;
}

.douyin-progress-guard span {
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(8, 18, 31, 0.78);
  font-size: 12px;
  font-weight: 800;
}

.video-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 28px;
  color: #e8eef8;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(21, 94, 239, 0.24), transparent 45%),
    #0c1727;
}

.video-fallback p {
  max-width: 520px;
  margin: 0;
  color: #aab7c8;
  line-height: 1.6;
}

.embed-click-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 180px;
  height: 44px;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.embed-click-layer span {
  opacity: 0.74;
  padding: 9px 14px;
  border-radius: 8px;
  background: rgba(8, 18, 31, 0.72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  transition: opacity 0.16s ease;
}

.embed-click-layer:hover span,
.embed-click-layer:focus-visible span {
  opacity: 1;
}

.video-scrubber {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.video-scrubber input[type="range"] {
  height: 18px;
  padding: 0;
  border: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.video-scrubber input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 8px;
  background: #d4e3ff;
}

.video-scrubber input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -5px;
}

.scrubber-time {
  min-width: 72px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.video-overlay-toolbar { display: none; }

.embed-time-panel {
  display: grid;
  grid-template-columns: auto auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 8px;
  border: 1px solid #f5b8b8;
  border-left: 4px solid #c1121f;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--ink);
}

.embed-time-panel span {
  color: var(--muted);
  font-size: 12px;
}

.embed-time-panel strong {
  min-width: 74px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.embed-time-panel .compact-btn {
  padding: 4px 8px;
  font-size: 12px;
}

.embed-time-hint {
  min-width: 0;
  color: #c1121f !important;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  padding: 9px 12px;
  font-weight: 700;
  box-shadow: none;
}

.tab-btn.active {
  border-color: transparent;
  border-bottom-color: var(--brand);
  color: var(--brand);
}

.tab-btn.positive-tab.active {
  background: linear-gradient(180deg, rgba(31, 143, 95, 0.08), transparent 70%);
  border-bottom-color: var(--positive);
  color: var(--positive);
}

.tab-btn.negative-tab.active {
  background: linear-gradient(180deg, rgba(201, 72, 72, 0.08), transparent 70%);
  border-bottom-color: var(--danger);
  color: var(--danger);
}

.scope-tab.active {
  background: linear-gradient(180deg, rgba(21, 94, 239, 0.08), transparent 70%);
}

.divider-top {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.time-input-row,
.inline-input {
  display: flex;
  gap: 8px;
}

.time-input-row input,
.inline-input input { flex: 1; }

.range-label,
.guidance-help {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-soft);
  font-size: 13px;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.chip:hover { border-color: var(--brand); }

.chip.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.chip.positive.active {
  border-color: var(--positive);
  color: var(--positive);
  background: var(--positive-soft);
}

.chip.negative.active {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.kv-grid {
  display: grid;
  gap: 8px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.hidden { display: none !important; }

.layout-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: var(--soft-shadow);
}

.layout-window-toolbar,
.layout-resize-handle {
  display: none;
}

body.free-layout-mode .app-shell {
  position: relative;
}

body.free-layout-mode .layout-window {
  max-width: none;
  max-height: none;
  overflow: auto;
  resize: none;
}

body.free-layout-mode .top-main.layout-window,
body.free-layout-mode .lists-stack.layout-window {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

body.free-layout-mode .layout-window-toolbar {
  position: sticky;
  top: -1px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  margin: -4px -4px 10px;
  padding: 6px 8px;
  border: 1px solid rgba(21, 94, 239, 0.16);
  border-radius: 8px;
  background: rgba(247, 250, 252, 0.96);
  color: #123c70;
  font-size: 12px;
  font-weight: 850;
  cursor: grab;
  user-select: none;
}

body.free-layout-mode .layout-window-toolbar:active {
  cursor: grabbing;
}

body.free-layout-mode .layout-window-reset {
  padding: 5px 8px;
  font-size: 12px;
}

body.free-layout-mode .layout-resize-handle {
  position: absolute;
  right: -32px;
  bottom: -32px;
  z-index: 6;
  display: block;
  width: 64px;
  height: 64px;
  border-right: 3px solid rgba(21, 94, 239, 0.7);
  border-bottom: 3px solid rgba(21, 94, 239, 0.7);
  border-radius: 0 0 6px 0;
  background: linear-gradient(135deg, transparent 48%, rgba(21, 94, 239, 0.12) 49%);
  cursor: nwse-resize;
}

body.free-layout-mode .layout-window-active {
  outline: 2px solid rgba(21, 94, 239, 0.34);
  outline-offset: 2px;
}

pre {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 12px;
}

.lists-stack {
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
  width: 100%;
}

.compact-timelines {
  grid-template-columns: 1fr;
  min-width: 0;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.list-row-card {
  position: relative;
  z-index: 1;
  overflow: visible;
  padding: 8px 10px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.list-row-card:hover,
.list-row-card:focus-within {
  z-index: 80;
}

.list-row-card .section-head {
  margin-bottom: 2px;
}

.list-row-card h2 {
  font-size: 15px;
}

.h-scroll-list:not(.timeline-list) {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 340px);
  gap: 12px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.timeline-list {
  overflow-x: auto;
  overflow-y: visible;
  padding: 2px 0 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.timeline-track {
  position: relative;
  min-width: 100%;
  height: 86px;
  padding: 16px 4px 4px;
}

.timeline-axis {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 14px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--positive));
  opacity: 0.38;
}

.timeline-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.timeline-tick.first {
  transform: translateX(0);
}

.timeline-tick.last {
  transform: translateX(-100%);
}

.timeline-card {
  position: absolute;
  top: 24px;
  width: 118px;
  min-width: 118px;
  min-height: 32px;
  max-height: 36px;
  overflow: hidden;
  box-shadow: var(--soft-shadow);
  padding: 5px 20px 5px 7px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, max-height 0.16s ease;
  z-index: 1;
}

.queue-list .queue-list-card {
  min-height: 54px;
  max-height: 76px;
  overflow: hidden;
  padding-right: 24px;
}

.timeline-card:hover,
.timeline-card:focus,
.timeline-card:focus-within,
.timeline-card.raised {
  z-index: 30;
  max-height: none;
  overflow: visible;
  transform: translateY(-6px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
}

.timeline-card > .timeline-compact-label {
  display: inline-block;
  max-width: calc(100% - 14px);
  padding-right: 0;
  vertical-align: middle;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.timeline-ellipsis {
  display: inline-block;
  margin-left: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  vertical-align: middle;
}

.timeline-card-details {
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  z-index: 60;
  display: none;
  min-width: 210px;
  max-width: 300px;
  gap: 3px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
}

.timeline-card.detail-align-right .timeline-card-details {
  left: auto;
  right: 0;
}

.timeline-card:hover .timeline-card-details,
.timeline-card:focus .timeline-card-details,
.timeline-card:focus-within .timeline-card-details,
.timeline-card.raised .timeline-card-details {
  display: grid;
}

.timeline-detail-title {
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
}

.timeline-card-details .meta {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.timeline-card.stacked {
  transform: translate(calc(var(--stack-index) * 5px), calc(var(--stack-index) * 3px));
  z-index: calc(4 + var(--stack-index));
}

.timeline-card.stack-layer-1 { background: #f6fbff; }
.timeline-card.stack-layer-2 { background: #f7fff9; }

.timeline-card.stacked.stack-open {
  z-index: calc(40 + var(--stack-index));
  transform: translateY(calc(-6px + var(--stack-index) * 40px));
}

.timeline-card.stacked:hover,
.timeline-card.stacked:focus,
.timeline-card.stacked:focus-within,
.timeline-card.stacked.raised {
  z-index: 90;
}

.timeline-card::before {
  content: "";
  position: absolute;
  left: 12px;
  top: -12px;
  width: 2px;
  height: 12px;
  background: var(--brand);
}

.list-card.positive { border-color: rgba(31, 143, 95, 0.35); }
.list-card.negative { border-color: rgba(201, 72, 72, 0.35); }

.card-actions {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  margin-top: 0;
  z-index: 2;
}

.card-actions button {
  cursor: pointer;
}

.mini-action {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
}

.empty-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
}

.history-row .empty-state,
.timeline-list .empty-state {
  min-height: 50px;
  padding: 8px 10px;
  font-size: 12px;
}

.timeline-list .empty-state {
  width: 100%;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 1000;
}

.toast {
  min-width: 240px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.success { background: var(--positive); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--brand); }

#videoFullscreenShell:fullscreen {
  width: 100%;
  height: 100%;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: #08121f;
  box-shadow: none;
}

#videoFullscreenShell:fullscreen .video-wrap {
  height: calc(100vh - 24px);
  aspect-ratio: auto;
}

#videoFullscreenShell:fullscreen .video-overlay-toolbar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(8, 18, 31, 0.78);
  backdrop-filter: blur(12px);
}

@media (max-width: 1440px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 390px; }
  .notes-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1360px), (max-height: 760px) {
  .top-grid {
    grid-template-columns: 1fr;
  }

  .workflow-card {
    max-height: 220px;
  }

  .workflow-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 4px 18px;
    max-height: 92px;
  }

  .workflow-detail-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    max-height: 160px;
  }
}

@media (max-width: 1200px) {
  .top-grid,
  .upload-grid,
  .workspace-grid,
  .notes-grid,
  .compact-timelines {
    grid-template-columns: 1fr;
  }

  .time-input-row,
  .inline-input {
    flex-direction: column;
  }

  .workflow-detail-grid {
    left: auto;
    right: 0;
  }

  .workspace-grid.review-active .main-stage {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-grid.review-active .video-card {
    grid-column: 1;
    grid-row: 1;
  }

  .workspace-grid.review-active .review-card {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    top: auto;
    max-height: min(620px, calc(100vh - 24px));
  }
}

@media (max-width: 820px) {
  .app-shell { padding: 12px; }

  .section-head,
  .stack-head,
  .video-header,
  .section-subhead {
    flex-direction: column;
  }

  .button-row,
  .status-pills,
  .tab-row,
  .time-button-row,
  .inline-actions {
    flex-direction: column;
  }

  .folder-toolbar,
  .folder-tool-group {
    align-items: stretch;
  }

  .folder-tool-group {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }

  .folder-selection-group select,
  .folder-create-group input {
    flex-basis: 100%;
    max-width: none;
  }

  .folder-summary {
    max-width: none;
    width: 100%;
  }

  .folder-board {
    grid-auto-columns: minmax(170px, 72vw);
  }

  .history-row,
  .h-scroll-list {
    grid-auto-columns: minmax(220px, 84vw);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .guidance-title-help {
    max-width: none;
    width: 100%;
  }

  .workflow-detail-grid {
    left: 0;
    right: auto;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .embed-time-panel {
    grid-template-columns: auto auto auto auto;
  }

  .embed-time-hint {
    grid-column: 1 / -1;
  }
}

/* Team workspace, review-state layer and AI reference timeline. */
.auth-pending { visibility: hidden; }

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 15% 15%, rgba(21, 94, 239, 0.22), transparent 34%),
    radial-gradient(circle at 85% 80%, rgba(31, 143, 95, 0.2), transparent 32%),
    #e8eef5;
}

.login-overlay.hidden { display: none; }

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid rgba(21, 94, 239, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
}

.login-card h1 { font-size: 25px; }
.login-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.login-kicker { color: var(--brand); font-size: 12px; font-weight: 900; letter-spacing: 0.12em; }
.login-error { min-height: 20px; color: var(--danger) !important; font-weight: 700; }

.account-feedback-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.user-badge {
  padding: 7px 10px;
  border: 1px solid rgba(31, 143, 95, 0.25);
  border-radius: 999px;
  color: #176b49;
  background: var(--positive-soft);
  font-size: 12px;
  font-weight: 850;
}

.review-status-layer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  padding: 9px 10px;
  border: 1px solid rgba(21, 94, 239, 0.16);
  border-radius: 8px;
  background: #f6f9ff;
}

.layer-label { color: #123c70; font-size: 12px; font-weight: 900; white-space: nowrap; }
.status-folder-board { display: flex; gap: 7px; overflow-x: auto; }
.status-folder {
  padding: 7px 10px;
  color: #36506f;
  background: #fff;
  border: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12px;
}
.status-folder.active { color: #fff; background: var(--brand); border-color: var(--brand); }

.video-badge.reviewed { color: #176b49; background: var(--positive-soft); }
.video-badge.unreviewed { color: #1744a0; background: var(--brand-soft); }
.video-badge.returned { color: #9a3412; background: #fff0e7; }
.video-badge.unannotated { color: var(--muted); background: #edf2f7; }
.history-item.review-returned { border-color: rgba(201, 72, 72, 0.55); box-shadow: 0 8px 20px rgba(201, 72, 72, 0.1); }
.returned-video-note {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  color: #9a3412;
  background: #fff5ef;
  font-size: 11px;
  line-height: 1.45;
}
.compact-select { width: auto; max-width: 170px; padding: 4px 6px; font-size: 11px; }

.return-notice {
  display: grid;
  gap: 7px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid rgba(201, 72, 72, 0.32);
  border-radius: 8px;
  color: #7f1d1d;
  background: #fff5f5;
}
.return-notice.hidden { display: none; }
.return-item-list { display: flex; gap: 7px; overflow-x: auto; }
.return-item-button {
  min-width: 220px;
  max-width: 420px;
  padding: 8px 10px;
  color: #7f1d1d;
  background: #fff;
  border: 1px solid rgba(201, 72, 72, 0.25);
  text-align: left;
  font-size: 12px;
}

.review-ratio-control,
.compact-check {
  display: inline-flex;
  gap: 5px;
  padding: 5px 8px;
  background: #fff;
  white-space: nowrap;
}
.review-ratio-control::before,
.compact-check::before { display: none; }
.review-ratio-control input { width: 62px; padding: 5px 7px; }
.compact-check input { width: auto; }

.ai-timeline-panel {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: 8px;
  background: #faf8ff;
}
.ai-timeline-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.ai-timeline-head > div:first-child { display: grid; gap: 2px; }
.ai-timeline-head strong { color: #5b21b6; }
.ai-timeline-head span { color: var(--muted); font-size: 11px; }
.ai-json-file { width: min(260px, 34vw); padding: 6px; font-size: 11px; }
.ai-timeline { min-height: 62px; }
.ai-timeline .empty-state { width: 100%; min-height: 54px; }
.ai-marker-track {
  position: relative;
  height: 58px;
  margin: 4px 10px 0;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(124, 58, 237, 0.08), rgba(21, 94, 239, 0.08)),
    repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 1px), rgba(97, 116, 138, 0.16) 25%);
}
.ai-marker-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 28px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c3aed, #155eef);
}
.ai-time-marker {
  position: absolute;
  top: calc(19px - var(--marker-lane) * 5px);
  z-index: 2;
  width: 15px;
  height: 24px;
  padding: 0;
  transform: translateX(-50%);
  border: 2px solid #fff;
  border-radius: 8px 8px 4px 4px;
  background: #7c3aed;
  box-shadow: 0 3px 9px rgba(91, 33, 182, 0.3);
}
.ai-time-marker.active { width: 19px; height: 29px; top: 15px; background: #e11d48; }
.ai-axis-label { position: absolute; bottom: -2px; color: var(--muted); font-size: 10px; }
.ai-axis-label.start { left: 0; }
.ai-axis-label.end { right: 0; }
.ai-annotation-detail {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-left: 4px solid #7c3aed;
  border-radius: 6px;
  background: #fff;
}
.ai-annotation-detail.hidden { display: none; }
.ai-annotation-detail p { margin: 0; color: #394b63; font-size: 12px; line-height: 1.5; }

@media (max-width: 820px) {
  .account-feedback-row,
  .ai-timeline-head { align-items: stretch; flex-direction: column; }
  .review-status-layer { align-items: flex-start; flex-direction: column; }
  .ai-json-file { width: 100%; }
  .return-item-button { min-width: 78vw; }
}
