@font-face {
  font-family: "Source Han Sans SC";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("/fonts/NotoSansSC-Heavy-Latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Han Sans SC";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("/fonts/NotoSansSC-Heavy-CN.woff2") format("woff2");
  unicode-range: U+3000-303F, U+3040-309F, U+30A0-30FF, U+3100-312F, U+3200-32FF, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE10-FE1F, U+FE30-FE4F, U+FF00-FFEF;
}

:root {
  --bg: #f5f5f5;
  --panel: #fafafa;
  --card: #ffffff;
  --line: #ebebeb;
  --text: #0a0a0a;
  --muted: #666666;
  --dim: #888888;
  --pink: #e24b6a;
  --pink-soft: #ffe4ea;
  --yellow: #e8b031;
  --yellow-deep: #c99614;
  --yellow-soft: #fff4cc;
  --green: #1f9d55;
  --green-deep: #178246;
  --clip: #e8b031;
  --clip-off: #f3e2a8;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --r: 10px;
  --sans: "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

svg { width: 22px; height: 22px; display: block; }

#app {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 160px;
  grid-template-columns: minmax(0, 1fr);
}

.top {
  position: relative;
  z-index: 6;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 22px; height: 22px;
  background: var(--pink);
  border-radius: 6px;
}
.brand-name {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand strong {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #111;
}
.brand .slogan {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.brand em {
  display: block;
  font-style: normal;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
}

.pills {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  height: 40px;
  padding: 0 16px;
  border: 1px solid #e5e5e5;
  background: #fff;
  color: #171717;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  transition: transform 140ms var(--ease), background 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.pill svg { width: 16px; height: 16px; }
.pill:hover { background: #fafafa; }
.pill:active { transform: scale(0.98); }
.pill:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.pill.on {
  background: #fff;
  border-color: var(--clip);
  color: #171717;
  box-shadow: 0 0 0 1px var(--clip);
}
.pill.solid {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.pill.solid:hover { background: var(--green-deep); }

.fps-pill {
  height: 40px;
  padding: 0 4px 0 14px;
  border: 1px solid #e5e5e5;
  background: #fff;
  color: #171717;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.fps-pill input {
  width: 52px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #171717;
  text-align: center;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.fps-pill input::-webkit-outer-spin-button,
.fps-pill input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.fps-pill em {
  display: grid;
  place-items: center;
  height: 32px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: #3d2e00;
  font-style: normal;
  font-size: 13px;
  font-weight: 900;
}

.export-wrap { position: relative; }
.export-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 196px;
  padding: 6px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.12);
  z-index: 20;
}
.export-menu button {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #171717;
  text-align: left;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.export-menu button:hover { background: var(--pink-soft); }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.viewer {
  position: relative;
  background: var(--bg);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}
.drop {
  margin: 28px;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  border: 2px dashed #cfcfcf;
  border-radius: 16px;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px;
  cursor: pointer;
  background: #f3f3f3;
}
.drop:hover { border-color: #171717; }
.drop-kicker { margin: 0; color: #171717; font-size: 14px; font-weight: 900; }
.drop-title { margin: 10px 0 12px; font-size: 32px; font-weight: 900; color: #111; }
.drop-hint { margin: 0; max-width: 28em; color: var(--muted); font-size: 16px; }

.player {
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 56px;
  padding: 16px 16px 0;
}
.frame {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #111;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.12);
}
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #111;
}
.frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.frame.draw canvas { pointer-events: auto; cursor: crosshair; }
.region-hint {
  position: absolute; left: 16px; bottom: 14px;
  margin: 0;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 4px rgb(0 0 0 / 0.6);
  pointer-events: none;
}
.video-error {
  position: absolute; inset: 0;
  margin: 0;
  display: grid; place-items: center;
  padding: 24px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  background: rgb(0 0 0 / 0.55);
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}
.play-btn {
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 140ms var(--ease);
}
.play-btn:active { transform: scale(0.96); }
.play-btn svg { width: 22px; height: 22px; }
.play-btn .ico-pause { display: none; }
.play-btn.playing .ico-play { display: none; }
.play-btn.playing .ico-pause { display: block; }
.tc {
  font-family: var(--mono);
  font-size: 15px;
  color: #222;
  font-weight: 500;
}
.tc.dim { color: var(--dim); }
.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}
.vol-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #222;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.vol-btn svg { width: 22px; height: 22px; }
.vol-btn .ico-mute { display: none; }
.vol-btn.muted .ico-vol { display: none; }
.vol-btn.muted .ico-mute { display: block; }
#vol-range {
  width: 92px;
  accent-color: var(--clip);
}
.spacer { flex: 1; }
.meta { color: var(--muted); font-size: 14px; }

.busy {
  position: absolute; inset: 0;
  background: rgb(236 236 236 / 0.86);
  display: grid; place-content: center; gap: 14px;
}
.busy-bar {
  width: min(420px, 70vw); height: 4px; background: #ddd; border-radius: 4px;
}
.busy-bar i {
  display: block; height: 100%; width: 0%;
  background: var(--green);
  border-radius: 4px;
}
.busy p { margin: 0; text-align: center; color: var(--muted); font-size: 16px; }
.busy-stop {
  height: 36px;
  padding: 0 18px;
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  background: #fff;
  color: #171717;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}
.busy-stop:hover { background: #fff5f7; border-color: var(--pink); color: var(--pink); }
.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 14px;
  color: #525252;
  cursor: pointer;
  user-select: none;
}
.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
}

.side {
  border-left: 1px solid var(--line);
  background: var(--card);
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; height: 52px; border: 0; background: transparent;
  color: var(--dim); cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 500;
}
.tab.on {
  color: #111;
  box-shadow: inset 0 -3px 0 var(--clip);
}
.tab-body {
  display: none;
  padding: 14px;
  min-height: 0;
}
.tab-body.on {
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  padding-bottom: 8px;
}
.search-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  color: #111;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.btn-apply {
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--yellow);
  color: #3d2e00;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
.btn-apply:hover { background: var(--yellow-deep); color: #fff; }
.btn-apply:active { transform: scale(0.98); }
.btn-apply.wide { width: 100%; margin-top: 4px; }
.select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
  color: #525252;
  cursor: pointer;
  user-select: none;
}
.select-all input {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
}
.side-empty { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 8px 4px; }

.clip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.clip-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  position: relative;
}
.clip-item.on { border-color: var(--pink); background: #fff5f7; }
.clip-item.tone-red { border-left: 4px solid #e24b6a; }
.clip-item.tone-yellow { border-left: 4px solid #e8b031; }
.clip-item.tone-blue { border-left: 4px solid #3b82c4; }
.clip-item.tone-green { border-left: 4px solid #1f9d55; }
.color-picks {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease);
}
.clip-item:hover .color-picks {
  opacity: 1;
  pointer-events: auto;
}
.color-dot {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.18);
  cursor: pointer;
}
.color-dot.on { box-shadow: 0 0 0 2px #171717; }
.color-dot.none {
  background: #fff;
  position: relative;
}
.color-dot.none::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  background: #bbb;
  transform: rotate(-45deg);
}
.chip.color-chip { font-size: 12px; }
.clip-item.off { opacity: 0.5; }
.clip-item input {
  margin-top: 4px;
  width: 18px; height: 18px;
  accent-color: var(--pink);
}
.clip-time {
  font-family: var(--mono);
  font-size: 13px;
  color: #171717;
  font-weight: 900;
}
.clip-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; cursor: text; }
.chip {
  font-size: 14px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: #b4233d;
}
.clip-edit {
  display: block;
  width: 100%;
  min-height: 72px;
  margin-top: 6px;
  border: 1px solid var(--yellow);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.45;
  color: #111;
  background: var(--yellow-soft);
  resize: vertical;
  outline: none;
}
.clip-join {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 22px;
  margin: -6px 0;
  z-index: 1;
}
.join-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #ead89a;
  background: #fff;
  color: #8a6a10;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.86);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease), background 140ms var(--ease);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.08);
}
.join-btn svg { width: 16px; height: 16px; }
.clip-join:hover .join-btn,
.clip-item:hover + .clip-join .join-btn,
.clip-join:has(+ .clip-item:hover) .join-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.join-btn:hover { background: var(--yellow); color: #3d2e00; }

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 14px;
}
.field > span:first-child { color: #525252; }
.field-pill {
  display: inline-flex;
  align-items: stretch;
  height: 40px;
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.field-pill input {
  width: 72px;
  border: 0;
  background: transparent;
  color: #171717;
  text-align: center;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  padding: 0 4px;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.field-pill input::-webkit-outer-spin-button,
.field-pill input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-pill em {
  display: grid;
  place-items: center;
  min-width: 46px;
  padding: 0 14px;
  background: var(--yellow);
  color: #3d2e00;
  font-style: normal;
  font-size: 13px;
  font-weight: 900;
}
.fine { color: var(--muted); font-size: 14px; line-height: 1.55; }
.region-readout {
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}

.timeline {
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px;
  min-height: 0;
  overflow: hidden;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}
.tl-tools {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.tl-tools button {
  width: 32px;
  height: 32px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  background: #fff;
  color: #171717;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.tl-tools button:hover { background: var(--yellow-soft); }
.tl-tools button:disabled { opacity: 0.35; cursor: not-allowed; }
.tl-tools svg { width: 16px; height: 16px; }
.tl-scroll {
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}
.tl-scroll::-webkit-scrollbar { height: 8px; }
.tl-scroll::-webkit-scrollbar-thumb {
  background: #d8c48a;
  border-radius: 8px;
}
.tl-track {
  position: relative;
  height: 100%;
  min-width: 100%;
  background: #f4ecee;
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
}
.tl-ticks { position: absolute; inset: 0; pointer-events: none; }
.tl-tick {
  position: absolute; top: 0; bottom: 0; width: 1px; background: #ddd;
}
.tl-tick span {
  position: absolute; top: 6px; left: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.tl-segs { position: absolute; inset: 28px 0 10px; }
.seg {
  position: absolute; top: 0; bottom: 0;
  background: var(--clip);
  border-radius: 6px;
  cursor: pointer;
  color: #3d2e00;
}
.seg.off { background: var(--clip-off); color: #7a6a30; }
.seg.sel { outline: 2px solid #fff; outline-offset: 1px; box-shadow: 0 0 0 2px var(--yellow-deep); }
.seg .h {
  position: absolute; top: 0; bottom: 0; width: 10px;
  cursor: ew-resize; background: rgb(0 0 0 / 0.12);
}
.seg .h.l { left: 0; border-radius: 6px 0 0 6px; }
.seg .h.r { right: 0; border-radius: 0 6px 6px 0; }
.seg .lab {
  position: absolute; left: 12px; top: 8px; right: 12px;
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden;
  pointer-events: none;
}
.tl-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #171717;
  left: 0;
  z-index: 6;
  pointer-events: none;
  box-shadow: 0 0 0 1px #fff;
}
.tl-playhead::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: #171717;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
}
.tl-playhead::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 11px solid #171717;
  filter: drop-shadow(0 0 0 1px #fff);
}

.region-pop {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}
.region-pop.placing { visibility: hidden; }
.region-pop-actions { display: flex; gap: 6px; position: relative; z-index: 1; }
.region-pop .crop-preview {
  position: relative;
  inset: auto;
  display: block;
  width: auto;
  height: auto;
  max-width: 200px;
  pointer-events: none;
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.28);
  background: #111;
}
.region-pop button {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid #e5e5e5;
  background: #fff;
  color: #171717;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.16);
}
.region-pop button.go {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.region-pop button:hover { filter: brightness(0.97); }

@media (max-width: 900px) {
  #app { grid-template-rows: 64px minmax(0, 1fr) 140px; }
  .stage { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 200px; }
  .side { border-left: 0; border-top: 1px solid var(--line); min-height: 0; }
  .top { grid-template-columns: 1fr; }
  .pills { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (hover: hover) and (pointer: fine) {
  .clip-item:hover { border-color: #bbb; }
}
