/* طليطلة — mobile & tablet web app. Same glass theme as the desktop app. */
:root {
  --accent: #79DCC4; --fs: 1;
  --bg: #11131C; --surface: rgba(255,255,255,.075); --surface2: rgba(255,255,255,.12); --raised: rgba(255,255,255,.15);
  --line: rgba(255,255,255,.09); --line2: rgba(255,255,255,.15);
  --text: #FFFFFF; --text2: #CBD1D8; --text3: #8B93A1; --warn: #F1BD80; --soon: #FFD08B; --danger: #EF8080; --gold: #E8C66A;
  --popup: #1B1E29; --on-accent: #10201C;
  --b1: rgba(121,220,196,.42); --b2: rgba(124,108,232,.44); --b3: rgba(232,162,92,.30);
  --radius: 20px; --shadow: 0 18px 50px -24px rgba(0,0,0,.7);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #DCE1E8; --surface: rgba(255,255,255,.34); --surface2: rgba(255,255,255,.5); --raised: rgba(255,255,255,.62);
  --line: rgba(0,0,0,.08); --line2: rgba(0,0,0,.13);
  --text: #1A2226; --text2: #44505A; --text3: #6B7780; --warn: #A3650F; --soon: #9A6A00; --danger: #B33030; --gold: #B8860B;
  --popup: #ECEFF3; --on-accent: #FFFFFF;
  --b1: rgba(15,176,138,.42); --b2: rgba(99,82,224,.36); --b3: rgba(240,127,46,.30);
  --shadow: 0 18px 40px -26px rgba(30,40,60,.45);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: calc(16px * var(--fs)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Dubai", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
bdi { unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }

/* glowing background, like the desktop window */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(24px); width: 70vmax; height: 70vmax; animation: drift 60s ease-in-out infinite alternate; }
.blobs .b1 { background: radial-gradient(circle, var(--b1), transparent 62%); top: -30vmax; inset-inline-end: -25vmax; }
.blobs .b2 { background: radial-gradient(circle, var(--b2), transparent 62%); bottom: -32vmax; inset-inline-start: -28vmax; animation-duration: 74s; }
.blobs .b3 { background: radial-gradient(circle, var(--b3), transparent 62%); top: 30%; left: 30%; width: 45vmax; height: 45vmax; animation-duration: 90s; }
@keyframes drift { from { transform: translate(0,0); } to { transform: translate(8vmax, 10vmax); } }
@media (prefers-reduced-motion: reduce) { .blobs i { animation: none; } }

/* ---------- shell ---------- */
.shell { max-width: 1400px; margin: 0 auto; padding: calc(var(--safe-t) + 10px) 16px calc(150px + var(--safe-b)); }
.top { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.brand .wm { height: 34px; display: block; }
html[lang="en"] .brand .wm { height: 28px; }
.wordmark { height: 100%; width: auto; display: block; }
.wordmark .wi { fill: var(--text); } .wordmark .wb { fill: var(--bg); } .wordmark .wm { fill: var(--accent); } .wordmark .wg { fill: var(--gold); }
.top-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.date-pill { font-size: .78rem; color: var(--text2); background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.frame { display: block; }
.sidebar, .focus-col { display: none; }
main { outline: none; min-width: 0; }

.view-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 2px 12px; }
.view-head h1 { font-size: 1.6rem; margin: 0; font-weight: 700; }
.view-head .search { flex: 1 1 200px; max-width: 340px; margin-inline-start: auto; }

/* bottom tabs (phones) */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b)); background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border-top: 1px solid var(--line);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none; color: var(--text3); text-decoration: none; font-size: .7rem; border-radius: 14px; cursor: pointer; }
.nav-item.on { color: var(--accent); }
.nav-item.on .ic { stroke-width: 2.2; }
.ic { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.fillable { fill: none; }
.ic.gold { stroke: var(--gold); }
[dir="rtl"] .ic.flip-next, [dir="ltr"] .ic.flip-prev { transform: scaleX(-1); }

.fab {
  position: fixed; z-index: 31; inset-inline-end: 18px; bottom: calc(78px + var(--safe-b)); width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--accent) 70%, transparent); cursor: pointer;
}
.fab .ic { stroke-width: 2.4; }
.session-bar {
  position: fixed; z-index: 29; inset-inline: 12px; bottom: calc(76px + var(--safe-b)); display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line2); background: color-mix(in srgb, var(--popup) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--text); text-align: start; cursor: pointer; box-shadow: var(--shadow);
  margin-inline-end: 76px;
}
.session-bar .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .9rem; }
.session-bar .time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.session-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text3); flex: none; }
.session-bar .dot.live { background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.sync-bar { position: fixed; z-index: 40; inset-inline: 0; top: 0; height: calc(3px + var(--safe-t)); pointer-events: none; }
.sync-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #7C6CE8)); transition: width .3s; }
.sync-bar span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sync-btn.spin .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); }
.card.soft { background: var(--surface); padding: 14px; border-radius: 16px; }
.card h4, .card h3 { margin: 0 0 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 14px;
  border: 1px solid var(--line2); background: var(--surface2); color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none; transition: transform .12s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 600; }
.btn.primary.live { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .88rem; border-radius: 12px; }
.btn.big { min-height: 52px; font-size: 1.02rem; }
.btn.wide { width: 100%; justify-content: flex-start; }
.btn.grow, .grow { flex: 1 1 auto; min-width: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; flex: none; }
.icon-btn.tiny { width: 32px; height: 32px; border-radius: 10px; font-size: .9rem; }
.link-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); padding: 6px 2px; cursor: pointer; text-align: start; min-width: 0; }
.link-btn.strong { color: var(--accent); font-weight: 600; }
.input { width: 100%; min-height: 46px; padding: 10px 13px; border-radius: 13px; border: 1px solid var(--line2); background: var(--surface2); color: var(--text); font-size: 1rem; }
textarea.input { resize: vertical; line-height: 1.6; }
select.input { appearance: none; -webkit-appearance: none; }
.input.small { min-height: 36px; width: auto; padding: 4px 10px; font-size: .88rem; }
.input:focus { outline: none; border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-width: 0; }
.label, .field .label { color: var(--text2); font-size: .88rem; margin: 6px 0 4px; }
.hint { color: var(--text3); font-size: .8rem; margin: 2px 0; }
.hint.warn { color: var(--warn); }
.muted { color: var(--text2); } .small { font-size: .82rem; }
.accent-text { color: var(--accent); font-weight: 600; margin: 0; }
.center { text-align: center; justify-content: center; align-items: center; }
.row { display: flex; align-items: center; } .col { display: flex; flex-direction: column; }
.gap { gap: 12px; } .gap-s { gap: 8px; } .wrap { flex-wrap: wrap; } .end { justify-content: flex-end; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--text3); text-align: center; padding: 36px 16px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 999px; font-size: .78rem; background: var(--surface2); color: var(--text2); white-space: nowrap; }
.chip.accent { color: var(--accent); } .chip.warn { color: var(--warn); } .chip.soon { color: var(--soon); }
.chip.plan { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.chip.count { padding: 1px 10px; }
.chip.link { text-decoration: none; color: var(--text); }
.bar { height: 7px; border-radius: 9px; background: var(--surface2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: 14px; background: var(--surface2); }
.seg button { border: 0; background: none; padding: 9px 8px; border-radius: 11px; color: var(--text2); cursor: pointer; font-size: .9rem; }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface2); border-radius: 14px; padding: 4px; }
.stepper .icon-btn { border: 0; background: none; font-size: 1.3rem; }
.stepper .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--raised); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { inset-inline-start: 23px; }
.check { display: inline-flex; align-items: center; gap: 6px; flex: none; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- tasks ---------- */
.plan-line { color: var(--text2); font-size: .88rem; margin: 0 2px 6px; }
.plan-line.warn { color: var(--warn); }
.group-head { display: flex; align-items: center; gap: 10px; margin: 18px 4px 10px; }
.group-head h2 { font-size: 1.12rem; margin: 0; color: var(--accent); }
.group-head.warn h2 { color: var(--warn); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.task-card { display: flex; flex-direction: column; gap: 10px; }
.task-card.priority { border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; margin: 2px 0 0; font-size: 1.08rem; font-weight: 700; overflow-wrap: anywhere; }
.star { border: 0; background: none; width: 36px; height: 36px; color: var(--gold); }
.star .ic { stroke: var(--gold); }
.star.on .ic { fill: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.progress-strip { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 10px; }
.prog .cap { display: block; font-size: .76rem; color: var(--accent); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note { margin: 0; color: var(--text3); font-size: .85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.card-actions .btn { min-height: 42px; }

.links-strip .quick-links.compact { display: flex; flex-direction: row; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.links-strip .quick-links.compact::-webkit-scrollbar { display: none; }
.links-strip .ql-row { flex: none; }
.links-strip .ql { padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.links-strip .muted { display: none; }
.quick-links { display: flex; flex-direction: column; gap: 4px; }
.ql-row { display: flex; align-items: center; gap: 6px; }
.ql { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 8px 10px; border-radius: 12px; text-decoration: none; color: var(--text2); }
.ql:hover { background: var(--surface2); }
.favicon { width: 18px; height: 18px; border-radius: 4px; flex: none; }
.ql-tools { display: flex; gap: 4px; }
button.ql { font: inherit; background: none; border: 0; cursor: pointer; text-align: start; width: 100%; }
.quick-links.editing .ql { color: var(--text); background: var(--surface); border: 1px dashed var(--line2); }
.quick-links.editing .ql:hover { background: var(--surface2); }
.quick-links.compact.editing .ql-tools { gap: 2px; }
.quick-links.compact.editing .ql-tools .icon-btn.tiny { width: 26px; height: 30px; border-radius: 8px; }
.quick-links.compact.editing .ql { padding: 7px 8px; gap: 8px; }
.side-links .icon-btn.tiny.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.side-links .row { gap: 4px; }
.links-strip .ql-edit { color: var(--text3); padding: 7px 10px; }

/* ---------- sheets ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(5,8,14,.5); opacity: 0; transition: opacity .2s; }
.backdrop.in { opacity: 1; } .backdrop.leaving { opacity: 0; }
.sheet {
  position: fixed; z-index: 51; inset-inline: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--popup) 94%, transparent); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--line2); border-bottom: 0; border-radius: 24px 24px 0 0; box-shadow: 0 -20px 60px -20px rgba(0,0,0,.6);
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.sheet.in { transform: none; } .sheet.leaving { transform: translateY(100%); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px 6px; position: relative; }
.sheet-head .grab { position: absolute; top: 6px; left: 50%; width: 40px; height: 5px; border-radius: 9px; background: var(--line2); transform: translateX(-50%); }
.sheet-head h2 { flex: 1; font-size: 1.12rem; margin: 14px 0 4px; }
.sheet-head .close { margin-inline-start: auto; margin-top: 10px; }
.sheet-body { overflow-y: auto; padding: 6px 16px calc(20px + var(--safe-b)); overscroll-behavior: contain; }
.confirm .lead { font-size: 1.05rem; margin: 6px 0 18px; }
#toast {
  position: fixed; z-index: 60; inset-inline: 16px; bottom: calc(150px + var(--safe-b)); margin: 0 auto; max-width: 460px; padding: 12px 16px; border-radius: 14px;
  background: var(--popup); color: var(--text); border: 1px solid var(--line2); box-shadow: var(--shadow); text-align: center;
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
#toast.error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.more-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: 1rem; cursor: pointer; width: 100%; text-align: start; }
.link-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; align-items: center; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.step-title { color: var(--accent); margin: 14px 0 2px; font-size: 1rem; }
details summary { cursor: pointer; color: var(--accent); padding: 6px 0; }
.add-step-files { padding: 4px 0 8px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--surface2); border-top-color: var(--accent); animation: spin .9s linear infinite; margin: 10px auto; }

/* focus / timer */
.focus { display: flex; flex-direction: column; gap: 8px; }
.focus-title { margin: 6px 0 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.ring { width: 210px; height: 210px; border-radius: 50%; margin: 18px auto 6px; display: grid; place-items: center; border: 8px solid var(--surface2); position: relative; }
.ring.live { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 40px -10px var(--accent); }
.focus-time { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.big-time { font-size: 2.4rem; font-weight: 700; text-align: center; margin: 4px 0; color: var(--accent); font-variant-numeric: tabular-nums; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 12px 0 10px; }
.cal-head h2 { margin: 0; font-size: 1.15rem; }
.cal-layout { display: grid; gap: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-grid .wd { text-align: center; color: var(--text3); font-size: .72rem; padding: 2px 0 4px; }
.cal-day { min-height: 62px; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 2px; gap: 1px; cursor: pointer; }
.cal-day .n { font-weight: 600; font-size: .9rem; }
.cal-day .hj { font-size: .6rem; color: var(--text3); }
.cal-day.out { opacity: .38; }
.cal-day.today { border-color: var(--accent); }
.cal-day.today .n { color: var(--accent); }
.cal-day.sel { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.day-lbls { display: flex; flex-direction: column; gap: 2px; width: 100%; margin-top: 3px; min-width: 0; }
.day-lbl { display: block; width: 100%; font-size: .62rem; line-height: 1.3; padding: 1px 4px; border-radius: 5px; text-align: start;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); unicode-bidi: plaintext;
  background: color-mix(in srgb, var(--c) 24%, transparent); border-inline-start: 2px solid var(--c); }
.day-more { font-size: .6rem; color: var(--text3); line-height: 1.2; }
.cal-day.out .day-lbl { opacity: .8; }
@media (max-width: 599px) {
  .day-lbl { font-size: .52rem; padding: 0 2px; border-radius: 3px; }
  .day-lbls .day-lbl:nth-child(n+3) { display: none; }
}
.marks { display: flex; gap: 3px; margin-top: auto; }
.marks i { width: 6px; height: 6px; border-radius: 50%; }
.m-due { background: var(--warn); } .m-study { background: var(--accent); }
.day-details h3 { font-size: 1rem; }
.day-details h4 { color: var(--accent); font-size: .88rem; margin: 8px 0 2px; }
.agenda-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface2); border: 0; color: var(--text); text-align: start; width: 100%; }
.agenda-item.due { border-inline-start: 3px solid var(--warn); cursor: pointer; }

/* files */
.search { min-height: 42px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--text3); font-size: .88rem; margin-bottom: 4px; }
.crumbs .link-btn { color: var(--accent); }
.file-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-align: start; cursor: pointer; min-width: 0; }
.file-item.folder .ic:first-child { stroke: var(--accent); }
.file-item.off { opacity: .55; }
.ic.accent { stroke: var(--accent); }
.file-item .file-more { width: 30px; height: 30px; border: 0; background: none; margin-inline-start: 2px; opacity: .55; flex: none; }
.file-item:hover .file-more, .file-item .file-more:focus-visible { opacity: 1; }
.file-item { -webkit-touch-callout: none; user-select: none; }
.viewer img { max-width: 100%; border-radius: 12px; display: block; margin: 0 auto; }
.pdf-pages { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.pdf-page { background: #fff; border-radius: 6px; aspect-ratio: var(--ar, .7071); width: 100%; overflow: hidden; }
.pdf-page canvas { display: block; }

/* stats & archive */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat p { margin: 2px 0; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); text-align: center; margin: 6px 0 8px !important; font-variant-numeric: tabular-nums; }
.stats-table { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.srow { display: grid; grid-template-columns: 2.2fr 1fr 1fr 1fr; gap: 6px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface2); border: 0; color: var(--text); text-align: start; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
.srow.two { grid-template-columns: 3fr 1fr; }
.srow > bdi { text-align: center; }
.srow.head { background: none; color: var(--text3); font-weight: 600; font-size: .78rem; }
.srow .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline-start: calc(var(--d, 0) * 16px); }
.srow:not(.sub) .name { color: var(--accent); font-weight: 600; }
.sessions { padding: 6px 10px 10px; }
.session { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }

/* settings */
.settings-grid { columns: 3 300px; column-gap: 12px; }
.settings-grid > * { break-inside: avoid; margin: 0 0 12px; width: 100%; }
.settings-card { display: flex; flex-direction: column; gap: 8px; }
.card-h { display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: 1.05rem; margin: 0 0 4px !important; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line2); cursor: pointer; }
.swatch.auto { width: auto; padding: 0 14px; border-radius: 999px; background: var(--surface2); color: var(--text2); font-size: .82rem; }
.swatch.on { border: 3px solid var(--text); }

/* ---------- iPad / desktop: sidebar like the Windows app ---------- */
@media (min-width: 900px) {
  .shell { padding-bottom: 40px; }
  .frame { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 20px; align-items: start; }
  body.with-focus .frame { grid-template-columns: 236px minmax(0, 1fr) 300px; }
  .sidebar { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 14px; max-height: calc(100dvh - 28px); }
  .side-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
  .side-nav .nav-item { flex-direction: row; gap: 12px; font-size: .98rem; padding: 11px 14px; color: var(--text2); }
  .side-nav .nav-item.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 600; }
  .side-links { padding: 10px; min-height: 0; overflow-y: auto; }
  .side-links h4 { color: var(--text3); font-size: .85rem; margin: 2px 8px 6px; }
  .focus-col { display: block; position: sticky; top: 14px; }
  body:not(.with-focus) .focus-col { display: none; }
  .tabbar, .fab, .links-strip, .session-bar { display: none !important; }
  #toast { bottom: 30px; }
  .sheet { inset: auto; left: 50%; top: 50%; bottom: auto; width: min(620px, 92vw); max-height: 86dvh; border-radius: 24px; border-bottom: 1px solid var(--line2);
    transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet.wide { width: min(880px, 94vw); }
  .sheet.in { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.leaving { transform: translate(-50%, -46%) scale(.98); opacity: 0; }
  .sheet-head .grab { display: none; }
  .cal-layout { grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); align-items: start; }
  .cal-day { aspect-ratio: auto; min-height: 84px; }
  .view-head h1 { font-size: 1.9rem; }
}
@media (max-width: 380px) {
  .date-pill { display: none; }
  .srow { grid-template-columns: 1.6fr 1fr 1fr 1fr; font-size: .76rem; padding: 9px 8px; }
}

/* 1.0.3 — form rows never overflow (iOS date/time inputs have a wide built-in size) */
.field { min-width: 0; }
.row.gap > .field { flex: 1 1 0; min-width: 0; }
input[type=date].input, input[type=time].input { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; display: block; text-align: start; line-height: 1.4; }
input[type=date].input::-webkit-date-and-time-value, input[type=time].input::-webkit-date-and-time-value { text-align: start; }
.sheet .card, .sheet section { min-width: 0; overflow: hidden; }

/* calendar */
.cal-tools { margin-bottom: 4px; }
.cal-main { min-width: 0; }
.cal-main .cal-head { margin-top: 4px; }
.m-ev { background: var(--accent); }
.agenda-item.event { text-align: start; }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ev, var(--accent)); flex: none; }
.cal-choice { display: flex; align-items: center; gap: 10px; padding: 6px 2px; cursor: pointer; }
.cal-choice input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* files back / forward */
.files-nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.files-nav .icon-btn { width: 36px; height: 36px; flex: none; }
.files-nav .icon-btn[disabled] { opacity: .35; pointer-events: none; }
.files-nav .crumbs { min-width: 0; flex: 1; }

.sep-line { border: 0; border-top: 1px solid var(--line2); margin: 10px 0; width: 100%; }

/* ---------- «اكتب على الملف» (ink editor) ---------- */
html.ink-open, html.ink-open body { overflow: hidden; }
.ink-editor { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; background: var(--bg); padding-top: var(--safe-t); }
.ink-editor.closing { opacity: .6; pointer-events: none; }
.ink-tools { direction: ltr; display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, var(--surface2)); overflow-x: auto; scrollbar-width: none; flex: none; }
.ink-tools::-webkit-scrollbar { display: none; }
.ink-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; border: 1px solid transparent; background: none; color: var(--text); cursor: pointer; }
.ink-btn.on { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
.ink-btn:active { transform: scale(.94); }
.ink-sep { width: 1px; height: 26px; background: var(--line2); margin: 0 4px; flex: none; }
.ink-colors, .ink-sizes { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.ink-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); cursor: pointer; padding: 0; flex: none; }
.ink-color.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.ink-size { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: none; cursor: pointer; flex: none; }
.ink-size i { display: block; border-radius: 50%; background: var(--text2); }
.ink-size.on { border-color: var(--line2); background: var(--surface); }
.ink-size.on i { background: var(--accent); }
.ink-panes { direction: ltr; flex: 1; min-height: 0; display: flex; gap: 0; }
.ink-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); }
.ink-pane:last-child { border-inline-end: 0; }
.ink-editor.two .ink-pane.on .ink-pane-head { box-shadow: inset 0 -2px 0 var(--accent); }
.ink-pane-head { direction: rtl; display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: .86rem; font-weight: 600; border-bottom: 1px solid var(--line); flex: none; }
.ink-status { white-space: nowrap; font-weight: 500; }
.ink-status.warn { color: var(--warn); }
.ink-scroll { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; background: color-mix(in srgb, var(--bg) 70%, #000); }
.ink-page { position: relative; flex: none; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.35); border-radius: 3px; }
.ink-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ink-layer { touch-action: pan-x pan-y; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 720px) { .ink-editor.two .ink-panes { flex-direction: column; } .ink-editor.two .ink-pane { border-inline-end: 0; border-bottom: 1px solid var(--line); } }
.viewer-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.btn.small.icon-only { width: 40px; padding: 0; justify-content: center; }
.viewer-text { margin: 10px 0 0; padding: 14px; background: var(--surface); border-radius: 12px; max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; text-align: start; }
.viewer-media { width: 100%; max-height: 70vh; margin-top: 10px; border-radius: 12px; background: #000; }
audio.viewer-media { background: none; }
.file-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--surface); margin-bottom: 10px; min-width: 0; }
.file-card .col { min-width: 0; }
.file-badge { position: relative; flex: none; width: 54px; height: 62px; display: grid; place-items: center; color: var(--accent); }
.file-badge span { position: absolute; bottom: 4px; font-size: .62rem; font-weight: 700; background: var(--accent); color: #0b1714; border-radius: 5px; padding: 0 4px; }
.ink-editor.finger .ink-layer { touch-action: none; }
.ink-color.add { position: relative; display: inline-grid; place-items: center; background: var(--surface2); color: var(--text); font-weight: 700; font-size: 16px; line-height: 1; border-style: dashed; overflow: hidden; }
.ink-color-in { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.ink-color.own { box-shadow: inset 0 0 0 2px rgba(0,0,0,.18); }
.ink-seg { display: inline-flex; flex: none; border: 1px solid var(--line2); border-radius: 11px; overflow: hidden; }
.ink-seg button { border: 0; background: none; color: var(--text2); padding: 7px 10px; font: inherit; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.ink-seg button.on { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--accent); }
.ink-btn.danger { color: var(--danger); }
.ink-editor[data-tool="select"] .ink-layer { cursor: default; }
.ink-editor[data-tool="laser"] .ink-layer { cursor: pointer; }

.bb-list { max-height: 55vh; overflow: auto; }
.bb-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.bb-row input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.bb-row.have { opacity: .55; cursor: default; }
.bb-title { font-weight: 600; }
.view-head .bb-btn { flex: none; }
button.session { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); color: inherit; text-align: start; cursor: pointer; font: inherit; font-size: .82rem; }
button.session:hover { background: var(--surface); }
