:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #69756e;
  --line: #dfe6e1;
  --paper: #f4f7f3;
  --panel: #ffffff;
  --green: #1f6b4f;
  --green-dark: #154c38;
  --lime: #d8f06d;
  --danger: #b7352d;
  --danger-dark: #8e2822;
  --shadow: 0 20px 60px rgba(31, 57, 45, 0.08);
  --soft-green: #eff7f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 4% 0%, rgba(216, 240, 109, 0.28), transparent 28rem),
    radial-gradient(circle at 96% 18%, rgba(31, 107, 79, 0.07), transparent 25rem),
    var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

.shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 22px 0 80px; }

.app-bar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 74px;
  padding: 10px 14px;
  border: 1px solid rgba(203, 216, 208, .9);
  border-radius: 20px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 12px 36px rgba(31, 57, 45, .07);
  backdrop-filter: blur(16px);
}

.brand { display: flex; min-width: 0; align-items: center; gap: 11px; }
.brand-mark { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 12px; color: white; background: var(--ink); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.brand > span:last-child { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.brand strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: #89938d; font-size: 8px; font-weight: 800; letter-spacing: .12em; white-space: nowrap; }
.app-bar-note { justify-self: end; color: var(--muted); font-size: 12px; font-weight: 700; }

.mode-switcher {
  display: flex;
  width: fit-content;
  padding: 4px;
  border: 1px solid #d8e1db;
  border-radius: 13px;
  background: #f1f5f2;
}

.mode-tab {
  min-width: 140px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.mode-tab:hover { color: var(--green); background: #f3f8f4; }
.mode-tab:focus-visible, .button:focus-visible { outline: 3px solid rgba(31, 107, 79, .22); outline-offset: 2px; }
.mode-tab.active { color: white; background: var(--green); box-shadow: 0 6px 16px rgba(31,107,79,.2); }
.mode-tab:last-child.active { background: var(--danger); box-shadow: 0 6px 16px rgba(183,53,45,.18); }
.mode-tab > span { display: inline-grid; width: 20px; height: 20px; margin-right: 4px; place-items: center; border-radius: 6px; background: rgba(255,255,255,.14); font-size: 15px; }

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding: 46px 12px 30px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 { margin: 0; font-size: clamp(38px, 4.6vw, 62px); line-height: 1.04; letter-spacing: -0.055em; }
h2 { margin: 0; font-size: 22px; letter-spacing: -0.025em; }
.hero-copy { max-width: 700px; margin: 15px 0 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.hero-tags span { padding: 6px 9px; border: 1px solid #d9e4dc; border-radius: 8px; color: #546159; background: rgba(255,255,255,.62); font-size: 11px; font-weight: 700; }

.mode-badge {
  flex: 0 0 auto;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  color: var(--green);
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 8px 24px rgba(31,57,45,.05);
}

.mode-badge::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #8ba196; box-shadow: 0 0 0 3px rgba(139,161,150,.13); }
.mode-badge.live { color: var(--danger); border-color: #efc9c5; background: #fff8f7; }
.mode-badge.live::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(183,53,45,.12); }

.upload-panel, .material-panel, .results {
  border: 1px solid rgba(209, 220, 213, .9);
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}

.panel-heading > div { display: flex; align-items: center; gap: 12px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.step { display: grid; place-items: center; width: 36px; height: 28px; border-radius: 9px; background: var(--lime); font-size: 12px; font-weight: 850; box-shadow: inset 0 0 0 1px rgba(104,130,37,.08); }

.drop-zone {
  display: flex;
  min-height: 210px;
  margin: 26px;
  padding: 32px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 9px;
  border: 1.5px dashed #aebdb4;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfcfb, #f7faf7);
  cursor: pointer;
  transition: .18s ease;
}

.drop-zone:hover, .drop-zone.dragging { border-color: var(--green); background: #f3f9f4; transform: translateY(-1px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 5px; border-radius: 15px; background: var(--ink); color: white; font-size: 25px; font-weight: 300; box-shadow: 0 8px 20px rgba(23,33,29,.18); }
.drop-zone strong { font-size: 18px; }
.drop-zone span:last-child { color: var(--muted); font-size: 13px; }

.upload-actions { display: flex; align-items: center; gap: 18px; padding: 0 28px 28px; }
.delete-plan-entry { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 22px; align-items: center; margin: 24px 26px 0; padding: 18px 20px; border: 1px solid #d8e3dc; border-radius: 14px; background: var(--soft-green); }
.delete-plan-entry .field { width: min(100%, 380px); margin: 0; }
.plan-select-control { position: relative; z-index: 5; }
.plan-select-button { display: flex; width: 100%; height: 52px; padding: 0 16px; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid #cbd6cf; border-radius: 11px; color: var(--ink); background: white; font-size: 16px; font-weight: 800; text-align: left; cursor: pointer; }
.plan-select-button:focus, .plan-select-button[aria-expanded="true"] { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,79,.10); outline: none; }
.plan-select-arrow { flex: 0 0 auto; color: var(--muted); font-size: 20px; line-height: 1; transition: transform .16s ease; }
.plan-select-button[aria-expanded="true"] .plan-select-arrow { transform: rotate(180deg); }
.plan-select-menu { position: absolute; top: calc(100% + 8px); right: 0; left: 0; z-index: 20; padding: 6px; border: 1px solid #cbd6cf; border-radius: 12px; background: white; box-shadow: 0 16px 38px rgba(25,45,35,.20); }
.plan-select-menu[hidden] { display: none; }
.plan-select-option { display: flex; width: 100%; min-height: 48px; padding: 10px 12px; align-items: center; border: 0; border-radius: 8px; color: var(--ink); background: transparent; font-size: 16px; font-weight: 700; text-align: left; cursor: pointer; }
.plan-select-option:hover, .plan-select-option:focus { background: var(--soft-green); outline: none; }
.plan-select-option[aria-selected="true"] { color: var(--green); background: #e8f4ec; }
.delete-plan-entry p { margin: 0 0 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.button { min-height: 44px; padding: 0 20px; border: 0; border-radius: 11px; font-weight: 750; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.primary { background: var(--green); color: white; box-shadow: 0 8px 18px rgba(31,107,79,.16); }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.secondary { background: #edf1ee; color: var(--ink); }
.danger { background: var(--danger); color: white; }
.danger:hover:not(:disabled) { background: var(--danger-dark); }
.status-text { margin: 0; color: var(--muted); font-size: 13px; }
.status-text.error, .dialog-error { color: var(--danger); }

.results { margin-top: 26px; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.material-form { padding: 24px 26px 26px; }
.setup-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; color: #4f5d55; font-size: 13px; font-weight: 750; }
.field b { margin-left: 5px; color: var(--danger); font-size: 10px; }
.field em { margin-left: 5px; color: var(--muted); font-size: 11px; font-style: normal; font-weight: 500; }
.field select, .field input, .id-source textarea {
  width: 100%;
  border: 1px solid #cbd6cf;
  border-radius: 11px;
  color: var(--ink);
  background: white;
  outline: none;
}
.field select, .field input { height: 46px; padding: 0 14px; }
.field select:focus, .field input:focus, .id-source textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,79,.10); }
.video-picker-zone { display: flex; min-height: 190px; padding: 28px; align-items: center; justify-content: center; flex-direction: column; gap: 7px; border: 1.5px dashed #aebdb4; border-radius: 16px; background: linear-gradient(180deg, #fbfcfb, #f7faf7); text-align: center; }
.video-picker-zone strong { font-size: 18px; }
.video-picker-zone p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.video-picker-zone .file-picker-actions { width: min(100%, 480px); margin: 0; }
.source-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 4px; }
.id-source, .file-source { min-height: 298px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(180deg, #fbfcfb, #f8faf8); transition: border-color .18s ease, box-shadow .18s ease; }
.id-source:focus-within, .file-source:focus-within { border-color: #aec8b7; box-shadow: 0 0 0 4px rgba(31,107,79,.06); }
.id-source { display: flex; flex-direction: column; }
.file-source { display: flex; flex-direction: column; }
.source-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 15px; }
.source-heading i { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--green); background: #e9f4ed; font-size: 12px; font-style: normal; font-weight: 900; }
.source-heading > span { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.source-heading strong { color: var(--ink); font-size: 15px; }
.source-heading small { color: var(--muted); font-size: 11px; font-weight: 500; }
.id-source textarea { flex: 1; min-height: 180px; padding: 13px 14px; resize: vertical; line-height: 1.6; }
.id-source small { margin-top: 8px; color: var(--muted); font-weight: 500; }
.file-picker-actions { display: flex; gap: 10px; margin-bottom: 14px; }
.picker-button { display: inline-flex; width: auto; flex: 1; align-items: center; justify-content: center; border: 1px solid #dbe3de; }
.queue-empty { display: grid; min-height: 182px; padding: 20px; place-items: center; border: 1px dashed #b9c6be; border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.62); font-size: 13px; text-align: center; }
.queue-list-tools { display: flex; min-height: 34px; padding: 0 4px 8px; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.queue-list-tools label { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 750; cursor: pointer; }
.queue-list-tools small { color: var(--muted); font-size: 10px; }
.video-queue { flex: 1; max-height: 210px; margin: 0; padding: 0; overflow: auto; list-style: none; scrollbar-color: #c4cec8 transparent; scrollbar-width: thin; }
.video-queue li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 12px; transition: opacity .15s ease, background .15s ease; }
.video-queue li.excluded { opacity: .46; background: #f3f5f3; }
.video-queue .material-file-check { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.video-queue .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-queue .file-state { color: var(--muted); }
.video-queue .file-state.success { color: var(--green); font-weight: 750; }
.video-queue .file-state.error { color: var(--danger); font-weight: 750; }
.queue-summary { display: flex; min-height: 42px; margin-top: 10px; padding: 9px 12px; align-items: center; gap: 16px; border: 1px solid #d8e4dc; border-radius: 11px; color: var(--muted); background: var(--soft-green); font-size: 12px; }
.queue-summary strong { color: var(--ink); font-size: 13px; }
.queue-progress { margin-left: auto; padding-left: 16px; border-left: 1px solid #d2ddd6; color: var(--muted); font-weight: 750; }
.queue-progress.has-success { color: var(--green); }
.queue-progress.has-error { color: var(--danger); }
.queue-workspace { min-height: 0; padding: 22px 26px 0; border: 0; border-radius: 0; background: white; box-shadow: none; }
.queue-workspace:focus-within { border-color: transparent; box-shadow: none; }
.queue-workspace .video-queue { max-height: 360px; border-right: 1px solid #edf1ee; border-left: 1px solid #edf1ee; }
.queue-workspace .video-queue li { padding: 11px 12px; }
.queue-workspace .queue-list-tools { padding: 0 12px 10px; }
.queue-workspace .queue-summary { margin-top: 12px; }
.material-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 26px 26px; border-top: 1px solid #edf1ee; background: #fbfcfb; }
.material-actions > div { display: flex; gap: 10px; }
.material-result-summary { padding: 26px 28px; }
.material-result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.result-callout { padding: 20px; border: 1px solid #bfd7c8; border-radius: 14px; background: #eff8f2; }
.result-callout strong { display: block; margin-bottom: 7px; color: var(--green); font-size: 22px; }
.result-callout p { margin: 0; color: var(--muted); line-height: 1.7; }
.result-callout.pending { border-color: #cbd5e1; background: #f8fafc; }
.result-callout.pending strong { color: #475569; }
.result-callout.failed { border-color: #fecaca; background: #fef2f2; }
.result-callout.failed strong { color: #b91c1c; }
@media (max-width: 800px) {
  .material-result-grid { grid-template-columns: 1fr; }
}
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; padding: 24px 28px; }
.stat-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; transition: transform .16s ease, box-shadow .16s ease; }
.stat-card:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(31,57,45,.06); }
.stat-card span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 28px; letter-spacing: -0.04em; }
.stat-card.accent { border-color: #bed2c6; background: #eef8f1; }
.stat-card.accent strong { color: var(--green); }

.toolbar { display: flex; align-items: flex-end; gap: 14px; padding: 0 28px 20px; }
.search-box { flex: 1; display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; }
.search-box input, .confirm-input input { width: 100%; height: 44px; padding: 0 14px; border: 1px solid #cbd6cf; border-radius: 10px; color: var(--ink); background: white; outline: none; }
.search-box input:focus, .confirm-input input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,79,.10); }
.selection-summary { color: var(--muted); font-size: 13px; padding-bottom: 13px; }
.selection-summary strong { color: var(--ink); }

.table-wrap { position: relative; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 1080px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid #edf1ee; text-align: left; font-size: 13px; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: #f6f8f6; color: #55635b; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; }
tbody tr:hover { background: #fafcf9; }
tbody tr.deleted { opacity: .52; background: #f3f3f3; }
.checkbox-cell { width: 44px; text-align: center; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); }
.id-cell { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.exposure { font-weight: 800; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: #edf7ef; color: var(--green); font-size: 11px; font-weight: 750; }
.pill.deleted { background: #eee; color: #666; }
.empty-state { padding: 48px; color: var(--muted); text-align: center; }

.confirm-dialog { width: min(500px, calc(100% - 36px)); padding: 0; border: 0; border-radius: 20px; color: var(--ink); box-shadow: 0 30px 90px rgba(20,30,25,.32); }
.confirm-dialog::backdrop { background: rgba(18, 28, 23, .58); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 28px; }
.confirm-dialog h2 { margin-bottom: 12px; }
.confirm-dialog p { color: var(--muted); line-height: 1.6; }
.danger-text { color: var(--danger) !important; }
.confirm-input { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; color: var(--muted); font-size: 13px; }
.dialog-error { min-height: 20px; margin: 10px 0 0 !important; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

@media (max-width: 900px) {
  .shell { width: min(100% - 24px, 720px); padding-top: 30px; }
  .app-bar { grid-template-columns: 1fr auto; }
  .app-bar-note { display: none; }
  .hero, .panel-heading { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .source-grid { grid-template-columns: 1fr; }
  .delete-plan-entry { grid-template-columns: 1fr; align-items: stretch; }
  .setup-grid { grid-template-columns: 1fr; gap: 0; }
  .material-actions { align-items: stretch; flex-direction: column; }
  .selection-summary { padding: 0; }
  .button { width: 100%; }
  .picker-button { width: 100%; }
}

@media (max-width: 520px) {
  .shell { width: min(100% - 16px, 500px); }
  .app-bar { display: flex; padding: 10px; flex-direction: column; gap: 10px; border-radius: 16px; }
  .brand { width: 100%; }
  .brand-mark { width: 38px; height: 38px; }
  .mode-switcher { width: 100%; }
  .mode-tab { min-width: 0; flex: 1; padding: 0 12px; }
  .hero { padding: 30px 4px 24px; }
  .hero-copy { font-size: 14px; }
  .hero-tags { margin-top: 13px; }
  .panel-heading, .stats-grid, .toolbar, .material-form, .material-actions { padding-left: 18px; padding-right: 18px; }
  .drop-zone { margin: 18px; padding: 24px 16px; }
  .delete-plan-entry { margin: 18px 18px 0; padding: 16px; }
  .delete-plan-entry .field { width: 100%; }
  .upload-actions { padding: 0 18px 18px; flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .file-picker-actions, .material-actions > div { flex-direction: column; }
  .video-picker-zone { min-height: 220px; padding: 24px 16px; }
  .queue-workspace { padding: 18px 18px 0; }
  .queue-summary { flex-wrap: wrap; gap: 8px 14px; }
  .queue-progress { width: 100%; margin-left: 0; padding: 7px 0 0; border-top: 1px solid #d2ddd6; border-left: 0; }
}
