/* =====================================================================
   Design tokens. Single source of truth. Builders: copy these names
   1:1 into the app (CSS custom properties or a Tailwind theme).
   Never hard-code a colour, size, radius, shadow or duration elsewhere.
   ===================================================================== */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Karantina";
  src: url("brand/Karantina-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Light is the default. The light set also applies to things that are always light whatever the theme:
   a document preview is paper, and an uploaded logo sits on white so a dark logo never disappears. */
:root, .paper, .ws-mark.has-logo, .int-logo:not(.is-text), .light-scope {
  color-scheme: light;

  /* ---- Typography -------------------------------------------------- */
  /* FB-53: the colour emoji fonts are named, so emoji show in colour on every system (without them some fall back to a
     black-and-white symbol font for older emoji); Inter has no emoji, so nothing else changes */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  --font-display: "Karantina", "Inter", sans-serif; /* brand display face: sign-in and brand moments only, never body text */
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* 6 sizes + 1 display. Line heights are paired per size. */
  --text-xs: 0.75rem;   /* 12  meta, timestamps, table headers      */
  --text-sm: 0.8125rem; /* 13  secondary text, labels, pills         */
  --text-md: 0.875rem;  /* 14  desktop body, controls, list rows     */
  --text-lg: 1rem;      /* 16  phone body, inputs everywhere, h3      */
  --text-xl: 1.25rem;   /* 20  section/pane titles, phone page title  */
  --text-2xl: 1.5rem;   /* 24  desktop page title, document totals    */
  --text-display: 2rem; /* 32  call screen name/timer only            */

  --lh-xs: 1rem;
  --lh-sm: 1.125rem;
  --lh-md: 1.25rem;
  --lh-lg: 1.5rem;
  --lh-xl: 1.75rem;
  --lh-2xl: 2rem;
  --lh-display: 2.5rem;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ---- Colour: neutrals ------------------------------------------- */
  --color-canvas: #f5f6f8;       /* app background behind panes      */
  --color-surface: #ffffff;      /* panes, cards, inputs             */
  --color-surface-2: #f0f1f4;    /* hover, zebra, inset wells        */
  --color-surface-3: #e6e8ec;    /* pressed, selected-muted          */
  --color-raised: #ffffff;       /* selected segment on its track    */
  --color-line: #e2e4e9;         /* hairlines, dividers              */
  --color-line-strong: #c9cdd5;  /* button outlines, dashed placeholders (decorative, 1.6:1) */
  --color-control-border: #8a909b; /* input/select/textarea/switch-off borders: 3.2:1 non-text vs white (WCAG 1.4.11) */
  --icon-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23464c57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); /* dropdown arrow */
  --color-ink: #16181d;          /* primary text        17.9:1 on white */
  --color-ink-2: #464c57;        /* secondary text       8.6:1 on white */
  --color-ink-3: #636a77;        /* meta text            5.4:1 on white, 4.9:1 on canvas */
  --color-ink-inverse: #ffffff;
  --color-scrim: rgba(22, 24, 29, 0.48);
  --color-scrim-drawer: rgba(22, 24, 29, 0.24);
  --color-skel-hi: #d9dce2;      /* loading shimmer highlight        */
  --color-toast: #16181d;        /* toast background (white text)    */
  --color-note-bg: #fffbeb;  --color-note-line: #f3e3b5;   /* note cards on a timeline  */
  --color-mark: #fff1b8;         /* search match highlight           */
  --color-ask-bg: #fff8e6;   --color-ask-line: #f3d38a;    /* a question for you        */
  --color-danger-zone-bg: #fffafa; --color-danger-zone-line: #f1b8b2;

  /* ---- Colour: Client Spike brand (logo pack: black, white, mint #4ae1b4) ---- */
  --brand-mint: #4ae1b4;
  --brand-black: #000000;
  --brand-mint-weak: #e3faf3;
  --brand-mint-line: #bdeedd;
  /* Strong selection (filter chips, feedback kind): brand black in light, brand mint in dark. */
  --color-strong: #000000;  --color-on-strong: #ffffff;  --color-strong-accent: #4ae1b4;

  /* Primary buttons: brand mint with black text (12.4:1). */
  --color-primary: #4ae1b4;
  --color-primary-hover: #33d3a4;
  --color-primary-pressed: #22bf91;
  --color-on-primary: #000000;

  /* Action accent: links, switches, focus, selected. Mint is too light for text on white, so the accent is a deep brand green. */
  --color-accent: #087a5b;        /* links, switches, focus   5.4:1 on white */
  --color-accent-hover: #066a4f;
  --color-accent-pressed: #055a43;
  --color-accent-weak: #e3faf3;   /* selected rows, accent pill bg (brand mint tint) */
  --color-accent-ink: #05573f;    /* text on accent-weak       8.5:1 */
  --color-on-accent: #ffffff;     /* text on a solid accent fill      */

  /* ---- Colour: status (always paired with a text label) ----------- */
  --color-good: #12693f;     --color-good-bg: #e4f3ea;      /* green: done, paid, connected   */
  --color-wait: #1a3f9e;     --color-wait-bg: #e9effc;      /* blue: waiting, sent, scheduled */
  --color-attn: #8a4a00;     --color-attn-bg: #fcefd8;      /* amber: needs attention, offline queue */
  --color-bad:  #b42318;     --color-bad-bg:  #fdeceb;      /* red: failed, missed, overdue, cancel */
  --color-hist: #464c57;     --color-hist-bg: #eceef2;      /* grey: history, draft, void     */
  --color-danger: #c42b1c;   --color-danger-hover: #a52416; /* destructive buttons (white text 5.4:1) */
  --color-call: #13804a;     --color-call-hover: #0f6b3d;   /* answer / call buttons (white text 5.0:1) */

  /* Document type identity: quote vs invoice must never look alike */
  --color-quote: #6b3fb3;    --color-quote-bg: #f2ecfb;     /* violet  7.0:1 on its bg */
  --color-invoice: #16181d;  --color-invoice-bg: #eceef2;   /* ink                    */

  /* ---- Spacing (4px base; only these values) ---------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* ---- Radii (3) --------------------------------------------------- */
  --radius-sm: 6px;    /* inputs, buttons, chips, small tiles */
  --radius-md: 10px;   /* cards, panes, popovers, sheets top   */
  --radius-pill: 999px;/* status pills, avatars, segmented    */

  /* ---- Elevation (borders for surfaces; shadows ONLY for overlays) - */
  --shadow-1: 0 1px 2px rgba(22, 24, 29, 0.06);                         /* dragged card, sticky bar */
  --shadow-2: 0 8px 24px rgba(22, 24, 29, 0.12), 0 1px 3px rgba(22,24,29,.08); /* popover, toast, menu */
  --shadow-3: 0 24px 64px rgba(22, 24, 29, 0.24);                       /* modal, sheet, call card */

  /* ---- Focus ------------------------------------------------------- */
  --focus-ring: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);

  /* ---- Motion ------------------------------------------------------ */
  --dur-fast: 120ms;    /* hover, press, toggles   */
  --dur-base: 200ms;    /* popovers, drawers fade  */
  --dur-slow: 320ms;    /* sheets, call screen     */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Layout ------------------------------------------------------ */
  --sidebar-w: 240px;
  --rail-w: 76px;
  --pane-header-h: 56px;
  --phone-header-h: 56px;
  --tabbar-h: 60px;
  --tap: 44px;          /* minimum touch target */
  --control-h: 36px;    /* desktop control height */
  --control-h-touch: 44px;
  --z-sticky: 10; --z-popover: 40; --z-drawer: 50; --z-sheet: 60; --z-modal: 70; --z-call: 80; --z-toast: 90;
}

/* The page itself allows both schemes (Google Modern Web Guidance: the root stays "light dark"); a chosen Light pins light,
   the dark rules below pin dark. Same colours as before: only the declared scheme of <html> changes. */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }

/* ---- Dark theme ----------------------------------------------------
   Chosen in the theme menu (Light / Dark / System, saved on this device) or, on System, by the device setting.
   Same names as above; only the colours change. Brand mint is bright enough to be the accent on dark. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-canvas: #0f1114;
  --color-surface: #171a1e;
  --color-surface-2: #1f2327;
  --color-surface-3: #2a2f34;
  --color-raised: #353b42;
  --color-line: #2c3136;
  --color-line-strong: #3f454d;
  --color-control-border: #767d88;
  --icon-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23c4c9d1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  --color-ink: #eceef1;
  --color-ink-2: #c4c9d1;
  --color-ink-3: #a1a8b3;
  --color-ink-inverse: #16181d;
  --color-scrim: rgba(0, 0, 0, 0.62);
  --color-scrim-drawer: rgba(0, 0, 0, 0.5);
  --color-skel-hi: #353a40;
  --color-toast: #353b42;
  --color-note-bg: #2a2412;  --color-note-line: #4d4119;
  --color-mark: #5c4a0e;
  --color-ask-bg: #2a2412;   --color-ask-line: #5a4614;
  --color-danger-zone-bg: #1d1514; --color-danger-zone-line: #5e2a24;
  --brand-mint-weak: #0f2e26;
  --brand-mint-line: #1f5a48;
  --color-strong: #4ae1b4;  --color-on-strong: #000000;  --color-strong-accent: #000000;
  --color-primary: #4ae1b4;
  --color-primary-hover: #6be8c3;
  --color-primary-pressed: #33d3a4;
  --color-on-primary: #000000;
  --color-accent: #4ae1b4;
  --color-accent-hover: #6be8c3;
  --color-accent-pressed: #33d3a4;
  --color-accent-weak: #0f2e26;
  --color-accent-ink: #7eeccb;
  --color-on-accent: #000000;
  --color-good: #5ad19a;     --color-good-bg: #0f2a1d;
  --color-wait: #93b2ff;     --color-wait-bg: #172340;
  --color-attn: #f4b84d;     --color-attn-bg: #2d2210;
  --color-bad:  #ff8b7d;     --color-bad-bg:  #361815;
  --color-hist: #b6bcc6;     --color-hist-bg: #262a2f;
  --color-danger: #d63b2c;   --color-danger-hover: #e5503f;
  --color-call: #13804a;     --color-call-hover: #179456;
  --color-quote: #bb9bff;    --color-quote-bg: #261c3c;
  --color-invoice: #eceef1;  --color-invoice-bg: #262a2f;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 0 0 1px #3f454d, 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 0 0 1px #3f454d, 0 24px 64px rgba(0, 0, 0, 0.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-canvas: #0f1114;
    --color-surface: #171a1e;
    --color-surface-2: #1f2327;
    --color-surface-3: #2a2f34;
    --color-raised: #353b42;
    --color-line: #2c3136;
    --color-line-strong: #3f454d;
    --color-control-border: #767d88;
    --icon-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23c4c9d1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    --color-ink: #eceef1;
    --color-ink-2: #c4c9d1;
    --color-ink-3: #a1a8b3;
    --color-ink-inverse: #16181d;
    --color-scrim: rgba(0, 0, 0, 0.62);
    --color-scrim-drawer: rgba(0, 0, 0, 0.5);
    --color-skel-hi: #353a40;
    --color-toast: #353b42;
    --color-note-bg: #2a2412;  --color-note-line: #4d4119;
    --color-mark: #5c4a0e;
    --color-ask-bg: #2a2412;   --color-ask-line: #5a4614;
    --color-danger-zone-bg: #1d1514; --color-danger-zone-line: #5e2a24;
    --brand-mint-weak: #0f2e26;
    --brand-mint-line: #1f5a48;
    --color-strong: #4ae1b4;  --color-on-strong: #000000;  --color-strong-accent: #000000;
    --color-primary: #4ae1b4;
    --color-primary-hover: #6be8c3;
    --color-primary-pressed: #33d3a4;
    --color-on-primary: #000000;
    --color-accent: #4ae1b4;
    --color-accent-hover: #6be8c3;
    --color-accent-pressed: #33d3a4;
    --color-accent-weak: #0f2e26;
    --color-accent-ink: #7eeccb;
    --color-on-accent: #000000;
    --color-good: #5ad19a;     --color-good-bg: #0f2a1d;
    --color-wait: #93b2ff;     --color-wait-bg: #172340;
    --color-attn: #f4b84d;     --color-attn-bg: #2d2210;
    --color-bad:  #ff8b7d;     --color-bad-bg:  #361815;
    --color-hist: #b6bcc6;     --color-hist-bg: #262a2f;
    --color-danger: #d63b2c;   --color-danger-hover: #e5503f;
    --color-call: #13804a;     --color-call-hover: #179456;
    --color-quote: #bb9bff;    --color-quote-bg: #261c3c;
    --color-invoice: #eceef1;  --color-invoice-bg: #262a2f;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 0 0 1px #3f454d, 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-3: 0 0 0 1px #3f454d, 0 24px 64px rgba(0, 0, 0, 0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur-base: 0ms; --dur-slow: 0ms; }
}

/* The phone's status bar and home indicator (viewport-fit=cover): every inset in the app reads these. In the phone
   app viewport.js puts the last good value back when iOS briefly reports 0 (e.g. after the in-app browser closes). */
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }
