:root {
  --ink: #18302c;
  --muted: #687873;
  --line: #d9e2de;
  --paper: #fffefa;
  --soft: #f1f5f2;
  --soft-strong: #e7eeea;
  --accent: #23765f;
  --accent-dark: #16523f;
  --accent-light: #dcefe8;
  --red: #b84841;
  --red-light: #fff0ed;
  --focus: #76bca5;
  --shadow: 0 18px 50px rgba(25, 54, 45, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: #edf1ee;
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}
button, input { font: inherit; }
button, label[for] { cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 48%, transparent);
  outline-offset: 2px;
}

.site-header {
  height: 68px;
  padding: 0 max(28px, calc((100vw - 1200px) / 2));
  background: rgba(255, 254, 250, .94);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 780;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand b {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  color: #fff;
  background: var(--accent);
  border-radius: 9px;
}
.privacy-note { display: flex; align-items: center; gap: 7px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }

.app-shell { max-width: 1200px; margin: auto; padding: 42px 28px 64px; }
.intro { max-width: 700px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .14em; }
.intro h1 { margin: 0; font: clamp(32px, 5vw, 50px)/1.16 Georgia, "Songti SC", serif; letter-spacing: -.04em; }
.intro > p:last-child { margin: 15px 0 0; color: var(--muted); font-size: 16px; line-height: 1.75; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; grid-template-areas: "video controls" "timeline controls" "records controls"; row-gap: 10px; column-gap: 12px; align-items: start; }
.video-panel {
  grid-area: video;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  background: #111a17;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
  isolation: isolate;
}
.empty-state {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 38px;
  color: #f8faf7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed transparent;
  transition: border-color .2s, background .2s;
}
.empty-state.drag-over { border-color: #6cc6a5; background: #1c2a25; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 16px; border: 1px solid #77837e; border-radius: 50%; font-size: 30px; }
.empty-state h2 { margin: 0; font-size: 21px; }
.empty-state p { max-width: 440px; margin: 9px 0 22px; color: #b5c0bb; }
.file-hint { margin-top: 13px; color: #8e9b95; font-size: 11px; }
.video-panel video { width: 100%; height: 100%; display: block; object-fit: contain; background: #060a08; }
.video-caption {
  position: absolute;
  z-index: 2;
  bottom: 64px;
  left: 0;
  right: 0;
  padding: 28px 18px 14px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  font-size: 12px;
}
.video-caption span:first-child { max-width: 70%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.playback-toolbar {
  position: absolute;
  z-index: 3;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 64px;
  padding: 10px 12px;
  color: #fff;
  background: #0d1512;
  display: flex;
  align-items: center;
  gap: 7px;
}
.player-button {
  min-width: 42px;
  padding: 8px 9px;
  color: #fff;
  border: 1px solid #4c5d56;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  white-space: nowrap;
}
.player-button:hover { background: #26362f; }
.player-button-main { min-width: 54px; background: var(--accent); border-color: var(--accent); }
.player-button.compact { min-width: 38px; padding-inline: 7px; }
.playback-toolbar input { min-width: 80px; flex: 1; accent-color: #55a889; }
#speed-display { min-width: 45px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }

.control-panel, .timeline-section, .records-section { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.control-panel { grid-area: controls; padding: 20px; align-self: start; position: sticky; top: 88px; margin-left: 0; }
.mode-switch { display: flex; gap: 3px; padding: 3px; margin: -4px 0 18px; background: var(--soft); border-radius: 9px; }
.mode-tab { flex: 1; padding: 8px 3px; color: var(--muted); border: 0; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 750; }
.mode-tab.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px #0002; }
.project-row, .behavior-row { display: grid; gap: 7px; margin-bottom: 18px; }
.project-row label, .behavior-row label, .dialog-field label { color: var(--muted); font-size: 12px; font-weight: 700; }
input[type="text"], input[type="number"] { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; outline: none; }
input[type="text"]:focus, input[type="number"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #23765f20; }
.draft-status { min-height: 16px; color: var(--muted); font-size: 10px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.metric { min-height: 82px; padding: 12px; background: var(--soft); border-radius: 10px; }
.metric span, .metric strong { display: block; }
.metric span { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.metric strong { font-size: 20px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.status-card { display: flex; gap: 10px; align-items: center; padding: 13px; margin-bottom: 18px; border: 1px solid #ead5d1; border-radius: 10px; background: #fff8f6; }
.status-card.in { border-color: #c5e1d7; background: #f4fbf7; }
.status-card.replay { border-color: #d5dfeb; background: #f4f7fb; }
.status-card i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--red); }
.status-card.in i { background: var(--accent); box-shadow: 0 0 0 5px #23765f22; }
.status-card.replay i { background: #5c78a0; box-shadow: 0 0 0 5px #5c78a022; }
.status-card small, .status-card strong { display: block; }
.status-card small { color: var(--muted); font-size: 11px; }
.status-card strong { margin-top: 2px; font-size: 15px; }
.record-button { width: 100%; padding: 15px 10px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 780; }
.record-button.active { background: var(--red); }
.record-button:disabled, .button:disabled { cursor: not-allowed; opacity: .45; }
.key { margin-right: 8px; padding: 3px 6px; border: 1px solid #ffffff59; border-radius: 4px; font-size: 11px; }
.shortcut-tip { margin: 9px 0 17px; color: var(--muted); text-align: center; font-size: 11px; }
.button-key { margin-left: 7px; padding: 1px 5px; background: var(--soft); color: var(--muted); font-size: 10px; line-height: 1.35; }
kbd { padding: 1px 4px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--soft); font-family: inherit; }
.actions, .file-actions, .replay-actions { display: flex; gap: 8px; }
.actions { margin-bottom: 9px; }
.file-actions { padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.button { min-height: 38px; padding: 8px 11px; border: 1px solid transparent; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: transparent; font-weight: 680; text-decoration: none; }
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { flex: 1; background: #fff; color: var(--ink); border-color: var(--line); }
.secondary:hover:not(:disabled) { background: var(--soft); }
.text-button { flex: 1; color: var(--muted); }
.text-button:hover:not(:disabled) { color: var(--red); background: var(--red-light); }
.wide { flex-basis: 100%; }
.import-button, .replace-video { flex: 1; }
.lights-button { width: 100%; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.shortcuts { margin-top: 12px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.shortcuts summary { cursor: pointer; font-weight: 750; }
.shortcuts p { margin: 7px 0; }
.replay-controls { margin-bottom: 18px; }
.selected-record-card { min-height: 86px; margin-bottom: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.selected-record-card small, .selected-record-card strong, .selected-record-card span { display: block; }
.selected-record-card small { color: var(--muted); font-size: 11px; }
.selected-record-card strong { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-record-card span { margin-top: 5px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.replay-actions .primary { flex: 1.35; }

.timeline-section, .records-section { padding: 21px 23px; min-width: 0; overflow: hidden; }
.timeline-section { grid-area: timeline; }
.records-section { grid-area: records; width: 100%; max-width: 100%; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.section-heading h2 { margin: 0; font: 23px Georgia, "Songti SC", serif; }
.section-heading > span { color: var(--muted); font-size: 12px; text-align: right; }
.timeline { width: 100%; max-width: 100%; height: 58px; position: relative; overflow: hidden; contain: layout paint; background: var(--soft-strong); border-radius: 8px; }
.timeline-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #87938e; font-size: 12px; pointer-events: none; }
.timeline-segments { position: absolute; inset: 0; width: 100%; max-width: 100%; overflow: hidden; contain: layout paint; }
.segment { position: absolute; top: 0; bottom: 0; min-width: 3px; border: 0; padding: 0; background: var(--accent); cursor: pointer; opacity: .9; box-shadow: inset -1px 0 rgba(255,255,255,.32); }
.segment:hover, .segment.selected { background: var(--accent-dark); opacity: 1; z-index: 1; }
.segment.selected { box-shadow: inset 0 0 0 3px rgba(255,255,255,.62); }
.live-segment { background: var(--red); }
.playhead { width: 2px; top: 0; bottom: 0; position: absolute; z-index: 3; background: #fff; box-shadow: 0 0 0 1px #0007; pointer-events: none; }
.timeline-scale { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; }
td { font-variant-numeric: tabular-nums; }
tbody tr:not(.no-records) { cursor: pointer; transition: background .15s; }
tbody tr:not(.no-records):hover { background: var(--soft); }
tbody tr.selected-row { background: var(--accent-light); }
.no-records td { padding: 38px 10px; color: var(--muted); text-align: center; }
.actions-column { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.jump-button, .play-row-button, .edit-button, .delete-button { padding: 5px 7px; border: 0; border-radius: 5px; background: transparent; color: var(--accent); font-weight: 680; }
.jump-button:hover, .play-row-button:hover, .edit-button:hover { background: var(--accent-light); }
.delete-button { color: var(--red); }
.delete-button:hover { background: var(--red-light); }

Dialog { color: var(--ink); }
dialog { width: min(450px, calc(100% - 32px)); padding: 0; color: var(--ink); border: 0; border-radius: 15px; box-shadow: 0 24px 70px #0004; }
dialog::backdrop { background: #13231e75; backdrop-filter: blur(2px); }
dialog form { padding: 25px; }
dialog h2 { margin: 0; font: 23px Georgia, "Songti SC", serif; }
dialog p { color: var(--muted); line-height: 1.65; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.danger { color: #fff; background: var(--red); }
.dialog-field { display: grid; gap: 7px; margin-top: 18px; }
.dialog-time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { margin-bottom: 0; padding: 9px 11px; color: var(--red); background: var(--red-light); border-radius: 7px; font-size: 12px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 26px; max-width: min(560px, calc(100% - 32px)); padding: 11px 15px; color: #fff; background: #18302c; border-radius: 8px; transform: translate(-50%, 90px); opacity: 0; transition: .2s; pointer-events: none; text-align: center; box-shadow: 0 10px 30px #0003; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

body.lights-off { background: #080d0b; }
body.lights-off .site-header, body.lights-off .intro, body.lights-off .control-panel, body.lights-off .timeline-section, body.lights-off .records-section { opacity: .12; transition: opacity .2s; }
body.lights-off .control-panel:hover, body.lights-off .control-panel:focus-within { opacity: .96; }
body.lights-off .video-panel { box-shadow: 0 0 0 1px #476057, 0 20px 70px #000c; }
body.lights-off .lights-button { color: #fff; background: #25342e; }

@media (max-width: 1080px) {
  .playback-toolbar { flex-wrap: wrap; }
  .playback-toolbar input { order: 10; flex-basis: 100%; }
  .video-caption { bottom: 106px; }
}
@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; grid-template-areas: "video" "controls" "timeline" "records"; row-gap: 14px; column-gap: 0; }
  .control-panel { position: static; }
  .site-header { padding: 0 18px; }
  .app-shell { padding: 32px 18px 50px; }
}
@media (max-width: 560px) {
  .site-header { height: 60px; }
  .privacy-note { display: none; }
  .app-shell { padding-inline: 12px; }
  .control-panel, .timeline-section, .records-section { padding: 16px; }
  .playback-toolbar { gap: 5px; padding: 8px; }
  .player-button { padding: 7px 6px; min-width: 37px; }
  #mute-button, #fullscreen-button { display: none; }
  .video-caption { bottom: 100px; }
  .section-heading { align-items: flex-start; }
  .dialog-time-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
.workspace > * { min-width: 0; }
.table-wrap { max-width: 100%; }
