:root {
  --bg: #f6f7fb; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #625df5; --brand-d: #4f46e5; --red: #ef4444;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px #fee2e2; }

.container { max-width: 760px; margin: 28px auto; padding: 0 16px; display: grid; gap: 24px; }
.container.wide { max-width: 1100px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.center { text-align: center; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: block; height: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; transition: .15s; }
.mode small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.mode input:checked + span { border-color: var(--brand); background: #eef2ff; }
.mode input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
select, input[type=text], input[type=password], input[readonly] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; color: var(--text);
}
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 0 0 14px; }
.meter div { height: 100%; width: 0; background: #22c55e; transition: width .06s; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; cursor: pointer; }
.check input { margin-top: 4px; }
.check small { color: var(--muted); }

.preview-wrap { display: flex; justify-content: center; margin: 4px 0 18px; }
#camPreview, #camOnly { width: 180px; height: 180px; border-radius: 50%; object-fit: cover; transform: scaleX(-1); background: #111; box-shadow: 0 6px 20px rgba(0,0,0,.18); border: 4px solid #fff; }
#camOnly { width: 320px; height: 240px; border-radius: 14px; margin: 20px auto 0; display: block; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px system-ui, sans-serif; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; transition: .15s; white-space: nowrap; }
.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #f3f4f6; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.danger-text { color: var(--red) !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.small { gap: 4px; }
.center .row { justify-content: center; }

.error { color: var(--red); min-height: 1em; margin: 10px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 10px 0; }

.rec-indicator { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--red); }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: pulse 1.2s infinite; }
.paused .rec-indicator { color: #d97706; } .paused .pulse { background: #f59e0b; animation: none; }
@keyframes pulse { 50% { opacity: .25; } }
.timer { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0 18px; }

#reviewVideo { width: 100%; border-radius: 10px; background: #000; margin-bottom: 14px; max-height: 60vh; }
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--line); overflow: hidden; margin-top: 14px; }
.progress div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #111; mix-blend-mode: difference; filter: invert(1); }
.share { display: flex; gap: 8px; margin-top: 14px; }
.share input { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; background: #f9fafb; }

.lib-head { display: flex; justify-content: space-between; align-items: center; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 8px; }
.lib-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.thumb { position: relative; display: block; aspect-ratio: 16/9; background: #111; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nothumb { display: grid; place-items: center; height: 100%; color: #fff; font-size: 28px; }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.lib-meta { padding: 10px 12px 12px; }
.lib-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-sub { color: var(--muted); font-size: 13px; margin-bottom: 6px; }

.countdown { position: fixed; inset: 0; background: rgba(17,24,39,.65); display: grid; place-items: center; z-index: 50; }
.countdown span { width: 160px; height: 160px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 80px; font-weight: 800; display: grid; place-items: center; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(420px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog-body { padding: 22px; display: grid; gap: 10px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* watch page */
.video-frame { background: #000; border-radius: var(--radius); overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.video-frame video { width: 100%; display: block; max-height: 78vh; background: #000; }
.watch-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.watch-meta h1 { margin: 0 0 2px; }
select.btn { width: auto; padding-right: 10px; }

@media (max-width: 640px) {
  .modes, .grid2 { grid-template-columns: 1fr; }
  .share { flex-wrap: wrap; }
}
