:root {
  --bg: #f6f8fb;
  --surface: #fff;
  --border: #e4e8ef;
  --text: #1a2233;
  --muted: #6b7485;
  --accent: #2b69b4;
  --accent-dark: #225592;
  --accent-soft: #eaf1f9;
  --danger: #cf3a45;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 34, 51, .05), 0 6px 20px rgba(26, 34, 51, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f3f5f9; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 0 10px; }
.btn.ghost:hover { background: #eef1f6; color: var(--text); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

.input, textarea.input, select.input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); outline: none;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; padding: 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.login-card img { height: 40px; display: block; margin-bottom: 24px; }
.login-card h1 { font-size: 18px; margin: 0 0 16px; font-weight: 650; }
.login-card .input { margin-bottom: 12px; }
.login-card .code { font-size: 22px; letter-spacing: 8px; text-align: center; height: 48px; font-weight: 600; }
.login-card .hint { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; }

/* shell */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar img { height: 32px; display: block; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.page { max-width: 1200px; margin: 0 auto; padding: 24px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 380px; }
.toolbar select.input { width: auto; padding-right: 28px; }
.toolbar .count { color: var(--muted); font-size: 13px; margin-left: auto; }
.seg { display: inline-flex; padding: 3px; background: #e9edf3; border-radius: 9px; }
.seg button {
  height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-weight: 550; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(26, 34, 51, .12); }

/* library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #e9edf3; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #a9b2c2; }
.thumb .ph svg { width: 36px; height: 36px; }
.thumb .dur {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 5px;
  background: rgba(15, 20, 32, .78); color: #fff; font-size: 12px; font-weight: 600;
}
.card-body { padding: 12px 14px 6px; flex: 1; }
.card-title {
  font-weight: 600; font-size: 14.5px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title:hover { color: var(--accent); }
.card-meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.card-actions { display: flex; align-items: center; gap: 2px; padding: 4px 8px 8px; }
.card-actions .views { margin-left: auto; padding-right: 6px; color: var(--muted); font-size: 12.5px; display: inline-flex; gap: 5px; align-items: center; }
.card-actions .views svg { width: 15px; height: 15px; }

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 17px; margin: 0 0 6px; }
.empty .btn { margin-top: 16px; }

/* modal */
.overlay {
  position: fixed; inset: 0; z-index: 20; padding: 20px; overflow: auto;
  background: rgba(20, 28, 45, .45); display: grid; place-items: center;
}
.modal {
  width: 100%; max-width: 640px; background: var(--surface); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(20, 28, 45, .25); padding: 24px;
}
.modal.narrow { max-width: 420px; }
.modal.wide { max-width: 920px; align-self: start; }
.modal-head { display: flex; align-items: center; margin-bottom: 18px; }
.modal-head h2 { font-size: 17px; margin: 0; flex: 1; font-weight: 650; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal p { margin: 0; color: var(--muted); line-height: 1.5; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } }
.choice {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 12px; min-height: 210px;
}
.choice h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.choice h3 svg { width: 18px; height: 18px; color: var(--accent); }
.choice .grow { flex: 1; }
.drop {
  flex: 1; display: grid; place-items: center; text-align: center; padding: 16px;
  border: 1.5px dashed #c9d1de; border-radius: 8px; color: var(--muted); cursor: pointer; line-height: 1.5;
}
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: #ccd3df; position: relative; margin: 0; cursor: pointer; transition: background .15s; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(14px); }

.rec { text-align: center; padding: 12px 0 4px; }
.rec .timer { font-size: 44px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; display: inline-flex; align-items: center; gap: 14px; }
.rec .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.rec.paused .dot { animation: none; background: #a9b2c2; }
@keyframes pulse { 50% { opacity: .25; } }
.rec .cam { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; transform: scaleX(-1); margin: 14px auto 0; display: block; background: #e9edf3; }
.rec p { margin: 10px 0 20px; }
.rec .row { display: flex; justify-content: center; gap: 8px; }

.rec .count { font-size: 72px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1; }

.preview { width: 100%; max-height: 320px; background: #000; border-radius: 8px; display: block; margin-bottom: 16px; }

/* trim: two range inputs on one track; only their thumbs take the pointer */
.trim { margin: -4px 0 16px; }
.trim-head { display: flex; align-items: baseline; gap: 10px; font-size: 12px; color: var(--muted); }
.trim-head > span:first-child { font-weight: 600; }
.trim-info { font-variant-numeric: tabular-nums; }
.trim-bar { position: relative; height: 30px; --thumb: 14px; --a: 0; --b: 1; --p: 0; }
.trim-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 8px; border-radius: 4px; background: #dfe4ec; }
.trim-keep {
  position: absolute; top: 11px; height: 8px; background: var(--accent);
  left: calc(var(--a) * (100% - var(--thumb)) + var(--thumb) / 2);
  right: calc((1 - var(--b)) * (100% - var(--thumb)) + var(--thumb) / 2);
}
.trim-now {
  position: absolute; top: 5px; width: 2px; height: 20px; border-radius: 1px; background: var(--text); pointer-events: none;
  left: calc(var(--p) * (100% - var(--thumb)) + var(--thumb) / 2 - 1px);
}
.trim-bar input {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: none; outline: none; pointer-events: none;
}
.trim-bar input::-webkit-slider-runnable-track { height: 100%; background: none; }
.trim-bar input::-moz-range-track { background: none; }
.trim-bar input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; cursor: ew-resize;
  width: var(--thumb); height: 26px; margin-top: 2px; border: 2px solid var(--accent); border-radius: 4px; background: #fff;
}
.trim-bar input::-moz-range-thumb {
  pointer-events: auto; cursor: ew-resize; box-sizing: border-box;
  width: var(--thumb); height: 26px; border: 2px solid var(--accent); border-radius: 4px; background: #fff;
}
.trim-bar input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent-soft); }
.trim-bar input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--accent-soft); }
.trim-bar input:disabled::-webkit-slider-thumb { border-color: #a9b2c2; cursor: default; }
.trim-bar input:disabled::-moz-range-thumb { border-color: #a9b2c2; cursor: default; }
.trim-tools { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal .trim-hint { font-size: 12px; margin-top: 8px; }
.progress { height: 8px; border-radius: 4px; background: #e9edf3; overflow: hidden; margin: 18px 0 10px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.linkrow { display: flex; gap: 8px; margin-top: 14px; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 50;
  background: #1a2233; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* written guide */
.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border: 0; border-radius: 11px;
  font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--muted); white-space: nowrap;
}
button.pill { cursor: pointer; margin-top: 8px; }
.pill.needs_review { background: #fdf3dc; color: #8a5a00; }
.pill.ready { background: var(--accent-soft); color: var(--accent); }
.pill.approved { background: #e3f4e8; color: #1f7a3d; }
.pill.failed { background: #fbe9ea; color: var(--danger); }
.pill.generating { animation: pulse 1.6s infinite; }

/* tags: staff library only */
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 22px; padding: 0 8px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  font-size: 12px; font-weight: 550; color: var(--muted); white-space: nowrap;
}
button.tag { cursor: pointer; }
button.tag:hover, .tag.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tag button { display: grid; place-items: center; width: 16px; height: 16px; margin-right: -4px; padding: 0; border: 0; border-radius: 4px; background: none; color: inherit; cursor: pointer; }
.tag button:hover { background: #eef1f6; color: var(--text); }
.tag svg { width: 11px; height: 11px; }
.field .tags { margin: 0 0 8px; }
.field .tags:empty { display: none; }
.toolbar select.input { max-width: 220px; }

.modal .hint { font-size: 13px; margin: 10px 0 14px; }
.guide-status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.guide-wait { display: flex; gap: 16px; align-items: center; padding: 28px 4px; }
.guide-wait p { margin-top: 4px; }
.spinner { width: 26px; height: 26px; flex: none; border: 3px solid #e4e8ef; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.unclear { margin: 0 0 16px; padding: 12px 14px; border-radius: 8px; background: #fdf3dc; color: #6b4700; font-size: 13px; line-height: 1.5; }
.unclear ul { margin: 6px 0 0; padding-left: 18px; }
.guide-block { margin: 20px 0 16px; }
.guide-block h3 { font-size: 14px; margin: 0 0 6px; }
.guide-checks { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.guide-checks .warn, .approved { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.guide-checks .warn { color: #8a5a00; }
.guide-checks svg, .approved svg, .flag svg { width: 15px; height: 15px; flex: none; }
.approved { color: #1f7a3d; padding: 0 6px; }

.gsteps { list-style: none; margin: 0; padding: 0; }
.gsteps li { display: grid; grid-template-columns: 28px minmax(0, 1fr) 200px; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.gsteps li:first-child { border-top: 0; }
.gsteps .num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 13px; display: grid; place-items: center; margin-top: 6px; }
.gsteps li.flagged .num { background: #fdf3dc; color: #8a5a00; }
.gstep-body { display: flex; flex-direction: column; gap: 6px; }
.modal.wide textarea.input { field-sizing: content; min-height: 40px; resize: none; }
.gstep-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gstep-meta q { margin-left: 8px; font-style: italic; }
.flag { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; background: #fdf3dc; color: #6b4700; font-size: 12.5px; line-height: 1.45; }
.flag svg { margin-top: 2px; }
.gstep-frame { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); cursor: pointer; }
.gstep-frame:disabled { cursor: default; }
.gstep-frame:not(:disabled):hover { border-color: var(--accent); }
.gstep-frame img { display: block; width: 100%; height: auto; }
.gstep-tools { display: flex; justify-content: flex-end; margin-top: 4px; }
.frame-picker { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); grid-auto-rows: max-content; gap: 8px; max-height: 300px; overflow: auto; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.frame { padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; }
.frame.on, .frame:hover { border-color: var(--accent); }
.frame img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.frame span { display: block; padding: 3px 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .gsteps li { grid-template-columns: 28px minmax(0, 1fr); } .gstep-side { grid-column: 2; } }

.shots { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.shot-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.shot-item img { width: 64px; height: 40px; object-fit: cover; border: 1px solid var(--border); border-radius: 5px; }
.shot-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.shot-add { display: flex; gap: 8px; }
.shot-add .btn { height: 38px; }
.guide-foot { align-items: center; flex-wrap: wrap; position: sticky; bottom: -24px; margin: 18px -24px -24px; padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 14px 14px; }
.guide-foot .spacer { flex: 1; }
