:root {
  /* الألوان من design/README.md: زمردي للتمييز، ذهبي للتنبيه، والأحمر لحالة التسجيل والخطر فقط */
  --bg: #eef1ef;
  --surface: #ffffff;
  --ink: #10201d;
  --muted: #5b6b68;
  --line: #d5dcd9;
  --field-line: #84948f;
  --accent: #12806f;
  --accent-soft: #e0f1ee;
  --accent-ink: #ffffff;
  --gold: #d4a853;
  --gold-soft: #f8efd9;
  --gold-ink: #5e4412;
  --rec: #e0355b;
  --warn: #e8a33d;
  --danger: #b42318;
  --danger-soft: #fbe9e7;
  --stage: #0b1211;
  --shadow: 0 1px 2px rgba(20,25,35,.06), 0 4px 14px rgba(20,25,35,.06);
  --font-display: "Readex Pro", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1211; --surface: #151f1d; --ink: #edf2f0; --muted: #8fa19d; --line: #2a3634; --field-line: #66807a;
    --accent: #2fb5a0; --accent-soft: #10332e; --accent-ink: #04231e;
    --gold-soft: #3a2f16; --gold-ink: #f0d9a3;
    --danger: #f07167; --danger-soft: #3a1f1d;
    --stage: #060a09;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.55; }
button, input, select { font: inherit; color: inherit; }
h1, h2 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
svg { width: 16px; height: 16px; flex: none; }

header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
header.top h1 { font-size: 19px; }
header.top .sub { color: var(--muted); font-size: 13px; }
.keys { color: var(--muted); font-size: 12.5px; }
kbd {
  display: inline-block; min-width: 22px; padding: 0 6px; text-align: center; font-family: inherit; font-size: 12px;
  border: 1px solid var(--field-line); border-bottom-width: 2px; border-radius: 6px; background: var(--bg); color: var(--ink);
}

main { padding: 18px 20px 40px; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.btn {
  min-height: 40px; padding: 7px 16px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--field-line); font-weight: 500;
}
.btn:hover:not(:disabled) { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.rec svg { color: var(--rec); }
.btn.primary.rec svg { color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn.mini { min-height: 34px; padding: 4px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
a.btn { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin-bottom: 10px; }
.card h2.gap { margin-top: 18px; }

.panel {
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold);
}
.panel.ok { border-inline-start-color: var(--accent); }
.panel.danger { border-inline-start-color: var(--danger); color: var(--ink); }
.panel h2 { font-size: 14.5px; margin-bottom: 2px; }
.privacy p { color: var(--muted); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } }

.stage {
  position: relative; aspect-ratio: 16 / 9; background: var(--stage); border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #8fa19d;
}
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.placeholder { text-align: center; padding: 20px; font-size: 14px; }
.placeholder svg { width: 52px; height: 52px; opacity: .6; margin-bottom: 6px; }
.live-badge, .mic-badge {
  position: absolute; top: 12px; display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.live-badge { inset-inline-start: 12px; }
.mic-badge { inset-inline-end: 12px; }
.live-badge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
.live-badge.paused .dot { background: var(--warn); animation: none; }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-badge .dot { animation: none; } }
.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 110px; font-weight: 600; color: #fff; background: rgba(0,0,0,.55);
}

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.timer { direction: ltr; unicode-bidi: isolate; }
.timer { margin-inline-start: auto; font-family: var(--font-display); font-size: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer.live { color: var(--ink); }

.settings { display: flex; flex-direction: column; gap: 8px; }
.settings h2 { margin-bottom: 2px; }
.btn.mic { width: 100%; min-height: 46px; font-weight: 600; }
.btn.mic.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.mic.off { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: right; transition: transform .06s linear; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field select {
  min-height: 40px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--field-line); background: var(--surface); color: var(--ink); font-size: 14px;
}
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.list .empty { text-align: center; padding: 14px; }
.rec-item {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.rec-item + .rec-item { margin-top: 10px; }
@media (max-width: 560px) { .rec-item { grid-template-columns: minmax(0, 1fr); } }
.rec-item video { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #000; }
.rec-name { font-weight: 600; overflow-wrap: anywhere; }
.rec-meta { color: var(--muted); font-size: 13px; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.saved { color: var(--accent); font-size: 12.5px; font-weight: 500; }

/* النافذة الطافية: صف واحد صغير، المؤقت ثم ثلاثة أزرار أيقونات */
body.pip {
  display: flex; align-items: center; gap: 6px; height: 100vh; padding: 0 8px;
  background: var(--surface); overflow: hidden; user-select: none;
}
body.pip .live-badge {
  position: static; flex: 1; min-width: 0; padding: 0; gap: 6px; background: none; color: var(--ink);
  font-size: 13px; white-space: nowrap;
}
body.pip .live-badge .dot { width: 8px; height: 8px; }
.icon-btn {
  width: 30px; height: min(30px, calc(100vh - 6px)); padding: 0; flex: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--field-line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.icon-btn:hover:not(:disabled) { background: var(--accent-soft); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn.on { border-color: var(--accent); color: var(--accent); }
.icon-btn.stop { background: var(--rec); border-color: var(--rec); color: #fff; }
.icon-btn.stop:hover:not(:disabled) { background: var(--rec); filter: brightness(1.1); }
