/* HANDSCRIPT approved premium navigation: the desktop sidebar and the phone dock, with the filled
   duotone icons of sidebar-icons.js. Loaded from index.html <head>, so every box has its final size
   before the first paint. Painted with navigation tokens: Premium Dark keeps the approved navy panel,
   Premium Light uses a bright surface with the same icons and a light, clearly marked active row.
   Selectors are scoped to the signed-in shell so they win over the older theme sheets.
   Each row reads icon → label → chevron in the reading direction, so in Arabic and in English the icon
   comes before its window name; the panel's edge, corners, shadow and active stripe mirror with dir. */

/* ---------- Navigation tokens ---------- */
/* --nav-x: 1 when the sidebar sits on the right (Arabic, RTL), -1 on the left (English, LTR). */
:root{--nav-x:1}
:root[dir=ltr]{--nav-x:-1}
:root,:root[data-theme=light]{
 --nav-panel:linear-gradient(180deg,#FFFFFF 0%,#F7F9FF 55%,#EFF3FF 100%);--nav-glow:radial-gradient(120% 40% at calc(50% + 50% * var(--nav-x)) 0%,#7363EA14,transparent 60%);
 --nav-edge:#DCE4F7;--nav-shadow:inset calc(1px * var(--nav-x)) 0 0 #FFFFFF,calc(-16px * var(--nav-x)) 0 40px -28px #17244759;--nav-ink:#172447;--nav-ink-hover:#172447;
 --nav-chevron:#7363EA;--nav-divider:#DFE6F5;--nav-hover:#7363EA12;--nav-hover-line:#7363EA38;
 --nav-active:linear-gradient(90deg,#10BFD524 0%,#7363EA24 100%);--nav-active-line:#7363EA66;--nav-active-ink:#2E2391;--nav-active-edge:#10BFD5;
 --nav-active-glow:0 10px 24px -14px #7363EA99;--nav-active-shadow:inset calc(3px * var(--nav-x)) 0 0 #10BFD5,var(--nav-active-glow);--nav-active-chevron:#5B4BD6;--nav-footer:#6E7CA3;
 --nav-brand:linear-gradient(90deg,#172447 0%,#172447 42%,#0B8FA6 58%,#10BFD5 100%);--nav-logo-glow:drop-shadow(0 6px 14px #3B55D926);
 --icon-face:#1E2A6B;--icon-cut:#FFFFFF;--icon-glow:drop-shadow(0 2px 4px #3B55D933);--icon-glow-hover:drop-shadow(0 3px 8px #7363EA59) brightness(1.04);
 --icon-glow-active:drop-shadow(0 3px 7px #7363EA66);
 --dock-bg:linear-gradient(180deg,#FFFFFF,#F7F9FF);--dock-glass:linear-gradient(180deg,#FFFFFFE6,#F7F9FFE0);--dock-line:#D6DFF2;--dock-shadow:inset 0 1px 0 #FFFFFF,0 14px 30px #1724472e;--dock-ink:#3E4C70;--dock-hover:#7363EA14;
 --nav-header:#FFFFFF;--nav-header-line:#DCE4F7;--nav-focus:#5B4BD6;
}
:root[data-theme=dark]{
 --nav-panel:linear-gradient(180deg,#0B1A4A 0%,#08113A 55%,#060C2C 100%);--nav-glow:radial-gradient(120% 40% at calc(50% + 50% * var(--nav-x)) 0%,#1D2F8A55,transparent 60%);
 --nav-edge:#5B7BFF38;--nav-shadow:inset calc(1px * var(--nav-x)) 0 0 #8FB0FF14,calc(-12px * var(--nav-x)) 0 40px -18px #2563EB66;--nav-ink:#E6EDFF;--nav-ink-hover:#FFFFFF;
 --nav-chevron:#3B82F6;--nav-divider:#6D8DFF2E;--nav-hover:#3B82F61A;--nav-hover-line:#81A0FF38;
 --nav-active:linear-gradient(90deg,#2563EBF2 0%,#4F46E5EB 55%,#4F46E5E6 100%);--nav-active-line:#A5B4FC99;--nav-active-ink:#FFFFFF;--nav-active-edge:#22D3EE;
 --nav-active-glow:inset 0 1px 0 #FFFFFF2E,0 0 0 1px #22D3EE2E,0 10px 26px -10px #4F46E5,0 0 22px #3B82F659;
 --nav-active-shadow:inset calc(3px * var(--nav-x)) 0 0 #22D3EE,var(--nav-active-glow);--nav-active-chevron:#FFFFFF;--nav-footer:#5873B8;
 --nav-brand:linear-gradient(90deg,#FFFFFF 0%,#FFFFFF 42%,#67E8F9 58%,#22D3EE 100%);--nav-logo-glow:drop-shadow(0 6px 18px #22D3EE40);
 --icon-face:#0B1438;--icon-cut:#0B1438;--icon-glow:drop-shadow(0 2px 5px #22D3EE33);--icon-glow-hover:drop-shadow(0 0 7px #22D3EE88) brightness(1.08);
 --icon-glow-active:drop-shadow(0 2px 3px #0B1438B3) drop-shadow(0 0 6px #A5F3FC73);
 --dock-bg:linear-gradient(180deg,#172563,#0A1134);--dock-glass:linear-gradient(180deg,#172563E6,#0A1134E3);--dock-line:#60A5FA80;--dock-shadow:inset 0 1px 0 #FFFFFF1A,0 0 0 1px #7C3AED26,0 14px 34px #020617A6,0 0 26px #3B82F647;
 --dock-ink:#D5DEFA;--dock-hover:#3B82F61F;
 --nav-header:linear-gradient(180deg,#0B1A4A,#08113A);--nav-header-line:#5B7BFF38;--nav-focus:#67E8F9;
}

/* One active look everywhere: the phone dock's active item (and «المزيد» while open) wears the desktop sidebar's
   active row (--nav-active fill, line and ink, in each theme), without the sidebar's inline-edge stripe, which a
   small square button does not need. */
:root{--dock-active-bg:var(--nav-active);--dock-active-line:var(--nav-active-line);--dock-active-ink:var(--nav-active-ink);--dock-active-shadow:var(--nav-active-glow)}

/* ---------- Icons ---------- */
.hs-icon-defs{position:absolute;width:0;height:0;overflow:hidden;pointer-events:none}
:is(.side-nav,.mobile-dock) a>b.hs-nav-glyph{display:inline-grid;place-items:center;flex:0 0 48px;width:48px;height:48px;margin:0;font-size:0;line-height:0;text-shadow:none}
.hs-nav-icon{display:block;width:42px;height:42px;overflow:visible;pointer-events:none;filter:var(--icon-glow);transition:filter .2s ease}
.hs-nav-icon .hs-p{fill:url(#hs-g-main)}
.hs-nav-icon .hs-v{fill:url(#hs-g-violet)}
.hs-nav-icon .hs-c{fill:url(#hs-g-cyan)}
.hs-nav-icon .hs-k{fill:var(--icon-face)}
.hs-nav-icon .hs-w{fill:#fff}
.hs-nav-icon .hs-dim{fill-opacity:.82}
.hs-nav-icon .hs-h{fill:#fff;fill-opacity:.26}
.hs-nav-icon .hs-s{stroke:var(--icon-cut);stroke-width:1.1;paint-order:stroke}
.hs-nav-icon :is(.hs-l,.hs-wl,.hs-r){fill:none;stroke-linecap:round;stroke-linejoin:round}
.hs-nav-icon .hs-l{stroke:url(#hs-g-cyan);stroke-width:1.6}
.hs-nav-icon .hs-wl{stroke:#fff;stroke-width:1.6}
.hs-nav-icon .hs-thin{stroke-width:1.1;stroke-opacity:.75}
.hs-nav-icon .hs-r{stroke:url(#hs-g-main);stroke-width:2.4}
:is(.side-nav,.mobile-dock) a:is(:hover,:focus-visible) .hs-nav-icon{filter:var(--icon-glow-hover)}
:is(.side-nav,.mobile-dock) a.active .hs-nav-icon{filter:var(--icon-glow-active)}

/* ---------- Desktop sidebar (panel, logo, rows with chevrons) ---------- */
@media (min-width:761px){
 html[data-theme] body:not(.auth-gate) .app-shell{grid-template-columns:292px minmax(0,1fr)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar{padding-inline:12px;
  background:var(--nav-glow),var(--nav-panel);border:0;border-inline-end:1px solid var(--nav-edge);
  border-radius:0;border-start-end-radius:26px;border-end-end-radius:26px;box-shadow:var(--nav-shadow);
  color:var(--nav-ink);padding-bottom:22px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .brand-glyph.handscript-logo{background:none;box-shadow:none;filter:var(--nav-logo-glow)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .brand{flex-direction:column;gap:6px;padding:8px 8px 14px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .brand strong{font-family:'Space Grotesk',sans-serif;font-size:1.35rem;font-weight:800;letter-spacing:.02em;
  background:var(--nav-brand);-webkit-background-clip:text;background-clip:text;color:transparent}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav{display:grid;gap:2px;margin-top:6px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]{
  display:flex;align-items:center;gap:12px;min-height:64px;margin:0 8px;padding-block:8px;padding-inline:16px 12px;
  border:1px solid transparent;border-radius:14px;background:transparent;box-shadow:none;transform:none;
  color:var(--nav-ink);font-size:15px;font-weight:700;line-height:1.3;text-decoration:none;
  transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease,color .2s ease}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]>b{order:1}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]>span{order:2;white-space:nowrap}
 /* chevron (replaces the old shimmer pseudo-element) */
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]::after{
  content:"";order:3;position:static;inset:auto;display:block;flex:none;width:7px;height:7px;margin-inline-start:auto;
  border:solid var(--nav-chevron);border-width:2px 2px 0 0;border-radius:1px;background:none;transform:rotate(45deg);transition:border-color .2s ease;pointer-events:none}
 /* row divider */
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]::before{
  content:"";position:absolute;inset:auto 10px 0 10px;height:1px;background:linear-gradient(90deg,transparent,var(--nav-divider) 20%,var(--nav-divider) 80%,transparent);pointer-events:none}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]:is(:hover,:focus-visible):not(.active){background:var(--nav-hover);border-color:var(--nav-hover-line);color:var(--nav-ink-hover)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view].active{
  background:var(--nav-active);border-color:var(--nav-active-line);color:var(--nav-active-ink);box-shadow:var(--nav-active-shadow)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view].active::after{border-color:var(--nav-active-chevron)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]:is(.active,:hover)::before{opacity:0}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar::after{
  content:"HANDSCRIPT" / "";display:block;margin:20px 0 4px;text-align:center;font:600 11px 'Space Grotesk',sans-serif;letter-spacing:.6em;color:var(--nav-footer)}
}
@media (min-width:761px) and (max-width:1050px){
 html[data-theme] body:not(.auth-gate) .app-shell{grid-template-columns:256px minmax(0,1fr)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]{gap:10px;margin:0 4px;padding-block:8px;padding-inline:12px 10px;font-size:14px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view]>b.hs-nav-glyph{flex-basis:40px;width:40px;height:40px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .side-nav a[data-view] .hs-nav-icon{width:34px;height:34px}
}

/* ---------- Phone: header and dock (five items) ---------- */
@media (max-width:760px){
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar{background:var(--nav-header);border-bottom:1px solid var(--nav-header-line)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .brand-glyph.handscript-logo{background:none;box-shadow:none;filter:var(--nav-logo-glow)}
 /* A short header keeps the camera near the top; the dock already shows which section is open. */
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar{padding-block:6px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .brand{padding:0}
 html[data-theme] body:not(.auth-gate) .command-bar .breadcrumb{display:none}
 /* Header controls (language, theme, a guest's «تسجيل الدخول») are 44px touch targets. */
 html[data-theme] body:not(.auth-gate) .command-bar :is(.interface-controls button,.guest-badge-signin){min-height:44px;min-width:44px}
 /* The dock: a solid panel by default (and wherever backdrop-filter is missing, as in older Android WebViews); a
    slightly translucent, blurred panel where it is supported, so content scrolling underneath never clashes with the
    labels. The blur is kept off while the camera runs (performance.css turns it off for low-power phones and the
    camera; the dock alone is re-enabled here, outside the camera). Six items fit 360px: 6px edges, 4px padding, 2px gaps. */
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock{
  left:6px;right:6px;bottom:max(12px,env(safe-area-inset-bottom),var(--safe-area-inset-bottom,0px));gap:2px;min-height:86px;padding:6px 4px;border-radius:26px;
  background:var(--dock-bg);border:1px solid var(--dock-line);box-shadow:var(--dock-shadow)}
 @supports ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
  html[data-theme] body:not(.auth-gate):not(.camera-active)>nav.mobile-dock{background:var(--dock-glass);
   -webkit-backdrop-filter:blur(18px) saturate(1.4)!important;backdrop-filter:blur(18px) saturate(1.4)!important}
 }
 @supports not ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){
  html[data-theme] body:not(.auth-gate)>nav.mobile-dock{background:var(--dock-bg)}
 }
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more){
  flex:1 1 0;min-width:min-content;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:6px 1px 7px;
  border:1px solid transparent;border-radius:20px;background:transparent;color:var(--dock-ink);font-size:12px;font-weight:700;
  transition:background-color .2s ease,border-color .2s ease,color .2s ease,box-shadow .2s ease}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more)>b.hs-nav-glyph{flex:0 0 34px;width:34px;height:34px}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more) .hs-nav-icon{width:31px;height:31px}
 /* Labels: 12px (was 11px). Short dock names (app.js DOCK_LABELS: «المترجم», «تعلّم», «حسابي», "Chats"), centred, at most
    two lines that break only between words: never inside a word, never hyphenated, never clipped (the links keep
    overflow:hidden from product-upgrade.css). A slot is never narrower than its longest word (min-width:min-content),
    so a one-word label («الرئيسية», «المحادثات») with a large system font takes a little width from shorter ones instead
    of being cut at its edges. */
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more)>span{
  display:block;max-width:100%;font-size:12px;line-height:1.25;text-align:center;overflow-wrap:normal;word-break:normal;-webkit-hyphens:none;hyphens:none}
 /* English words are longer than the Arabic ones ("Translator"): on the narrowest phones they keep 12px (UI audit
    2026-12-01 I4, was 11.5px) with a hair less spacing; six items still fit 360px. */
 @media (max-width:374px){
  html[data-theme][lang=en] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more)>span{font-size:12px;letter-spacing:-.01em}
 }
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more)::after{content:none;transform:none}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a:is([data-view],.dock-more):is(:hover,:focus-visible):not(.active){background:var(--dock-hover);color:var(--nav-ink-hover)}
 /* ONE indicator: the filled active item (the desktop sidebar's active look); no underline. */
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a[data-view].active{
  color:var(--dock-active-ink);border-color:var(--dock-active-line);background:var(--dock-active-bg);box-shadow:var(--dock-active-shadow)}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a[data-view].active::after{content:none}

 /* Home, translator, chat, learn, account and "More" fit at 360px (no dock on home itself); the rest, model training
    included, live behind "More" (mobile-more.js), which is hidden when nothing is left behind it. */
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a[data-view="model-training"]{display:none}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a.dock-more{display:flex;cursor:pointer}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a.dock-more[hidden]{display:none}
 html[data-theme] body:not(.auth-gate)>nav.mobile-dock a.dock-more[aria-expanded="true"]{color:var(--dock-active-ink);border-color:var(--dock-active-line);background:var(--dock-active-bg);box-shadow:var(--dock-active-shadow)}
 .dock-sheet{position:fixed;inset:0;z-index:60}
 .dock-sheet[hidden]{display:none}
 .dock-sheet-backdrop{position:absolute;inset:0;background:#0b122680}
 .dock-sheet-panel{position:absolute;left:6px;right:6px;bottom:calc(var(--hs-dock-space,110px) + 8px);padding:14px;border-radius:24px;
  background:var(--dock-bg);border:1px solid var(--dock-line);box-shadow:var(--dock-shadow);color:var(--dock-ink)}
 .dock-sheet-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 4px 8px}
 .dock-sheet-head strong{font-size:16px;color:var(--hs-ink,inherit)}
 .dock-sheet-close{min-height:44px;padding:0 14px;border-radius:14px;border:1px solid var(--dock-line);background:transparent;color:inherit;font:inherit;font-size:14px}
 .dock-sheet-list{display:grid;gap:4px}
 .dock-sheet-list a{display:flex;align-items:center;gap:12px;min-height:52px;padding:6px 10px;border-radius:16px;color:inherit;text-decoration:none;font-size:15px;font-weight:700}
 .dock-sheet-list a:is(:hover,:focus-visible){background:var(--dock-hover);outline:none}
 .dock-sheet-list a:focus-visible{outline:2px solid var(--nav-focus);outline-offset:-2px}
 .dock-sheet-list a.active{color:var(--dock-active-ink);background:var(--dock-active-bg)}
 .dock-sheet-list a>b.hs-nav-glyph{display:inline-grid;place-items:center;flex:0 0 40px;width:40px;height:40px;font-size:0}
 .dock-sheet-list .hs-nav-icon{width:34px;height:34px}
}

/* ---------- Focus, motion, forced colours ---------- */
nav:is(.side-nav,.mobile-dock) a[data-view]:focus-visible{outline:2px solid var(--nav-focus);outline-offset:-3px}
@media (prefers-reduced-motion:reduce){.hs-nav-icon,.hs-nav-icon *,nav:is(.side-nav,.mobile-dock) a[data-view],nav:is(.side-nav,.mobile-dock) a[data-view]::after{transition:none!important}}
@media (forced-colors:active){.hs-nav-icon *{fill:CanvasText!important;stroke:Canvas!important}.hs-nav-icon :is(.hs-l,.hs-wl,.hs-r){fill:none!important;stroke:CanvasText!important}}

/* ---------- «من نحن» / About us (index.html .sidebar-secondary; phones: the account menu, home-menus.js) ----------
   Desktop: a small secondary link at the BOTTOM of the sidebar, under its own divider and just above the HANDSCRIPT
   wordmark (the sidebar's ::after). Smaller and muted (13px, 18px icon, no fill, no chevron) so it never competes
   with the five sections; a 44px target and a visible focus ring. Phones: never in the dock or «المزيد»; it is a row
   of the account menu (signed in), and the sign-in footer / home footer / settings links stay. */
:root,:root[data-theme=light]{--nav-about-ink:#46557F}
:root[data-theme=dark]{--nav-about-ink:#B4C3EC}
.sidebar-secondary{display:none}
@media (min-width:761px){
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .sidebar-secondary{display:block;margin:auto 8px 0;padding-top:10px;border-top:1px solid var(--nav-divider)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .sidebar-about{display:flex;align-items:center;gap:8px;min-height:44px;padding:6px 12px;
  border:1px solid transparent;border-radius:12px;color:var(--nav-about-ink);font-size:13px;font-weight:600;line-height:1.3;text-decoration:none;
  transition:background-color .2s ease,border-color .2s ease,color .2s ease}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .sidebar-about:is(:hover,:focus-visible){background:var(--nav-hover);border-color:var(--nav-hover-line);color:var(--nav-ink-hover)}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .sidebar-about:focus-visible{outline:2px solid var(--nav-focus);outline-offset:2px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar .sidebar-about-icon{flex:none;width:18px;height:18px}
 html[data-theme] body:not(.auth-gate) .app-shell>.sidebar::after{margin-top:12px}
}

/* UI audit 2026-12-01 I2: while the on-screen keyboard is open over a focused text field (keyboard-dock.js sets
   html.hs-kb-open) the phone dock steps aside so it never covers what is being typed; it returns when the keyboard
   closes. The offline pill then sits at the bottom edge instead of above the (hidden) dock. */
html.hs-kb-open body:not(.auth-gate)>nav.mobile-dock{display:none!important}
html.hs-kb-open.hs-has-dock body:not(.auth-gate) .offline-banner{bottom:calc(max(8px,env(safe-area-inset-bottom)) + 4px)}
