: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); }
label.field { display: block; margin-bottom: 12px; }
label.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-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; }

.preview { width: 100%; max-height: 320px; background: #000; border-radius: 8px; display: block; margin-bottom: 16px; }
.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); }
