/* rec.dx1.dev: one stylesheet, light theme only (owner's eyesight: no dark mode). */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #545b64;      /* 7:1 on white */
  --line: #d9dde3;
  --primary: #0b57d0;
  --primary-ink: #ffffff;
  --rec: #c4161c;
  --ok: #137333;
  --warn-bg: #fff6d6; --warn-ink: #5c4400; --warn-line: #e8c94a;
  --err-bg: #fde8e8;  --err-ink: #8a1116; --err-line: #f0a5a5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--primary); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .875rem; margin: .25rem 0 .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar nav { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.topbar nav > a:not(.btn) { color: var(--ink); text-decoration: none; padding: .5rem .25rem; min-height: 44px; display: inline-flex; align-items: center; }
.topbar nav > a[aria-current="page"]:not(.btn) { font-weight: 600; box-shadow: inset 0 -2px 0 var(--primary); }
.brand, .brand-title { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; min-height: 44px; }
.brand-dot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--rec); display: inline-block; }
form.inline { display: inline; margin: 0; }

/* Layout */
main { padding: 16px; }
.page { max-width: 960px; margin: 0 auto; }
.center-page main { min-height: 100vh; display: grid; place-items: center; }
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.narrow { width: 100%; max-width: 380px; }
.row-gap { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Forms */
label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
input[type=text], input[type=password], input[type=date], select {
  width: 100%; min-height: 44px; padding: .5rem .7rem; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #8c939c; border-radius: 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .btn:focus-visible { outline: 3px solid #8ab4f8; outline-offset: 2px; }
input[type=range] { width: 100%; min-height: 44px; accent-color: var(--primary); }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; margin: .6rem 0; min-height: 44px; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex: none; accent-color: var(--primary); }
fieldset.group { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem 1rem; margin: 1rem 0; }
legend { font-weight: 700; padding: 0 .35rem; }
output { font-weight: 400; color: var(--muted); margin-left: .35rem; }
.dim { opacity: .45; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-sm { min-height: 44px; padding: .35rem .8rem; font-size: .9rem; }
.btn-lg { min-height: 52px; padding: .7rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #0842a0; }
.btn-ghost { background: #fff; color: var(--ink); border-color: #b9bfc7; }
.btn-ghost:hover { background: #eef1f5; }
.btn-ghost[aria-pressed="true"] { background: #e3ecfb; border-color: var(--primary); color: #0842a0; }
.btn-danger { background: #fff; color: var(--rec); border-color: #e2a3a5; }
.btn-danger:hover { background: var(--err-bg); }
.btn-light { background: #fff; color: var(--rec); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Alerts */
.alert { border: 1px solid; border-radius: 8px; padding: .65rem .85rem; margin: .5rem 0 1rem; }
.alert-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.alert-error { background: var(--err-bg); color: var(--err-ink); border-color: var(--err-line); font-weight: 600; }
.alarm { position: sticky; top: 0; z-index: 50; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--rec); color: #fff; padding: .8rem 16px; font-size: 1.05rem; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { background: var(--rec); } to { background: #8f0f14; } }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } }

/* Recorder */
.recorder { max-width: 720px; }
.meter-block { margin: .75rem 0; }
.meter-label { font-weight: 600; display: block; margin-bottom: .25rem; }
.level { height: 18px; background: #e8ebef; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.level-fill { height: 100%; width: 0; background: linear-gradient(90deg, #1e8e3e 0%, #1e8e3e 70%, #f9ab00 85%, #d93025 100%); background-size: 100vw 100%; transition: width 60ms linear; }
.level-fill.hot { background: #d93025; }
.level-sm { width: 120px; height: 10px; margin-left: auto; }
.live-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.timer { font: 700 1.75rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #9aa0a6; }
.rec-dot.on { background: var(--rec); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-dot.on { animation: none; } }
.sources { list-style: none; padding: 0; margin: .25rem 0 .75rem; display: grid; gap: .25rem; }
.sources li { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.sources .dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa0a6; flex: none; }
.sources li.on { color: var(--ink); }
.sources li.on .dot { background: var(--ok); box-shadow: 0 0 0 3px #ceead6; }
#src-mic:not(.on) { color: var(--err-ink); font-weight: 600; }
#src-mic:not(.on) .dot { background: var(--rec); }
#preview { width: 100%; max-height: 50vh; background: #111; border-radius: 8px; margin: .5rem 0 1rem; }
.countdown { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; text-align: center; background: rgba(255, 255, 255, .92); }
.countdown span { font: 800 9rem/1 var(--font); color: var(--rec); }
.countdown p { color: var(--muted); }
.link-box { display: flex; gap: .5rem; margin: 1rem 0; }
.link-box input { font-family: var(--mono); font-size: .95rem; }

/* Library */
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h1 { margin: 0; }
.storage { min-width: min(100%, 320px); }
.storage label { font-weight: 400; font-size: .875rem; color: var(--muted); margin: 0 0 .2rem; }
.storage meter { width: 100%; height: 12px; }
.empty { padding: 2rem; text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.lib { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .75rem; }
.lib-row { display: grid; grid-template-columns: 200px 1fr; gap: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; box-shadow: var(--shadow); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #e8ebef; border-radius: 6px; overflow: hidden; align-self: start; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, .78); color: #fff; font: 600 .78rem/1 var(--mono); padding: 3px 5px; border-radius: 4px; }
.thumb-dur:empty { display: none; }
.title-input { font-weight: 600; border-color: transparent !important; padding-left: .35rem !important; margin-left: -.35rem; }
.title-input:hover { border-color: var(--line) !important; }
.title-input:focus { border-color: #8c939c !important; }
.lib-sub { font-size: .9rem; margin: .2rem 0 .5rem; }
.lib-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.lib-settings { margin-top: .75rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.field-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.field-row label { width: 100%; margin: .25rem 0 0; }
.field-row input { flex: 1 1 180px; width: auto; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .1rem .5rem; border-radius: 99px; background: #e8ebef; color: var(--ink); }
.badge-ready { background: #ceead6; color: #0d5323; }
.badge-processing, .badge-uploading { background: #e3ecfb; color: #0842a0; }
.badge-failed { background: var(--err-bg); color: var(--err-ink); }

/* Share page */
.share { max-width: 1100px; margin: 0 auto; }
.player-wrap { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.state-box { background: var(--card); border: 1px solid var(--line); text-align: center; padding: 1rem; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #d6dce4; border-top-color: var(--primary); animation: spin .9s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.share-meta { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: start; margin-top: 1rem; }
.share-meta h1 { margin-bottom: .2rem; overflow-wrap: anywhere; }
.share-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.speed { display: inline-flex; gap: .25rem; }

@media (max-width: 640px) {
  .lib-row { grid-template-columns: 1fr; }
  .link-box { flex-direction: column; }
  .countdown span { font-size: 6rem; }
  .player-wrap { border-radius: 0; margin: -16px -16px 0; }
}
