@layer radix, base, components, screens, utilities;
/* styles/core/ec-tokens.css: the one place app colours, type scale and line heights are defined (css-core plan 2.2). Variables only, no rules.
   Load after ec-fonts.css and before ec-base.css. Names are the existing ones (tokens.css, public-r2.css), values are what the S1 screens render today;
   nothing here was renamed or re-valued. Components and screens read --ec-* and --lh-* and never name a palette colour (--paper-*, --ink-*, --envoy-*, ...).
   Only what the S1 screens need is carried over; later stages add their variables here. The root tokens.css (homepage-protected) is not loaded by screens that load this file.
   Palette and semantic values come from tokens.css; the dark block is the one dark theme (admin-login is the only dark screen).
   Surfaces: the default :root values are the paper surface (S1 screens). <html data-surface="console"> (admin.html, workspace.html) switches the semantic tokens to the
   console values that components.css section 0 used to define (grey scale, white background, 14px minimum text); the scales (spacing, radius, motion, shadow) are shared.
   Orange: --ec-action (#cf3600) is the only fill and small-text orange (white text 5.02:1); --ec-brand (#ff4d00) is decoration only (dots, bars, icons on dark). */
@layer base {
  :root {
    /* Palette: referenced by the semantic tokens below only. */
    --envoy-3: #ffedd3;
    --envoy-7: #fca364;
    --envoy-9: #ff4d00;
    --envoy-10: #f54100;
    --envoy-11: #cf3600;
    --envoyd-3: #341b05;
    --envoyd-7: #823c0d;
    --envoyd-9: #ff4d00;
    --envoyd-11: #ff9656;
    --paper-1: #fbf9f6;
    --paper-2: #f7f5f1;
    --paper-3: #efede8;
    --paper-6: #dbd7d0;
    --paper-7: #d1cdc5;
    --paper-10: #858179;
    --paper-11: #66625c;
    --paper-12: #22201b;
    --cream: #fffaf2;
    --ink-1: #12110f;
    --ink-2: #1a1917;
    --ink-3: #23221f;
    --ink-4: #2b2a26;
    --ink-5: #33312c;
    --ink-6: #3c3a35;
    --ink-7: #4b4842;
    --ink-10: #7e7a73;
    --ink-11: #b6b3ac;
    --ink-12: #f0eee9;
    --green-3: #e6f6eb;
    --green-6: #adddc0;
    --green-11: #218358;
    --green-12: #193b2d;
    --greend-3: #132d21;
    --greend-6: #20573e;
    --greend-11: #3dd68c;
    --amber-11: #ab6400;
    --amberd-11: #ffca16;
    --ruby-3: #feeaed;
    --ruby-6: #f8bfc8;
    --ruby-12: #64172b;
    --rubyd-3: #3a141e;
    --rubyd-6: #6f2539;
    --rubyd-11: #ff949d;
    /* Neutral scale of the console surface (white canvas, ink text). Referenced by the semantic tokens below only. */
    --n-0: #ffffff;
    --n-1: #f7f7f7;
    --n-2: #f2f2f2;
    --n-4: #dddddd;
    --n-7: #8a8a8a;
    --n-9: #6a6a6a;
    --n-12: #222222;

    /* Type scale and line height. */
    --ec-fs-body: 16px;
    --ec-fs-aux: 14px;
    --ec-fs-min: 13px;
    --lh-body: 1.6;
    --lh-heading: 1.28;

    /* Semantic colours (light). */
    --ec-bg: var(--paper-2);
    --ec-surface: var(--cream);
    --ec-surface-hover: var(--paper-1);
    --ec-surface-active: var(--paper-3);
    --ec-line: var(--paper-6);
    --ec-line-strong: var(--paper-7);
    --ec-field-bg: var(--paper-1);
    --ec-field-line: var(--paper-10);
    --ec-text: var(--paper-12);
    --ec-text-muted: var(--paper-11);
    --ec-accent-bg: var(--envoy-3);
    --ec-accent-line: var(--envoy-7);
    --ec-accent-text: var(--envoy-11);
    --ec-focus: var(--envoy-11);
    --ec-success-bg: var(--green-3);
    --ec-success-line: var(--green-6);
    --ec-success-text: var(--green-12);
    --ec-warning-solid-strong: var(--amber-11);
    --ec-danger-bg: var(--ruby-3);
    --ec-danger-line: var(--ruby-6);
    --ec-danger-text: var(--ruby-12);

    /* Action colour on every surface: one orange fill (#cf3600, white label 5.02:1, so a 16px label passes AA). The logo orange --ec-brand (#ff4d00) is decoration only (dots, rings, bars). */
    --ec-action: var(--envoy-11);
    --ec-action-hover: #b83700;
    --ec-action-active: #9e2f00;
    --ec-brand: var(--envoy-9);
    --ec-on-action: #ffffff;
    --ec-ink: var(--ink-1);
    --ec-on-ink: var(--n-0);

    /* Control metrics shared by every surface: two button heights (44, 36), one label size and weight for all buttons, one field height and radius. */
    --ctl-radius: 12px;
    --btn-height: 44px;
    --btn-height-sm: 36px;
    --btn-font-size: var(--ec-fs-body);
    --btn-font-weight: 700;
    --field-height: 44px;

    /* Floating consultation button: 56px round from 1024 up, with a content gutter wide enough that no control sits under it (button + 2 gaps). Below 1024 it is docked inside the bottom tab bar (48px), so it never covers content. */
    --fab-size: 56px;
    --fab-gap: var(--sp-8);
    --fab-gutter: calc(var(--fab-size) + 2 * var(--fab-gap));
    --fab-dock: 48px;
    --fab-dock-reserve: calc(var(--fab-dock) + var(--sp-5) + var(--sp-2));

    /* Shell: one left menu width for the three consoles (app-shell.css and the partner sidebar read it), and the partner phone bars. */
    --shell-side-w: 240px;
    --mobile-top-bar-height: 56px;
    --mobile-tab-bar-height: 64px;
    --accent-dot: var(--ec-brand);

    /* Sheet and dialog padding (ec-sheet): head and actions are pinned with this padding, the body scrolls between them. */
    --sheet-pad: var(--sp-8);
    --sheet-pad-b: calc(var(--sheet-pad) + env(safe-area-inset-bottom, 0px));

    /* Scales shared by every surface. */
    --sp-1: 2px;
    --sp-2: 4px;
    --sp-3: 6px;
    --sp-4: 8px;
    --sp-5: 12px;
    --sp-6: 16px;
    --sp-7: 20px;
    --sp-8: 24px;
    --sp-9: 32px;
    --sp-10: 40px;
    --sp-11: 56px;
    --sp-12: 72px;
    --r-1: 6px;
    --r-2: 8px;
    --r-3: 12px;
    --r-4: 16px;
    --r-5: 24px;
    --r-pill: 999px;
    --mo-1: 120ms cubic-bezier(0.2, 0, 0.38, 0.9);
    --mo-2: 180ms cubic-bezier(0.2, 0, 0.38, 0.9);
    --mo-3: 260ms cubic-bezier(0.16, 1, 0.3, 1);
    --sh-pop: 0 8px 24px rgba(0, 0, 0, 0.12);
    --sh-lift: 0 6px 20px rgba(0, 0, 0, 0.08);
    --realm-badge-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --focus-offset: 2px;

    /* Legacy R2 aliases, only the ones the 404 page reads. Retired when the other screens move to --ec-* (css-core S5). */
    --r2-surface: var(--n-0);
    --r2-text: var(--n-12);
    --r2-text-muted: var(--n-9);
    --r2-line: var(--n-4);
    --r2-radius-input: 12px;
    --r2-accent: var(--ec-action);
    --r2-accent-hover: var(--ec-action-hover);
    --r2-accent-ink: #111111;
  }

  /* Japanese and Chinese documents: looser line height. */
  html[lang^="ja"], html[lang^="zh"] {
    --lh-body: 1.75;
    --lh-heading: 1.4;
  }

  /* Console surface: <html data-surface="console"> (operator console and creator workspace). Same names as the paper surface, the values components.css section 0 defined
     before css-core S2. Declared after :root so it wins at equal specificity. */
  [data-surface="console"] {
    color-scheme: light;
    --ec-bg: var(--n-0);
    --ec-bg-subtle: var(--n-1);
    --ec-surface: var(--n-0);
    --ec-surface-hover: var(--n-1);
    --ec-surface-active: var(--n-2);
    --ec-line: var(--n-4);
    --ec-line-strong: var(--n-7);
    --ec-field-bg: var(--n-0);
    --ec-field-line: var(--n-7);
    --ec-field-line-hover: var(--n-12);
    --ec-text: var(--n-12);
    --ec-text-muted: var(--n-9);
    --ec-text-disabled: var(--n-7);
    --ec-placeholder: var(--n-9);
    --ec-icon: var(--n-9);
    --ec-focus: var(--n-12);
    --ec-text-on-solid: var(--n-0);
    --ec-scrim: rgba(0, 0, 0, 0.4);
    --ec-info-bg: var(--n-2);
    --ec-info-text: var(--n-12);
    --ec-accent-bg: #ffede6;
    --ec-accent-text: var(--n-12);
    --ec-accent-text-strong: var(--n-12);
    --ec-danger-solid: #e54666;
    --ec-danger-solid-strong: var(--ruby-12);
    --ec-danger-text: var(--ruby-12);
    --ec-google-bg: #ffffff; /* sign-in provider faces: fixed by each provider's brand guide */
    --ec-google-text: #1f1f1f;
    --ec-kakao: #fee500;
    --ec-kakao-text: #191600;
    --ec-danger-ink: #b42318; /* danger button and danger link: red text and border, 6.5:1 on white */


    /* Status dots (decision D1, 2026-11-06): done = green, attention (your turn) = orange hollow ring (--ec-brand), in progress = ink, risk = red, nothing = grey.
       The components draw the ring; these variables only name the colour of each state. */
    --dot-neutral: var(--n-7);
    --dot-info: var(--n-12);
    --dot-success: var(--green-11);
    --dot-warning: var(--ec-brand);
    --dot-danger: #d92d20;

    /* Left menu (dark ink face, light text). Component variables of the shell read these. */
    --ec-nav-bg: var(--ec-ink);
    --ec-nav-text: var(--ink-11);
    --ec-nav-text-strong: var(--n-0);
    --ec-nav-line: color-mix(in srgb, var(--ec-nav-text-strong) 16%, var(--ec-nav-bg));
    --ec-nav-hover: color-mix(in srgb, var(--ec-nav-text-strong) 9%, var(--ec-nav-bg));
    --ec-nav-active: color-mix(in srgb, var(--ec-nav-text-strong) 17%, var(--ec-nav-bg));

    /* Type: body 16, label 14, three heading steps (screen title 32, 28 on phones / card title 22 / sub-heading inside a card 16). The button label is the body size. */
    --ec-fs-body: 16px;
    --ec-fs-aux: 14px;
    --ec-fs-min: 14px;
    --t-body-size: 16px;
    --t-body-lg-size: 16px;
    --t-body-weight: 400;
    --t-body-leading: var(--lh-body);
    --t-body-tracking: -0.005em;
    --t-label-size: 14px;
    --t-label-leading: 1.3;
    --t-caption-size: 12px;
    --t-appbar-size: 20px;
    --t-title-1-size: 32px;
    --t-title-1-leading: 1.28;
    --t-title-1-tracking: -0.025em;
    --t-title-2-size: 22px;
    --t-title-2-leading: 1.36;
    --t-title-2-tracking: -0.015em;
    --t-title-3-size: 16px;
    --t-title-3-leading: 1.4;
    --t-title-3-tracking: -0.015em;

    /* Rhythm. */
    --section-gap: var(--sp-8);
    --card-pad-x: var(--sp-8);
    --card-pad-y: var(--sp-8);
    --row-lead: 48px;
    --form-max: 760px;
    --form-col: 200px;
    --focus-ring: 2px solid var(--ec-focus);

    /* Icon masks (alpha only; a component paints them with background: <colour>). */
    --ec-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
    --ec-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm-1.5 14.5l-4-4 1.4-1.4 2.6 2.6 5.6-5.6 1.4 1.4-7 7z'/%3E%3C/svg%3E");
    --ec-icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    --ec-icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5-1.2-1.2L8.6 8 4.8 4.2z'/%3E%3C/svg%3E");
    --ec-icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 2.4L8 6.9l4.5-4.5 1.1 1.1L9.1 8l4.5 4.5-1.1 1.1L8 9.1l-4.5 4.5-1.1-1.1L6.9 8 2.4 3.5z'/%3E%3C/svg%3E");
    --ec-icon-globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.6 2.5 4 5.600 4 9s-1.400 6.500-4 9c-2.600-2.500-4-5.600-4-9s1.400-6.500 4-9z'/%3E%3C/svg%3E");
  }
  @media (max-width: 640px) {
    [data-surface="console"] {
      --t-title-1-size: 28px;
      --t-title-2-size: 22px;
      --card-pad-x: var(--sp-6);
      --card-pad-y: var(--sp-6);
      --sheet-pad: var(--sp-6);
    }
  }
  html[lang^="ja"][data-surface="console"], html[lang^="zh"][data-surface="console"] { --t-label-leading: 1.55; }

  /* The one dark theme: <html data-theme="dark"> (admin-login). Semantic tokens point at the ink palette. */
  [data-theme="dark"] {
    --ec-bg: var(--ink-1);
    --ec-surface: var(--ink-3);
    --ec-surface-hover: var(--ink-4);
    --ec-surface-active: var(--ink-5);
    --ec-line: var(--ink-6);
    --ec-line-strong: var(--ink-7);
    --ec-field-bg: var(--ink-2);
    --ec-field-line: var(--ink-10);
    --ec-text: var(--ink-12);
    --ec-text-muted: var(--ink-11);
    --ec-accent-bg: var(--envoyd-3);
    --ec-accent-line: var(--envoyd-7);
    --ec-accent-text: var(--envoyd-11);
    --ec-focus: var(--envoyd-9);
    --ec-success-bg: var(--greend-3);
    --ec-success-line: var(--greend-6);
    --ec-success-text: var(--greend-11);
    --ec-warning-solid-strong: var(--amberd-11);
    --ec-danger-bg: var(--rubyd-3);
    --ec-danger-line: var(--rubyd-6);
    --ec-danger-text: var(--rubyd-11);
  }
}
