/* BOD — design tokens. Light is the base; dark redefines the same tokens. All layout uses logical properties. */
@font-face { font-family: 'Plex'; src: url('../vendor/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: 'Plex'; font-weight: 700; src: url('../vendor/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: 'Plex'; src: url('../vendor/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Plex'; font-weight: 700; src: url('../vendor/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2') format('woff2'); font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eef2f6; --ink: #101828; --ink-2: #475467; --ink-3: #98a2b3;
  --line: #d0d5dd; --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #d9efec; --warn: #b45309; --warn-soft: #fef3e2;
  --danger: #b42318; --danger-soft: #fee4e2; --ok: #067647; --ok-soft: #dcfae6; --info: #1d4ed8; --info-soft: #e0e9ff;
  --shadow: 0 6px 24px rgba(16,24,40,.12); --radius: 14px; --tap: 44px;
  --font: 'Plex', 'IBM Plex Sans Arabic', 'Noto Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --lh: 1.45;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --surface: #121a2b; --surface-2: #1a2438; --ink: #eef2f7; --ink-2: #b4bccb; --ink-3: #7d879a;
  --line: #2a3650; --accent: #2dd4bf; --accent-ink: #062a27; --accent-soft: #123a37; --warn: #fbbf24; --warn-soft: #3a2a08;
  --danger: #f87171; --danger-soft: #3b1414; --ok: #4ade80; --ok-soft: #0f2e1c; --info: #93c5fd; --info-soft: #14244a;
  --shadow: 0 8px 28px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0b1220; --surface: #121a2b; --surface-2: #1a2438; --ink: #eef2f7; --ink-2: #b4bccb; --ink-3: #7d879a;
  --line: #2a3650; --accent: #2dd4bf; --accent-ink: #062a27; --accent-soft: #123a37; --warn: #fbbf24; --warn-soft: #3a2a08;
  --danger: #f87171; --danger-soft: #3b1414; --ok: #4ade80; --ok-soft: #0f2e1c; --info: #93c5fd; --info-soft: #14244a;
  --shadow: 0 8px 28px rgba(0,0,0,.5);
} }
html[dir="rtl"] { --lh: 1.7; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: var(--lh); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; color: var(--ink-2); }
p { margin: 0 0 .6em; }
.muted { color: var(--ink-2); } .tiny { font-size: .8rem; } .small { font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
html[dir="rtl"] .num { direction: ltr; }

.app { display: grid; grid-template-rows: auto 1fr auto; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px; background: var(--surface); border-block-end: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; }
.wordmark { font-weight: 700; letter-spacing: .12em; color: var(--accent); font-size: 1.1rem; }
.phase { font-size: .8rem; color: var(--ink-2); }
.hdr-actions { display: flex; gap: 4px; }
.iconbtn { min-width: var(--tap); min-height: var(--tap); border: 0; background: transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; font-size: 1.05rem; }
.iconbtn:active, .tab:active { background: var(--surface-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.dot.synced { background: var(--ok); } .dot.pending { background: var(--warn); } .dot.offline { background: var(--ink-3); } .dot.error { background: var(--danger); }
.sync-label { font-size: .75rem; color: var(--ink-2); }

.view { padding: 14px 14px calc(96px + env(safe-area-inset-bottom, 0px)); max-width: 880px; width: 100%; margin-inline: auto; min-width: 0; overflow-x: clip; }
.app > * { min-width: 0; }
@media (min-width: 900px) {
  .app { grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .tabbar { position: sticky; top: 61px; align-self: start; flex-direction: column; border-block-start: 0; border-inline-end: 1px solid var(--line); height: calc(100dvh - 61px); padding: 12px 8px; gap: 4px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 10px; padding-inline: 12px; border-radius: 10px; }
  .view { grid-column: 2; padding-block-end: 40px; }
  .fab { inset-inline-end: 28px; bottom: 28px; }
}
.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; display: flex; background: var(--surface); border-block-start: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (min-width: 900px) { .tabbar { position: sticky; inset-inline: auto; } }
.tab { flex: 1; min-height: 56px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .75rem; color: var(--ink-2); }
.tab .ico { font-size: 1.25rem; line-height: 1; }
.tab.active { color: var(--accent); font-weight: 700; }
.fab { position: fixed; z-index: 21; inset-inline-end: 16px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); min-height: 52px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1rem; box-shadow: var(--shadow); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-block-end: 12px; }
.card.tight { padding: 10px 12px; }
.card h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: .78rem; color: var(--ink-2); }
.stat.ok { background: var(--ok-soft); } .stat.warn { background: var(--warn-soft); } .stat.danger { background: var(--danger-soft); }
.bar { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-block-start: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s; }
.bar.over > i { background: var(--warn); }
.alert { border-radius: 12px; padding: 10px 12px; margin-block-end: 10px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent; }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.alert.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.alert .x { margin-inline-start: auto; border: 0; background: transparent; min-width: 36px; min-height: 36px; font-size: 1.1rem; }
.alert .body { flex: 1; }

.btn { min-height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-block-end: 12px; overflow-x: auto; }
.seg button { flex: 1 0 auto; min-height: 38px; border: 0; background: transparent; border-radius: 10px; white-space: nowrap; padding: 0 10px; color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.field { display: flex; flex-direction: column; gap: 4px; margin-block-end: 10px; }
.field label { font-size: .85rem; color: var(--ink-2); }
.field input, .field select, .field textarea { min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface); width: 100%; }
.field input[type=number] { direction: ltr; text-align: start; font-variant-numeric: tabular-nums; }
.field .hint { font-size: .78rem; color: var(--ink-3); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field.inline label { flex: 1; }
.field.inline input, .field.inline select { width: auto; min-width: 110px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-block-end: 1px solid var(--line); min-height: var(--tap); }
.list li:last-child { border-block-end: 0; }
.list .t { flex: 1; min-width: 0; }
.list .t .n { font-weight: 600; }
.list .t .s { font-size: .8rem; color: var(--ink-2); }
.list .r { text-align: end; font-size: .9rem; white-space: nowrap; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th, table.tbl td { text-align: start; padding: 8px 6px; border-block-end: 1px solid var(--line); vertical-align: top; }
table.tbl th { font-size: .78rem; color: var(--ink-2); font-weight: 600; }
.tbl-wrap { overflow-x: auto; }
.delta.up { color: var(--danger); } .delta.down { color: var(--ok); }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); }
.check input { width: 22px; height: 22px; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-block-end: 8px; background: var(--surface); }
summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; justify-content: space-between; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '›'; transform: rotate(90deg); color: var(--ink-3); }
details[open] summary::after { transform: rotate(-90deg); }
.prose p { margin-block-end: .7em; }
.prose h4 { margin-block-start: 1em; }
.callout { border-inline-start: 4px solid var(--accent); background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; margin-block-end: 10px; }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.gate { border-color: var(--info); background: var(--info-soft); }
.next { border: 1px dashed var(--accent); border-radius: 10px; padding: 8px 12px; margin-block-end: 10px; font-weight: 600; }
.exercise-img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.sets { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 8px; align-items: center; margin-block-end: 6px; }
.sets input { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; background: var(--surface); direction: ltr; }
.last { font-size: .8rem; color: var(--ink-2); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 31; background: var(--surface); border-start-start-radius: 20px; border-start-end-radius: 20px; padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px)); max-height: 92dvh; overflow-y: auto; box-shadow: var(--shadow); }
@media (min-width: 900px) { .sheet { inset-inline: auto; left: 50%; transform: translateX(-50%); width: 560px; bottom: 24px; border-radius: 20px; } }
.sheet .handle { width: 42px; height: 5px; border-radius: 4px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { display: flex; justify-content: space-between; align-items: center; }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.quick button { min-height: 68px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .8rem; font-weight: 600; }
.quick button .ico { font-size: 1.3rem; }
@media (max-width: 420px) { .quick { grid-template-columns: repeat(3, 1fr); } }
.toast { position: fixed; bottom: calc(140px + env(safe-area-inset-bottom, 0px)); inset-inline: 16px; z-index: 40; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; text-align: center; box-shadow: var(--shadow); }
.export-stage { position: absolute; inset-inline-start: -20000px; top: 0; width: 900px; }
.report { width: 860px; padding: 24px; background: #fff; color: #101828; font-family: var(--font); }
.report h1 { color: #0f766e; } .report table { width: 100%; border-collapse: collapse; font-size: 12px; } .report th, .report td { border: 1px solid #d0d5dd; padding: 4px 6px; text-align: start; }
.report th { background: #f4f6f9; }
.report .dual { display: flex; justify-content: space-between; gap: 12px; }
.card-png { width: 720px; padding: 28px; background: linear-gradient(135deg, #0f766e, #134e4a); color: #fff; font-family: var(--font); border-radius: 24px; }
.card-png .big { font-size: 44px; font-weight: 700; line-height: 1; }
.card-png .row { display: flex; gap: 16px; }
.card-png .k { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 14px; flex: 1; }
.card-png canvas { background: rgba(255,255,255,.08); border-radius: 14px; }
canvas.chart { width: 100% !important; height: 220px !important; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mirror { display: inline-block; }
html[dir="rtl"] .mirror { transform: scaleX(-1); }
.streak { display: flex; gap: 4px; }
.streak i { width: 14px; height: 14px; border-radius: 4px; background: var(--surface-2); display: inline-block; }
.streak i.on { background: var(--accent); }
.tag { font-size: .72rem; background: var(--surface-2); border-radius: 6px; padding: 1px 6px; color: var(--ink-2); margin-inline-end: 4px; }
.searchbar { display: flex; gap: 8px; margin-block-end: 10px; }
.searchbar input { flex: 1; min-height: var(--tap); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--surface); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; }
pre.code { background: var(--surface-2); border-radius: 10px; padding: 10px; font-size: .78rem; overflow-x: auto; direction: ltr; text-align: left; }
.kbd { font-family: ui-monospace, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
