/* «На ПК»: світла тема за замовчуванням (молочний фон), темна — другим режимом (data-theme="dark").
   CSP не дозволяє inline-стилів, тому все тут. */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e4e0d6;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok: #1f9d55;
  --warn: #b7791f;
  --danger: #d64545;
  --info-bg: #e8f0ff;
  --warn-bg: #fff4de;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 6px 18px rgba(31, 36, 48, .06);
  --radius: 18px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12141a;
  --card: #1c1f27;
  --text: #eceff4;
  --muted: #9aa3b2;
  --line: #2b303b;
  --accent: #6c9cff;
  --accent-text: #0d1220;
  --ok: #4cc38a;
  --warn: #e0a73a;
  --danger: #ff7a7a;
  --info-bg: #1f2a44;
  --warn-bg: #3a2f17;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo { font-size: 20px; }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 6px 10px; border-radius: 12px; color: inherit; }
.icon-btn:active { background: var(--line); }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; }
h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 8px; }
h2 { font-size: 17px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 14px 0; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 16px; font-size: 14.5px; }
.bar-info { background: var(--info-bg); }
.bar-warn { background: var(--warn-bg); }
main .bar { border-radius: 14px; margin: 12px 0; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 14px; min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-xl { min-height: 56px; font-size: 18px; flex: 1; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; padding: 10px 0; text-decoration: underline; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.row > .btn { flex: 1; }
.row.center { justify-content: center; }
.sticky-actions { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; }

.field { display: block; margin: 12px 0; font-weight: 600; }
.field input, .field select, textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text);
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }

.seg { display: flex; background: var(--line); padding: 3px; border-radius: 14px; margin: 12px 0; }
.seg-btn { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; padding: 10px; border-radius: 11px; }
.seg-btn[aria-selected="true"], .seg-btn[aria-checked="true"] { background: var(--card); box-shadow: var(--shadow); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.big {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 112px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 700; font-size: 16px; box-shadow: var(--shadow); padding: 12px;
}
.big:active { transform: scale(.98); }
.big-ico { font-size: 36px; line-height: 1; }
.big-wide { grid-column: 1 / -1; min-height: 88px; flex-direction: row; gap: 14px; }

.steps { padding-left: 22px; margin: 0 0 12px; }
.steps li { margin: 8px 0; }
.glyph { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; }

.status { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.status.online .dot { background: var(--ok); }
.status.offline .dot { background: var(--warn); }
.status.error .dot { background: var(--danger); }

.msg { min-height: 1.4em; color: var(--muted); }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

.scanner { position: relative; padding: 0; overflow: hidden; aspect-ratio: 1 / 1; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 14px; }

.queue { list-style: none; margin: 8px 0 0; padding: 0; }
.q-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.q-item:first-child { border-top: 0; }
.q-ico { font-size: 24px; flex: none; }
.q-body { flex: 1; min-width: 0; }
.q-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-sub { font-size: 13.5px; color: var(--muted); }
.q-sub.ok { color: var(--ok); }
.q-sub.err { color: var(--danger); }
.q-sub.wait { color: var(--warn); }
.q-x { background: none; border: 0; font-size: 20px; color: var(--muted); padding: 8px; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.overall { margin: 6px 0 10px; }

.pages { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.page { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.page img { width: 64px; height: 84px; object-fit: cover; border-radius: 8px; background: var(--line); }
.page-n { font-weight: 700; flex: 1; }
.page button { background: none; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 18px; min-width: 40px; min-height: 40px; }

.rec-card { text-align: center; }
.rec-timer { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.level { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 14px; }
.level-bar { height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.rec-card .check { justify-content: center; }
audio { width: 100%; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 14px; text-align: center; box-shadow: var(--shadow);
}

.settings summary { font-weight: 700; cursor: pointer; }
.warn-note { color: var(--warn); }
