:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #18181b;
  --muted: #71717a;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "PingFang SC", sans-serif;
}
button, input { font: inherit; }
button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
button:hover { opacity: .88; }
button:disabled { opacity: .4; cursor: not-allowed; }
input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  outline: none;
}
input:focus { border-color: #93b4f5; box-shadow: 0 0 0 3px #2563eb12; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; padding: 12px; }
.eyebrow { display: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
h2 { margin-bottom: 0; font-size: 16px; }
h3 { margin-bottom: 0; font-size: 15px; }
.sidebar-head { padding: 18px 16px 16px; border-bottom: 1px solid var(--line); }
.sidebar-head h1 { font-size: 20px; }
.scan-control { display: flex; gap: 7px; width: 100%; margin-top: 15px; }
.scan-control input { min-width: 0; flex: 1; padding: 10px 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.workspace {
  height: calc(100vh - 24px);
  min-height: 620px;
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 12px;
}
.results-panel { display: flex; min-height: 0; flex-direction: column; }
.panel-head, .segments-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
.counter {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 14px;
  background: #f1f3f5;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-block: 1px solid var(--line);
}
.batch-bar label { color: var(--muted); }
.ghost { border-color: var(--line); background: white; color: #3f3f46; }
.danger { color: var(--danger); }
.retry-button { background: #18181b; }
.result-list { flex: 1; overflow-y: auto; padding: 6px; }
.result-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  padding: 11px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.result-item > div { min-width: 0; }
.result-item:hover { background: #f7f7f8; }
.result-item.active { border-color: #bfdbfe; background: var(--accent-soft); }
.result-item input { margin-top: 3px; accent-color: var(--accent); }
.result-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.result-group { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-time { color: #a1a1aa; font-size: 10px; white-space: nowrap; }
.result-url { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #22c55e; }
.dot.error { background: var(--danger); }
.dot.review { background: #f59e0b; }
.retry-mini {
  margin-top: 7px;
  padding: 3px 9px;
  border-color: #fecaca;
  background: white;
  color: var(--danger);
  font-size: 11px;
}
.retrying-label { display: inline-block; margin-top: 6px; color: var(--accent); font-size: 11px; }
.review-label { display: inline-block; margin-top: 6px; color: #b45309; font-size: 11px; }
.empty-state, .empty-detail { color: var(--muted); text-align: center; }
.empty-state { margin: auto; padding: 30px; }
.detail-panel { min-width: 0; overflow-y: auto; }
.empty-detail { height: 100%; display: grid; place-content: center; }
.empty-detail h2 { margin: 14px 0 5px; color: var(--text); }
.empty-icon { margin: auto; color: #a1a1aa; font-size: 20px; }
.detail-head {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.detail-title { min-width: 0; }
.detail-title h2 { display: inline; margin-left: 8px; }
.detail-link-row { display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: 6px; }
.detail-title a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.issue-copy { flex: 0 0 auto; padding: 3px 8px; color: var(--danger); font-size: 10px; }
.detail-actions { display: flex; gap: 8px; }
.badge { padding: 3px 7px; border-radius: 12px; background: #ecfdf3; color: #16803c; font-size: 11px; font-weight: 650; }
.badge.error { background: #fef2f2; color: var(--danger); }
.badge.review { background: #fffbeb; color: #b45309; }
.detail-panel > #detail { height: 100%; }
.media-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 330px; height: calc(100% - 82px); min-height: 0; }
.viewer-column { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.image-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 330px);
  min-height: 300px;
  overflow: hidden;
  border-radius: 9px;
  background: #111;
}
.image-stage img { width: 100%; height: 100%; object-fit: contain; transition: filter .2s ease; }
.image-stage.blurred img { filter: blur(26px) brightness(.65); transform: scale(1.04); }
.privacy-label {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 7px 11px;
  border-radius: 16px;
  background: #18181bcc;
  color: white;
  font-size: 12px;
  pointer-events: none;
}
.image-stage.blurred .privacy-label { display: block; }
.image-stage.no-image .privacy-label { display: none; }
.image-placeholder { color: #a1a1aa; }
.preview-loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; background: #111e; color: white; }
.preview-loading span { width: 22px; height: 22px; margin: auto; border: 3px solid #52525b; border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirm-bar {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: end;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.confirm-bar label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.time-input { display: flex; align-items: center; }
.time-input input { width: 82px; padding: 8px; }
.time-input span { margin-left: 6px; color: var(--muted); }
.confirm-copy { align-self: center; min-width: 0; }
.confirm-copy strong, .confirm-copy small { display: block; }
.confirm-copy small { margin-top: 2px; color: var(--muted); }
.meta-grid { display: grid; grid-template-columns: 180px 1fr; gap: 8px; margin-top: 10px; }
.meta-grid div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.meta-grid span, .meta-grid strong { display: block; }
.meta-grid span { margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.meta-grid strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 550 11px/1.4 ui-monospace, monospace; }
.segments-panel { display: flex; min-width: 0; min-height: 0; flex-direction: column; }
.segment-search { margin: 0 12px 9px; padding: 9px 10px; }
.segment-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 7px 9px; }
.segment-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 7px;
  border-bottom: 1px solid #f0f0f1;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 400;
}
.segment-item:hover { background: #f7f7f8; }
.segment-item.active { background: var(--accent-soft); color: var(--accent); }
.segment-item.previewing { background: #eff6ff; box-shadow: inset 2px 0 var(--accent); }
.segment-index { color: #a1a1aa; font: 500 10px/1 ui-monospace, monospace; }
.segment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 11px/1.3 ui-monospace, monospace; }
.segment-duration { color: var(--muted); font-size: 10px; }
.break-mark { color: #d97706; font-size: 9px; }
.break-mark.ad-mark { color: var(--danger); }
.segment-loading { margin: auto; padding: 30px; color: var(--muted); text-align: center; }
.progress { margin-top: 10px; padding: 9px 10px; border-radius: 7px; background: #f7f7f8; font-size: 11px; }
.progress > div:first-child { display: flex; justify-content: space-between; }
.track { height: 3px; margin-top: 7px; overflow: hidden; border-radius: 3px; background: #e5e7eb; }
.track i { display: block; width: 5%; height: 100%; background: var(--accent); transition: width .25s; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(500px, calc(100vw - 40px));
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18181b;
  color: white;
  box-shadow: 0 8px 25px #0002;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: #991b1b; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 270px minmax(0, 1fr); }
  .media-workspace { grid-template-columns: 1fr; }
  .detail-panel > #detail, .media-workspace { height: auto; }
  .viewer-column { border-right: 0; }
  .segments-panel { min-height: 420px; border-top: 1px solid var(--line); }
  .segment-list { max-height: 360px; }
}

@media (max-width: 700px) {
  .app-shell { padding: 12px; }
  .workspace { height: auto; grid-template-columns: 1fr; }
  .results-panel { max-height: 430px; }
  .detail-panel { min-height: 650px; }
  .detail-head { align-items: stretch; flex-direction: column; }
  .detail-actions { flex-wrap: wrap; }
  .detail-actions button { flex: 1; }
  .confirm-bar, .meta-grid { grid-template-columns: 1fr; }
  .image-stage { min-height: 210px; }
}
