/* =====================================================================
   The Office — design tokens (v2)
   Every colour, size and timing the UI uses lives here. Components read
   only these custom properties, so a theme is a matter of swapping them.
   Contrast ratios (WCAG 2.2) are noted next to every text/background pair.
   ===================================================================== */

:root {
  /* ---------------------------------------------------------- chrome (dark, around the room) */
  --bg: #232830;               /* app background */
  --bg-raised: #2e3440;        /* raised chrome: dock, top bar on phone */
  --bg-sunk: #1c2026;          /* wells: the rooms switcher track */
  --chrome-text: #fff6e8;      /* 13.83:1 on --bg */
  --chrome-muted: #cfc9c0;     /*  9.01:1 on --bg, 9.94:1 on --bg-sunk */
  --chrome-fill: rgba(255, 246, 232, 0.06);
  --chrome-fill-hover: rgba(255, 246, 232, 0.13);
  --chrome-fill-press: rgba(255, 246, 232, 0.20);
  --chrome-line: rgba(255, 246, 232, 0.38);   /* = #777676 on --bg, 3.27:1 (UI boundary ≥ 3:1) */
  --chrome-line-soft: rgba(255, 246, 232, 0.14); /* dividers only, never a control's only edge */

  /* ---------------------------------------------------------- paper (panels, cards, sheets) */
  --surface: #fff6e8;          /* paper */
  --surface-2: #f6e8d2;        /* paper, one step deeper: wells, rows, columns */
  --surface-3: #ead7ba;        /* dividers and quiet borders (decorative, not a control edge) */
  --surface-input: #fffdf8;    /* text fields */
  --ink: #3b2830;              /* 12.79:1 on --surface, 11.35:1 on --surface-2 */
  --ink-muted: #6c5660;        /*  6.25:1 on --surface,  5.54:1 on --surface-2 */
  --ink-placeholder: #806b75;  /*  4.83:1 on --surface-input */
  --ink-on-dark: #fff6e8;

  /* ---------------------------------------------------------- brand & action */
  --primary: #f4a883;          /* peach. Ink text on it: 7.03:1 */
  --primary-hover: #f7b793;    /* ink 7.93:1 */
  --primary-press: #e98f7a;    /* ink 5.66:1 */
  --accent-ink: #a84b2b;       /* clay: icons + small accent text on paper. 5.29:1 / 4.69:1 on --surface-2 */
  --selected: #f3cf7a;         /* gold "on" fill. Ink 9.15:1. Never alone: always with a check or inset edge */
  --selected-edge: rgba(59, 40, 48, 0.28);
  --gold-ink: #8a6412;         /* the lead's crown on paper, 5.01:1 */
  --rose-ink: #b8324f;         /* hearts, unread badges. White text on it 5.82:1; on paper 5.43:1 */
  --sage: #a2c291;             /* people-count pill. Ink 6.96:1 */
  --sky: #90b6de;

  /* ---------------------------------------------------------- feedback */
  --success: #3a7243;          /* 5.34:1 on paper */
  --success-soft: #dff2d3;     /* --success text on it 4.85:1 */
  --warning: #8a4a1c;          /* 6.37:1 on paper */
  --warning-soft: #fff1c9;     /* --warning text 6.07:1, ink 12.19:1 */
  --danger: #b3363c;           /* 5.58:1 on paper; white on it 5.98:1 */
  --danger-soft: #fde3e1;      /* --danger text 4.92:1 */
  --live: #e0525e;             /* recording / live dot (always paired with a word) */

  /* ---------------------------------------------------------- characters */
  --yazan: #34487a;            /* 8.33:1 on paper; paper on it 8.42:1 */
  --yazan-soft: #dce8f6;       /* --yazan text 7.19:1 */
  --habib: #22604f;            /* 6.87:1 on paper */
  --habib-soft: #dff0ea;

  /* ---------------------------------------------------------- presence (colour + shape, never colour alone) */
  --here: #6fc36a;             /* filled dot */
  --idle: #f3cf7a;             /* half dot */
  --away: #c7b3bd;             /* hollow ring */

  /* ---------------------------------------------------------- focus */
  --focus: #2b5f9e;            /* on paper: 6.06:1 vs --surface (≥ 3:1 for a focus indicator) */
  --focus-on-dark: #f3cf7a;    /* on chrome: 9.89:1 vs --bg */
  --focus-width: 3px;
  --focus-offset: 2px;

  /* ---------------------------------------------------------- type */
  --font: 'Rubik', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', 'Noto Sans Arabic', Tahoma, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-caption: 0.75rem;   /* 12 / 16  meta, timestamps only */
  --fs-small: 0.875rem;    /* 14 / 20  helper text, chips, list secondary */
  --fs-body: 1rem;         /* 16 / 24  body, inputs (16 stops iOS zoom) */
  --fs-label: 0.9375rem;   /* 15 / 20  button labels */
  --fs-title: 1.125rem;    /* 18 / 24  panel and section titles */
  --fs-h2: 1.375rem;       /* 22 / 28  dialog titles */
  --fs-display: 1.875rem;  /* 30 / 36  front page */
  --lh-tight: 1.2;
  --lh-snug: 1.33;
  --lh-body: 1.5;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-heavy: 800;

  /* ---------------------------------------------------------- space (4-based) */
  --s-0: 2px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --gutter: 16px;              /* phone side gutter */

  /* ---------------------------------------------------------- shape */
  --r-xs: 6px;    /* tiny chips, swatches */
  --r-sm: 8px;    /* controls: buttons, inputs, tool buttons */
  --r-md: 12px;   /* cards, rows, columns */
  --r-lg: 16px;   /* panels, dialogs, sheets */
  --r-pill: 999px;
  --bw: 2px;                                  /* the ink edge of paper controls */
  --edge: var(--bw) solid var(--ink);
  --edge-soft: 1px solid var(--surface-3);

  /* ---------------------------------------------------------- elevation: hard pixel shadows + one soft lift */
  --sh-1: 0 2px 0 rgba(20, 12, 18, 0.45);                                  /* buttons, chips */
  --sh-2: 0 3px 0 rgba(20, 12, 18, 0.55);                                  /* panels on the page */
  --sh-3: 0 4px 0 rgba(20, 12, 18, 0.5), 0 12px 32px rgba(0, 0, 0, 0.32);  /* popovers, toasts, floating */
  --sh-4: 0 6px 0 rgba(20, 12, 18, 0.5), 0 24px 60px rgba(0, 0, 0, 0.45);  /* dialogs, sheets */
  --scrim: rgba(24, 16, 22, 0.62);

  /* ---------------------------------------------------------- layers */
  --z-room: 0;
  --z-tags: 2;
  --z-room-ui: 4;     /* Habib, Yazan, floating tools over the room */
  --z-chrome: 10;     /* top bar, dock, bottom bar */
  --z-popover: 40;
  --z-modal: 50;
  --z-toast: 60;

  /* ---------------------------------------------------------- sizes */
  --tap: 44px;                 /* minimum touch target */
  --ctl-h: 40px;               /* chrome controls on desktop (hit area padded to 44) */
  --topbar-h: 56px;
  --dock-h: 56px;
  --bottombar-h: 64px;
  --icon: 20px;                /* the pixel icon grid is 10 units: 20px = 2 device px per unit (crisp) */
  --icon-lg: 30px;             /* 3x */
  --icon-sm: 10px;             /* 1x, decorations only */
  --sidebar-w: 360px;

  /* ---------------------------------------------------------- motion */
  --dur-press: 80ms;
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);  /* gestures over heads, toasts landing */

  /* ---------------------------------------------------------- safe areas */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  color-scheme: dark;
}

@media (pointer: coarse) {
  :root { --ctl-h: 44px; }
}

/* Arabic: a touch more leading, no tracking */
:root:lang(ar) { --lh-body: 1.65; --lh-snug: 1.5; }

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-press: 0ms;
    --dur-fast: 0ms;
    --dur-base: 80ms;   /* fades stay, movement goes */
    --dur-slow: 80ms;
    --ease-pop: linear;
  }
}
