/* ───────── Tokens ─────────
   Visual identity: Egyptian judiciary — deep navy ink, judicial gold, ivory / parchment surfaces. */
:root {
  color-scheme: light;
  --page: #f2eee3;
  --surface: #fffdf8;
  --surface-2: #faf6ec;
  --surface-3: #efe8d6;
  --ink: #16202d;
  --ink-2: #4f5866;
  --ink-3: #737b87;
  --line: rgba(22, 32, 45, 0.1);
  --line-2: rgba(22, 32, 45, 0.2);
  --primary: #14294a;
  --primary-hover: #1e3c68;
  --primary-ink: #ffffff;
  --accent-soft: #f4ecd7;
  --focus: #8f6610;
  --gold: #b08a35;
  --gold-2: #d6bb78;
  --gold-soft: #efe3c2;
  --navy: #14294a;
  --navy-deep: #0d1d36;
  --good: #1f7a3a;
  --warning: #c98a00;
  --critical: #b3261e;
  --rec: #b3261e;
  --meter-track: #ebe3cf;
  --meter-fill: #b08a35;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.05), 0 10px 30px -14px rgba(20, 30, 45, 0.2);
  --radius: 14px;
  --radius-sm: 9px;
  --bar-h: 76px;
  --sans: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --serif: "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
  --formal: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0a101b;
    --surface: #111a29;
    --surface-2: #162132;
    --surface-3: #1e2a3d;
    --ink: #eee9dc;
    --ink-2: #b3ac9c;
    --ink-3: #8c8778;
    --line: rgba(232, 220, 190, 0.1);
    --line-2: rgba(232, 220, 190, 0.2);
    --primary: #dcc07a;
    --primary-hover: #e9d297;
    --primary-ink: #13213a;
    --accent-soft: #29251a;
    --focus: #dcc07a;
    --gold: #d0ae66;
    --gold-2: #b39350;
    --gold-soft: #3a321d;
    --meter-track: #25314a;
    --meter-fill: #d0ae66;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.6; background: var(--page); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; }
h2 { font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-2); }

.wrap { max-width: 1800px; margin: 0 auto; padding: 0 20px; }

/* ───────── Top bar: official letterhead band ───────── */
.topbar {
  position: sticky; top: 0; z-index: 30; color: #f5efe0;
  background: linear-gradient(180deg, #16305a 0%, var(--navy-deep) 100%);
  border-bottom: 2px solid #c9a65a;
  box-shadow: 0 1px 0 var(--navy-deep), 0 6px 18px -10px rgba(8, 18, 36, 0.55);
}
.bar { display: flex; align-items: center; gap: 14px; height: var(--bar-h); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { display: none; }
.brand-eagle { display: block; height: 56px; width: auto; flex: none; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35)); }
.brand-gov { display: grid; min-width: 0; line-height: 1.25; }
.brand-state { font-size: 12px; font-weight: 500; color: var(--gold-2); white-space: nowrap; }
@media (prefers-color-scheme: dark) { .brand-state { color: #d6bb78; } }
.brand-court { font-family: var(--formal); font-size: 22px; font-weight: 700; color: #fff; line-height: 1.4; white-space: nowrap; }
.brand-sep { align-self: stretch; width: 1px; margin: 16px 6px; flex: none; background: linear-gradient(transparent, rgba(214, 187, 120, 0.75), transparent); }
.brand-app { display: grid; min-width: 0; line-height: 1.35; }
.brand-name { font-weight: 600; font-size: 14.5px; color: #f5efe0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: rgba(245, 239, 224, 0.66); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(214, 187, 120, 0.38); color: #f5efe0; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(245, 239, 224, 0.45); flex: none; }
.status[data-state="connecting"] .status-dot, .status[data-state="reconnecting"] .status-dot { background: #f0b429; animation: blink 1s infinite; }
.status[data-state="ready"] .status-dot { background: #4cc46a; }
.status[data-state="recording"] { background: rgba(179, 38, 30, 0.42); box-shadow: inset 0 0 0 1px rgba(255, 160, 150, 0.45); }
.status[data-state="recording"] .status-dot { background: #ff6b5e; animation: pulse 1.4s infinite; }
.status[data-state="error"] { background: rgba(179, 38, 30, 0.32); box-shadow: inset 0 0 0 1px rgba(255, 160, 150, 0.45); color: #ffd9d4; }
.status[data-state="error"] .status-dot { background: #ff6b5e; }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }

.topbar .btn { background: transparent; border-color: rgba(214, 187, 120, 0.5); color: #f5efe0; }
.topbar .btn:hover { background: rgba(255, 255, 255, 0.08); border-color: #d6bb78; }
.topbar .sess-toggle .k { background: rgba(214, 187, 120, 0.22); color: #f5efe0; }

@media (max-width: 1100px) { .brand-sep, .brand-app { display: none; } }

/* ───────── Layout ───────── */
.layout { display: grid; grid-template-columns: 350px minmax(0, 1fr) 300px; gap: 18px; padding-top: 18px; padding-bottom: 18px; align-items: start; }
.side { display: grid; gap: 14px; position: sticky; top: calc(var(--bar-h) + 20px); max-height: calc(100vh - var(--bar-h) - 38px); overflow: auto; padding: 2px; scrollbar-width: thin; }
@media (max-width: 1379px) {
  .layout { grid-template-columns: 350px minmax(0, 1fr); }
}
@media (max-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; overflow: visible; }
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card > h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-family: var(--formal); font-size: 18.5px; font-weight: 700; color: var(--primary); }
.card > h2::before, .sess-head h2::before { content: ""; width: 19px; height: 19px; flex: none; background: url("brand/scales.svg") center / contain no-repeat; }
.card > h2.sr-only::before { content: none; }

/* ───────── Controls ───────── */
.field { display: grid; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.field.inline .input { width: auto; height: 36px; }
.input { width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.input::placeholder { color: var(--ink-3); }
.key-row { display: flex; gap: 6px; }
.key-locked { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 30%, transparent); font-size: 14px; font-weight: 500; }
.key-locked svg { width: 16px; height: 16px; flex: none; color: var(--focus); }
.key-locked .btn { margin-inline-start: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin-bottom: 12px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.hint { font-size: 12.5px; color: var(--ink-3); margin: 10px 0 0; }

.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
.btn:hover { background: var(--surface-2); border-color: var(--gold); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-block { width: 100%; height: 44px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn svg { width: 17px; height: 17px; flex: none; }
.icon-btn { width: 42px; height: 42px; padding: 0; flex: none; }
.btn.danger { color: var(--critical); }

/* Recorder */
.rec-row { display: flex; align-items: center; gap: 16px; }
.mic {
  appearance: none; width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  display: grid; place-items: center; background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 0 0 4px var(--gold-soft), 0 0 0 5px color-mix(in srgb, var(--gold) 55%, transparent), 0 10px 24px -10px color-mix(in srgb, var(--primary) 80%, transparent);
  transition: transform 0.12s, background 0.12s;
}
.mic svg { width: 32px; height: 32px; }
.mic:hover:not(:disabled) { transform: scale(1.04); }
.mic:disabled { background: var(--surface-3); color: var(--ink-3); box-shadow: 0 0 0 4px var(--surface-2); cursor: not-allowed; }
.mic[aria-pressed="true"] { background: var(--rec); color: #fff; animation: pulse 1.6s infinite; }
.mic.busy:disabled { background: var(--accent-soft); color: var(--focus); cursor: progress; }
.mic .spin { width: 28px; height: 28px; border-width: 3px; }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; }
.spin.big { width: 30px; height: 30px; border-width: 3px; color: #b08a35; }
@keyframes spin { to { transform: rotate(360deg); } }
.cont-btn { margin-top: 10px; color: var(--focus); padding: 0 8px; }
.auto-opts { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 6px; }
.auto-opts .check { margin: 0; font-size: 13.5px; align-items: flex-start; line-height: 1.5; }
.auto-opts .check input { margin-top: 2px; flex: none; }
.auto-opts .check:has(input:disabled) { opacity: 0.5; cursor: default; }
.rec-info { flex: 1; min-width: 0; }
.rec-time { font-size: 28px; font-weight: 600; line-height: 1.1; color: var(--primary); }
.rec-label { color: var(--ink-2); font-size: 13.5px; margin: 2px 0 10px; }
.meter { height: 8px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--meter-fill); border-radius: 999px; transition: width 0.08s linear; }

.segctl { display: flex; padding: 3px; gap: 3px; background: var(--surface-3); border-radius: 11px; }
.segctl button { appearance: none; flex: 1; min-width: 0; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.segctl button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), inset 0 -2px 0 var(--gold); }

.diar { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.diar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: -2px; }
.diar-note { font-size: 12.5px; color: var(--ink-3); }
.diar-note.on::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-inline-end: 6px; vertical-align: middle; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.meta-grid .full { grid-column: 1 / -1; }
.party { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--surface-2); }
.party legend { font-family: var(--formal); font-size: 15px; color: var(--primary); font-weight: 700; padding: 0 6px; }

/* ───────── Main panel ───────── */
.main { padding: 0; display: flex; flex-direction: column; height: calc(100vh - var(--bar-h) - 38px); min-height: 520px; overflow: hidden; position: relative; border-top: 3px solid var(--gold); }
@media (max-width: 1040px) { .main { height: auto; min-height: 0; } }
.tabbar { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); }
.tabs { display: flex; gap: 4px; }
.tabs button { appearance: none; border: 0; background: none; cursor: pointer; padding: 14px 12px 12px; font-family: var(--formal); font-size: 17px; font-weight: 700; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--gold); }
.tabs .k { font-family: var(--sans); font-weight: 500; font-size: 12px; color: var(--ink-3); margin-inline-start: 4px; }
.tools { display: flex; gap: 6px; margin-inline-start: auto; padding: 8px 0; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.transcript { flex: 1; overflow-y: auto; padding: 18px 22px 8px; scroll-behavior: smooth; }
@media (max-width: 1040px) { .transcript { max-height: 70vh; min-height: 320px; } }
.foot { display: flex; justify-content: space-between; gap: 10px; padding: 10px 22px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; background: var(--surface-2); }

.empty { max-width: 470px; margin: 5vh auto; text-align: center; color: var(--ink-2); }
.empty::before { content: ""; display: block; width: 66px; height: 90px; margin: 0 auto 6px; background: url("brand/eagle.svg") center / contain no-repeat; }
.empty-ico { display: none; }
.empty h3 { font-family: var(--formal); font-size: 21px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.empty h3::after { content: ""; display: block; width: 120px; height: 7px; margin: 8px auto 14px; background:
  linear-gradient(var(--gold), var(--gold)) center / 100% 1px no-repeat,
  radial-gradient(circle, var(--gold) 0 3px, transparent 3.5px) center / 7px 7px no-repeat; }
.empty ol { text-align: start; display: grid; gap: 6px; padding-inline-start: 22px; margin: 0; font-size: 14px; }

.seg { position: relative; padding: 10px 12px; margin: 0 -12px; border-radius: 12px; transition: background 0.15s; }
.seg:hover { background: var(--surface-2); }
.seg:focus-within { background: var(--accent-soft); }
.seg.new { animation: seg-in 0.35s ease-out; }
@keyframes seg-in { from { opacity: 0; transform: translateY(6px); } }
.seg-h { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 2px; min-height: 26px; }
.spk { appearance: none; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); border-radius: 999px; height: 24px; padding: 0 10px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.spk[data-spk="1"] { background: #e7edf7; border-color: #b6c6e0; color: #1d3a66; }
.spk[data-spk="2"] { background: #f7ebdc; border-color: #e3c59f; color: #7a4113; }
.spk[data-spk="3"] { background: #e3f3ec; border-color: #b0dccb; color: #11583f; }
.spk[data-spk="4"] { background: #efeafb; border-color: #cfc3f1; color: #4b3596; }
.spk[data-spk="5"] { background: #fbe9ef; border-color: #efbfd0; color: #8a2550; }
.spk[data-spk="6"] { background: #fbf2d9; border-color: #ead494; color: #6f5000; }
.spk.auto { border-style: dashed; }
.spk.pending { opacity: 0.55; letter-spacing: 0.1em; }
.seg.cont { padding-top: 2px; }
.seg.cont .seg-h { position: absolute; top: 4px; inset-inline-end: 8px; margin: 0; padding: 0 6px; min-height: 24px; border-radius: 8px; background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); opacity: 0; pointer-events: none; transition: opacity 0.12s; z-index: 1; }
.seg.cont:hover .seg-h, .seg.cont:focus-within .seg-h { opacity: 1; pointer-events: auto; }
.seg.cont .seg-del { opacity: 1; margin-inline-start: 0; }
@media (prefers-color-scheme: dark) {
  .spk[data-spk="1"] { background: #18263d; border-color: #2d4a73; color: #b5cdf0; }
  .spk[data-spk="2"] { background: #33251a; border-color: #5f4129; color: #f0c9a2; }
  .spk[data-spk="3"] { background: #13302a; border-color: #23574a; color: #9fe0c8; }
  .spk[data-spk="4"] { background: #241d3a; border-color: #3e3366; color: #c9bcf5; }
  .spk[data-spk="5"] { background: #361a27; border-color: #5e2c43; color: #f3b3cf; }
  .spk[data-spk="6"] { background: #33290f; border-color: #5c4a1a; color: #f0d48c; }
}
.edited { color: var(--ink-3); font-size: 11.5px; }
.seg-del { appearance: none; border: 0; background: none; color: var(--ink-3); cursor: pointer; margin-inline-start: auto; padding: 2px 6px; border-radius: 6px; opacity: 0; font-size: 12.5px; }
.seg:hover .seg-del, .seg:focus-within .seg-del { opacity: 1; }
.seg-del:hover { color: var(--critical); background: var(--surface-3); }
.seg-txt { font-family: var(--serif); font-size: 18px; line-height: 1.9; outline: none; white-space: pre-wrap; word-wrap: break-word; border-radius: 6px; cursor: text; }
.seg-txt:focus { box-shadow: 0 0 0 2px var(--focus); background: var(--surface); padding: 2px 6px; margin: -2px -6px; }

.interim { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0 18px; color: var(--ink-3); font-family: var(--serif); font-size: 18px; line-height: 1.9; }
.typing { display: inline-flex; gap: 3px; padding-top: 14px; flex: none; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }

.jump { position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%); appearance: none; border: 0; background: var(--primary); color: var(--primary-ink); border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 13px; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); }

/* ───────── Formal document (official letterhead) ───────── */
.doc-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.doc-toolbar .check { margin: 0; }
.doc-hint { margin: 0; padding: 8px 18px; font-size: 12.5px; color: var(--ink-3); }
.paper-wrap { flex: 1; overflow: auto; background: var(--surface-3); padding: 24px 16px 40px; }
.paper {
  --p-ink: #16202d; --p-ink-2: #4e5562; --p-line: #d3c9b1; --p-soft: #f7f1e2; --p-navy: #14294a; --p-gold: #b08a35;
  width: 100%; max-width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: var(--p-ink);
  padding: 16mm 18mm 18mm; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18); border-radius: 2px;
  font-family: var(--serif); font-size: 15.5px; line-height: 1.9; color-scheme: light;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.paper[dir="ltr"] { font-family: Georgia, "Times New Roman", serif; }
.paper:focus { outline: none; }
.paper [data-ph]:empty::before { content: attr(data-ph); color: #aaa; }
.paper li:empty::before { content: "…"; color: #bbb; }
.paper [contenteditable="true"]:hover { background: #fbf8ea; }
.paper [contenteditable="true"]:focus { outline: 1.5px dashed #b9a54b; outline-offset: 2px; background: #fffbe8; }

/* Letterhead: state / ministry / court (start side) · national emblem (centre) · case fields (end side),
   then a navy + gold double rule. Built entirely in CSS on top of the generated .doc-head. */
.doc-head {
  position: relative; text-align: center;
  padding: 122px 0 12px; margin-bottom: 18px;
  border-bottom: 3px double var(--p-navy);
  background:
    url("brand/eagle.svg") center 0 / auto 86px no-repeat,
    linear-gradient(var(--p-navy), var(--p-navy)) 0 98px / 100% 2px no-repeat,
    linear-gradient(var(--p-gold), var(--p-gold)) 0 103px / 100% 1px no-repeat;
}
.doc-head::before, .doc-head::after {
  position: absolute; top: 2px; white-space: pre-line; text-align: center;
  font-family: var(--formal); font-weight: 700; font-size: 15px; line-height: 1.72; color: var(--p-navy);
}
.doc-head::before { content: "جمهورية مصر العربية\A وزارة العدل\A محكمة الإسكندرية الابتدائية"; inset-inline-start: 0; }
.doc-head::after { content: "رقم الدعوى: ................\A الدائرة: ....................\A الجلسة: ....................."; inset-inline-end: 0; font-weight: 400; font-size: 14px; text-align: start; color: var(--p-ink-2); }
.doc-kicker { display: inline-block; font-family: var(--formal); font-size: 15px; font-weight: 700; color: #8a6a22; padding: 0 14px; position: relative; }
.doc-kicker::before, .doc-kicker::after { content: "◆"; font-size: 8px; vertical-align: 3px; color: var(--p-gold); }
.doc-kicker::before { margin-inline-end: 10px; }
.doc-kicker::after { margin-inline-start: 10px; }
.doc-title { font-family: var(--formal); font-size: 27px; font-weight: 700; color: var(--p-navy); margin: 2px 0 0; line-height: 1.5; }
.paper[dir="ltr"] .doc-title { font-family: Georgia, "Times New Roman", serif; }
.doc-meta { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 14.5px; }
.doc-meta th, .doc-meta td { border: 1px solid var(--p-line); padding: 6px 10px; text-align: start; vertical-align: top; }
.doc-meta th { background: var(--p-soft); color: var(--p-navy); font-weight: 700; width: 16%; white-space: nowrap; font-family: var(--formal); font-size: 15px; }
.doc-sec { margin-bottom: 16px; break-inside: avoid-page; }
.doc-sec h2 { font-size: 18px; font-weight: 700; margin: 0 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--p-gold); color: var(--p-navy); font-family: var(--formal); }
.paper[dir="ltr"] .doc-sec h2 { font-family: Georgia, "Times New Roman", serif; }
.doc-sec p { margin: 0; text-align: justify; }
.doc-sec ul, .doc-sec ol { margin: 0; padding-inline-start: 24px; }
.doc-sec li { margin-bottom: 3px; }
.doc-sec li::marker { color: var(--p-gold); }
.doc-none { color: var(--p-ink-2); }
.doc-tasks { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.doc-tasks th, .doc-tasks td { border: 1px solid var(--p-line); padding: 6px 10px; text-align: start; vertical-align: top; }
.doc-tasks th { background: var(--p-soft); color: var(--p-navy); font-family: var(--formal); font-size: 15px; font-weight: 700; }
.doc-tasks td:first-child { width: 36px; text-align: center; }
.doc-appx { font-size: 13.5px; line-height: 1.8; }
.doc-appx p { margin: 0 0 4px; }
.doc-appx b { font-family: var(--sans); font-size: 12.5px; color: var(--p-navy); }
.doc-end { break-inside: avoid; page-break-inside: avoid; }
.doc-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 34px; break-inside: avoid; page-break-inside: avoid; }
.sig { font-size: 14.5px; border: 1px solid var(--p-line); border-top: 2px solid var(--p-navy); padding: 12px 14px 4px; }
.sig h3 { font-size: 17px; font-weight: 700; margin: 0 0 12px; font-family: var(--formal); color: var(--p-navy); text-align: center; }
.sig-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 18px; }
.sig-row .lbl { white-space: nowrap; color: var(--p-ink-2); font-family: var(--sans); font-size: 13px; }
.sig-row .ln { flex: 1; border-bottom: 1px dotted var(--p-ink); min-height: 26px; padding: 0 4px; }
.sig-row.tall .ln { min-height: 46px; }
.doc-foot { margin-top: 26px; padding-top: 8px; border-top: 1px solid var(--p-gold); font-family: var(--sans); font-size: 11.5px; color: var(--p-ink-2); text-align: center; }
.doc-empty { display: grid; place-items: center; min-height: 240mm; text-align: center; color: #777; font-family: var(--sans); }
.doc-empty > div::before { content: ""; display: block; width: 58px; height: 80px; margin: 0 auto 12px; background: url("brand/eagle.svg") center / contain no-repeat; opacity: 0.85; }

/* ───────── Saved sessions ───────── */
.sessions { position: sticky; top: calc(var(--bar-h) + 20px); max-height: calc(100vh - var(--bar-h) - 38px); min-height: 0; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.sess-head { padding: 16px 14px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.sess-head-row { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.sess-head h2 { display: flex; align-items: center; gap: 8px; font-family: var(--formal); font-size: 18.5px; font-weight: 700; color: var(--primary); }
.sess-head .k, .sess-toggle .k { font-size: 12px; font-weight: 600; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); display: inline-grid; place-items: center; }
.sess-head .btn-block { height: 40px; }
.sess-search { display: block; }
.sess-search .input { height: 38px; font-size: 14px; }
.sess-close { display: none; margin-inline-start: auto; width: 34px; height: 34px; }
.sess-list { list-style: none; margin: 0; padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 60px; scrollbar-width: thin; }
.sess-day { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 12px 8px 4px; }
.sess { display: flex; align-items: stretch; border-radius: 12px; border: 1px solid transparent; margin-bottom: 2px; transition: background 0.12s; }
.sess:hover { background: var(--surface-2); }
.sess.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--gold) 55%, transparent); box-shadow: inset -3px 0 0 var(--gold); }
[dir="ltr"] .sess.on { box-shadow: inset 3px 0 0 var(--gold); }
.sess-main { appearance: none; flex: 1; min-width: 0; display: grid; gap: 1px; text-align: start; border: 0; background: none; padding: 9px 10px; cursor: pointer; color: inherit; border-radius: 12px; }
.sess-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sess-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-sub { font-size: 12.5px; color: var(--ink-2); }
.sess-who { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-acts { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding-inline-end: 6px; opacity: 0; transition: opacity 0.12s; }
.sess:hover .sess-acts, .sess:focus-within .sess-acts, .sess.on .sess-acts { opacity: 1; }
@media (hover: none) { .sess-acts { opacity: 1; } }
.sess-act { appearance: none; width: 30px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.sess-act svg { width: 16px; height: 16px; }
.sess-act:hover { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.sess-act.danger:hover { color: var(--critical); }
.badge { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge[data-st="done"] { background: color-mix(in srgb, var(--good) 13%, var(--surface)); color: #17672f; }
.badge[data-st="recording"] { background: color-mix(in srgb, var(--rec) 13%, var(--surface)); color: var(--rec); }
.badge[data-st="recording"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
.badge[data-st="finishing"], .badge[data-st="summarizing"] { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); color: var(--focus); }
.badge[data-st="finishing"]::before, .badge[data-st="summarizing"]::before { content: ""; width: 8px; height: 8px; border: 1.6px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.badge[data-st="failed"] { background: color-mix(in srgb, var(--critical) 11%, var(--surface)); color: var(--critical); }
.badge[data-st="fresh"] { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-3); }
@media (prefers-color-scheme: dark) { .badge[data-st="done"] { color: #74dd86; } }
.sess-none, .sess-empty { margin: 0; padding: 14px 16px; color: var(--ink-3); font-size: 13.5px; text-align: center; }
.sess-foot { margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); background: var(--surface-2); }
.sess-toggle { display: none; }
.sess-toggle svg { width: 17px; height: 17px; }
.sess-bg { display: none; }
@media (max-width: 1379px) {
  .sess-toggle { display: inline-flex; }
  .sessions { position: fixed; z-index: 45; top: 0; bottom: 0; inset-inline-end: 0; width: min(340px, 88vw); max-height: none; border-radius: 0; transform: translateX(-105%); visibility: hidden; transition: transform 0.22s ease, visibility 0s linear 0.22s; }
  [dir="ltr"] .sessions { transform: translateX(105%); }
  .sessions.open { transform: none; visibility: visible; transition: transform 0.22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); }
  .sess-close { display: inline-flex; }
  .sessions.open ~ .sess-bg { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(8, 16, 30, 0.45); }
}
.print-sheet { display: none; }

/* ───────── Toasts ───────── */
.toasts { position: fixed; inset-inline: 0; bottom: 20px; z-index: 100; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 560px; background: var(--navy-deep); color: #f5efe0; padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(214, 187, 120, 0.35); font-size: 14px; animation: seg-in 0.18s ease-out; }
.toast.err { background: var(--critical); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.toast button { appearance: none; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

@media (max-width: 640px) {
  :root { --bar-h: 64px; }
  .wrap { padding: 0 12px; }
  .bar { gap: 10px; }
  .brand { gap: 9px; }
  .brand-eagle { height: 44px; }
  .brand-state { font-size: 10.5px; }
  .brand-court { font-size: 17px; }
  .brand-sub { display: none; }
  .status { padding: 0 10px; }
  .paper { padding: 12mm 9mm; font-size: 14.5px; min-height: 0; }
  .doc-head { padding-top: 112px; background-position: left 0 top 0, 0 92px, 0 97px; background-size: auto 76px, 100% 2px, 100% 1px; }
  .paper[dir="ltr"] .doc-head { background-position: right 0 top 0, 0 92px, 0 97px; }
  .doc-head::before { font-size: 12.5px; }
  .doc-head::after { display: none; }
  .doc-title { font-size: 23px; }
  /* the 4-column meta table becomes label / value rows */
  .doc-meta, .doc-meta tbody { display: block; }
  .doc-meta { border: 1px solid var(--p-line); border-bottom: 0; }
  .doc-meta tr { display: grid; grid-template-columns: minmax(86px, auto) 1fr; }
  .doc-meta th, .doc-meta td { border: 0; border-bottom: 1px solid var(--p-line); }
  .doc-meta th { width: auto; }
  .doc-sign { grid-template-columns: 1fr; gap: 10px; }
  .seg-txt { font-size: 16.5px; }
  .tools .label { display: none; }
  .sess-toggle { padding: 0 10px; }
}
@media (max-width: 480px) {
  .sess-toggle-label { display: none; }
  .brand-state { display: none; }
  .brand-court { font-size: 16px; }
}

/* ───────── Print: only the formal document ───────── */
@media print {
  @page {
    size: A4; margin: 13mm 13mm 15mm;
    @bottom-center { content: "صفحة " counter(page) " من " counter(pages); font-family: "Noto Naskh Arabic", serif; font-size: 9pt; color: #555; }
  }
  :root { color-scheme: light; }
  body { background: #fff; }
  .topbar, .side, .tabbar, .doc-toolbar, .doc-hint, #panel-live, .toasts, .jump { display: none !important; }
  #panel-doc { display: block !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .main.card { border: 0; box-shadow: none; padding: 0; height: auto; overflow: visible; background: #fff; }
  .paper-wrap { padding: 0; background: #fff; overflow: visible; }
  .paper { box-shadow: none; max-width: none; min-height: 0; padding: 0; line-height: 1.8; }
  .paper [contenteditable="true"]:hover, .paper [contenteditable="true"]:focus { background: none; outline: none; }
  .paper [data-ph]:empty::before, .paper li:empty::before { content: none; }
  /* a slightly tighter letterhead on paper */
  .doc-head { padding-top: 108px; margin-bottom: 14px; background-size: auto 78px, 100% 2px, 100% 1px; background-position: center 0, 0 88px, 0 93px; }
  .doc-head::before, .doc-head::after { line-height: 1.62; }
  .doc-meta { margin-bottom: 14px; }
  .doc-meta th, .doc-meta td, .doc-tasks th, .doc-tasks td { padding: 3px 10px; }
  .doc-sec { margin-bottom: 10px; }
  .doc-sec h2 { margin-bottom: 4px; }
  .doc-sec li { margin-bottom: 1px; }
  .doc-sign { margin-top: 14px; gap: 20px; }
  .sig { padding: 6px 12px 0; }
  .sig h3 { margin-bottom: 4px; }
  .sig-row { margin-bottom: 8px; }
  .sig-row.tall .ln { min-height: 32px; }
  .doc-foot { margin-top: 8px; padding-top: 5px; }
  /* printing a saved session: only its sheet */
  body.printing > :not(.print-sheet) { display: none !important; }
  body.printing > .print-sheet { display: block !important; }
}
