/* ==========================================================================
   Trymade design system trymade-ds-1.0
   Shared token + base stylesheet for every Trymade surface
   (index.html hub, landing.html, app.html, embed/configurator.html).

   Lives in assets/, so every url() below is relative to assets/.

   BRAND ASSETS (assets/brand/, copied verbatim, never recolour the cube)
     trymade-logo-on-{light,dark}.svg      viewBox 221.80 x 47.00, intrinsic 887 x 188  (ratio ~4.72 : 1)
     trymade-icon-on-{light,dark}.svg      viewBox 64 x 64, intrinsic 256 x 256        (ratio 1 : 1)
     trymade-wordmark-on-{light,dark}.svg  viewBox 162.64 x 37.88, intrinsic 651 x 152 (ratio ~4.29 : 1)

   FONTS (assets/fonts/, self-hosted variable woff2 from Google Fonts)
     Sora  600 / 700        latin + latin-ext  (display)
     Inter 400 / 500 / 600  latin + latin-ext  (body / UI)

   TOKENS (consumers depend on these exact names)
     Neutrals   --bg --surface --ink --ink-2 --muted --hairline --hairline-strong
                --dark --dark-2 --paper --wash
     Brand      --cobalt --cobalt-hi --cobalt-deep --cobalt-on-dark --cobalt-tint
     Accent     --accent --accent-ink --accent-deep --accent-tint
                (components only read --accent*, so the embed can white-label:
                 override --accent on :root; also override --accent-deep (hover /
                 strong text) and --accent-tint (selected bg) for a perfect match,
                 e.g. --accent-deep: color-mix(in srgb, <brand> 75%, #000).)
     Status     --success --success-tint --warning --warning-tint --danger
                --danger-tint --danger-deep
     Type       --f-display --f-body --f-mono
                --t-12 --t-14 --t-16 --t-18 --t-20 --t-24 --t-32 --t-40 --t-56
     Space      --s1 4 | --s2 8 | --s3 12 | --s4 16 | --s5 24 | --s6 32 |
                --s7 48 | --s8 64 | --s9 96 | --s10 128
     Radius     --r-control 10 | --r-card 16 | --r-media 24 | --r-pill 999
     Elevation  --shadow-1 --shadow-2 --shadow-3
     Motion     --dur-1 160ms | --dur-2 240ms | --dur-3 360ms | --ease-out | --ease-in
     Focus      --focus-ring

   ORDER OF THIS FILE
     1. OD layout primitives (@layer od-layout, declared first so the layer is lowest)
     2. @font-face
     3. :root tokens
     4. Reset + base
     5. Components (prefix tm-)
     6. Reduced motion
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. OD layout primitives (verbatim from .od-frames/layout.css)
   -------------------------------------------------------------------------- */

/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio.
   Put this @layer first; product CSS outside the layer always wins. */
@layer od-layout {
  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
  .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
/* /OD-LAYOUT-PRIMITIVES v1 */


/* --------------------------------------------------------------------------
   2. @font-face
   Google serves Sora and Inter as variable fonts: one file per subset covers
   every weight, so the same file is reused across the weight rules below.
   latin-ext carries the French accents beyond Latin-1 (œ is in latin).
   -------------------------------------------------------------------------- */

/* Sora 600 */
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/sora-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/sora-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Sora 700 */
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/sora-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/sora-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Inter 400 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Inter 500 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/inter-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/inter-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Inter 600 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


/* --------------------------------------------------------------------------
   3. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Neutrals: cool greys only, no beige/cream grounds */
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --ink: #111318;
  --ink-2: #3A3F4B;
  --muted: #5B616E;
  --hairline: #E3E5EA;
  --hairline-strong: #CDD1D8;
  --dark: #0E1016;
  --dark-2: #171A22;
  --paper: #F5F6F8;
  --wash: rgba(17, 19, 24, .05);        /* ghost hover, segmented track, neutral fills */

  /* Brand cobalt */
  --cobalt: #2747E8;
  --cobalt-hi: #5B78FF;
  --cobalt-deep: #1A2FA8;
  --cobalt-on-dark: #8FA2FF;
  --cobalt-tint: #EEF1FE;               /* selected backgrounds */

  /* Accent: what components actually read (white-label hook) */
  --accent: var(--cobalt);
  --accent-ink: #FFFFFF;                /* text on --accent */
  --accent-deep: var(--cobalt-deep);    /* primary hover + strong accent text */
  --accent-tint: var(--cobalt-tint);    /* selected backgrounds */

  /* Status */
  --success: #0F7B4F;
  --success-tint: #E7F5EE;
  --warning: #A15C00;
  --warning-tint: #FDF2E3;
  --danger: #C2253A;
  --danger-tint: #FCEBED;
  --danger-deep: #9E1C2F;               /* danger button hover */

  /* Type families */
  --f-display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --f-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale */
  --t-12: 12px;
  --t-14: 14px;
  --t-16: 16px;
  --t-18: 18px;
  --t-20: 20px;
  --t-24: 24px;
  --t-32: 32px;
  --t-40: 40px;
  --t-56: 56px;

  /* Spacing */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;
  --s10: 128px;

  /* Radius */
  --r-control: 10px;
  --r-card: 16px;
  --r-media: 24px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(17, 19, 24, .06);
  --shadow-2: 0 12px 32px rgba(17, 19, 24, .10);
  --shadow-3: 0 24px 64px rgba(17, 19, 24, .16);

  /* Motion */
  --dur-1: 160ms;
  --dur-2: 240ms;
  --dur-3: 360ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);

  /* Focus */
  --focus-ring: 0 0 0 3px rgba(39, 71, 232, .35);
}


/* --------------------------------------------------------------------------
   4. Reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 400 var(--t-16)/1.6 var(--f-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Margins are zeroed; each surface owns its own vertical rhythm. */
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: balance;
}

p { text-wrap: pretty; }

img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-underline-offset: .2em; }

::selection { background: var(--accent-tint); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@keyframes tm-spin { to { transform: rotate(360deg); } }


/* --------------------------------------------------------------------------
   5. Components
   Rules: every value from a token; touch targets >= 44px; hover only under
   (hover: hover); hover never lightens or greys text.
   -------------------------------------------------------------------------- */

/* ---- Container ---------------------------------------------------------- */
.tm-container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--s5);
}
@media (max-width: 480px) {
  .tm-container { padding-inline: var(--s4); }
}


/* ---- Button -------------------------------------------------------------
   <button class="tm-btn tm-btn--primary">Label</button>
   Colours flow through --btn-bg / --btn-fg / --btn-border so variants and
   states only swap variables.                                               */
.tm-btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--btn-border);
  border-radius: var(--r-control);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 600 15px/1 var(--f-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.tm-btn > svg { width: 18px; height: 18px; flex: none; }
.tm-btn:active:not(:disabled, [aria-disabled="true"], .is-loading) { transform: translateY(1px); }

.tm-btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  box-shadow: var(--shadow-1);
}
.tm-btn--secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: var(--hairline-strong);
}
.tm-btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
}
.tm-btn--danger {
  --btn-bg: var(--danger);
  --btn-fg: #FFFFFF;
  box-shadow: var(--shadow-1);
}

@media (hover: hover) {
  .tm-btn--primary:hover:not(:disabled, [aria-disabled="true"], .is-loading)   { --btn-bg: var(--accent-deep); }
  .tm-btn--secondary:hover:not(:disabled, [aria-disabled="true"], .is-loading) { --btn-border: var(--ink); }
  .tm-btn--ghost:hover:not(:disabled, [aria-disabled="true"], .is-loading)     { --btn-bg: var(--wash); }
  .tm-btn--danger:hover:not(:disabled, [aria-disabled="true"], .is-loading)    { --btn-bg: var(--danger-deep); }
}

/* Sizes. --sm is for the dense desktop dashboard only: the visual box is
   36px but an invisible ::before keeps the hit area at 44px. */
.tm-btn--sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: var(--t-14);
}
.tm-btn--sm::before {
  content: "";
  position: absolute;
  inset: -5px 0;
}
.tm-btn--lg {
  min-height: 52px;
  padding: 0 24px;
  font-size: var(--t-16);
}
.tm-btn--block { width: 100%; }

/* Disabled */
.tm-btn:disabled,
.tm-btn[aria-disabled="true"] {
  --btn-bg: var(--hairline);
  --btn-fg: var(--muted);
  --btn-border: transparent;
  box-shadow: none;
  cursor: not-allowed;
}
.tm-btn--ghost:disabled,
.tm-btn--ghost[aria-disabled="true"] { --btn-bg: transparent; }

/* Loading: label hidden (colour transparent), spinner in --btn-fg */
.tm-btn.is-loading {
  color: transparent;
  pointer-events: none;
}
.tm-btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: tm-spin .7s linear infinite;
}


/* ---- Icon button --------------------------------------------------------
   <button class="tm-icon-btn" aria-label="Close"><svg>…</svg></button>      */
.tm-icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
.tm-icon-btn > svg { width: 20px; height: 20px; }
.tm-icon-btn:disabled,
.tm-icon-btn[aria-disabled="true"] { color: var(--muted); cursor: not-allowed; }
@media (hover: hover) {
  .tm-icon-btn:hover:not(:disabled, [aria-disabled="true"]) { background: var(--wash); }
}


/* ---- Form fields --------------------------------------------------------
   <div class="tm-field">
     <label class="tm-label" for="x">Email <span class="tm-required" aria-hidden="true">*</span></label>
     <input class="tm-input" id="x" aria-describedby="x-help">
     <p class="tm-help" id="x-help">We only use it to send your quote.</p>
     <p class="tm-error"><svg aria-hidden="true">…</svg>Enter a valid email.</p>
   </div>                                                                    */
.tm-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.tm-label {
  font-size: var(--t-14);
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-2);
}
.tm-help {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.tm-required {
  margin-inline-start: 2px;
  color: var(--danger);
  font-weight: 600;
}

.tm-input,
.tm-select,
.tm-textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font: 400 var(--t-16)/1.4 var(--f-body);   /* 16px: no iOS zoom on focus */
  transition:
    border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out);
}
.tm-input::placeholder,
.tm-textarea::placeholder { color: var(--muted); opacity: 1; }

.tm-textarea {
  min-height: 96px;
  resize: vertical;
}

.tm-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%235B616E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  cursor: pointer;
}

@media (hover: hover) {
  .tm-input:hover:not(:focus, :disabled),
  .tm-select:hover:not(:focus, :disabled),
  .tm-textarea:hover:not(:focus, :disabled) { border-color: var(--muted); }
}

.tm-input:focus,
.tm-select:focus,
.tm-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.tm-input:disabled,
.tm-select:disabled,
.tm-textarea:disabled {
  background: var(--paper);
  color: var(--muted);
  cursor: not-allowed;
}

/* Invalid: .tm-field.is-invalid wrapper or aria-invalid on the control */
.tm-field.is-invalid :is(.tm-input, .tm-select, .tm-textarea),
:is(.tm-input, .tm-select, .tm-textarea)[aria-invalid="true"] {
  border-color: var(--danger);
}
.tm-field.is-invalid :is(.tm-input, .tm-select, .tm-textarea):focus,
:is(.tm-input, .tm-select, .tm-textarea)[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(194, 37, 58, .25);
}
.tm-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--danger);
}
/* leading icon slot */
.tm-error > svg,
.tm-error__icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}


/* ---- Range --------------------------------------------------------------
   <input type="range" class="tm-range" style="--fill: 40%">
   JS updates --fill = (value - min) / (max - min) * 100%.
   The input is 44px tall for the hit area; the visible track is 4px.        */
.tm-range {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.tm-range:focus-visible { outline: none; }

/* WebKit / Blink */
.tm-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--r-pill);
  background: linear-gradient(to right,
    var(--accent) 0, var(--accent) var(--fill),
    var(--hairline-strong) var(--fill), var(--hairline-strong) 100%);
}
.tm-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(17, 19, 24, .20);
  transition: box-shadow var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.tm-range:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--focus-ring), 0 1px 3px rgba(17, 19, 24, .20);
}
.tm-range:active::-webkit-slider-thumb { transform: scale(1.1); }

/* Firefox */
.tm-range::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--hairline-strong);
}
.tm-range::-moz-range-progress {
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
}
.tm-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(17, 19, 24, .20);
  transition: box-shadow var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.tm-range:focus-visible::-moz-range-thumb {
  box-shadow: var(--focus-ring), 0 1px 3px rgba(17, 19, 24, .20);
}
.tm-range:active::-moz-range-thumb { transform: scale(1.1); }

.tm-range:disabled { cursor: not-allowed; opacity: .5; }


/* ---- Swatch -------------------------------------------------------------
   <button class="tm-swatch" style="--sw:#2B2D31" aria-pressed="true">
     <span class="visually-hidden">Anthracite</span>
   </button>
   44px hit area, 36px colour disc. --sw accepts any background value
   (colour, gradient or texture url). Selected = accent ring with a white
   gap + a check badge, so state never relies on colour alone.               */
.tm-swatch {
  --sw: var(--hairline-strong);
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.tm-swatch::before {
  content: "";
  grid-area: 1 / 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sw);
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(17, 19, 24, .14);
  transition: box-shadow var(--dur-1) var(--ease-out);
}
.tm-swatch::after {
  content: "";
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23111318' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
  box-shadow: 0 1px 3px rgba(17, 19, 24, .30);
  opacity: 0;
  transform: scale(.6);
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.tm-swatch:is([aria-pressed="true"], [aria-checked="true"])::before {
  box-shadow:
    inset 0 0 0 1px rgba(17, 19, 24, .14),
    0 0 0 2px var(--surface),
    0 0 0 4px var(--accent);
}
.tm-swatch:is([aria-pressed="true"], [aria-checked="true"])::after {
  opacity: 1;
  transform: none;
}
@media (hover: hover) {
  .tm-swatch:hover:not([aria-pressed="true"], [aria-checked="true"], :disabled)::before {
    box-shadow:
      inset 0 0 0 1px rgba(17, 19, 24, .14),
      0 0 0 2px var(--surface),
      0 0 0 4px var(--hairline-strong);
  }
}
.tm-swatch:disabled { cursor: not-allowed; opacity: .4; }


/* ---- Segmented control --------------------------------------------------
   <div class="tm-segmented" role="radiogroup" aria-label="Roof">
     <button role="radio" aria-checked="true">Louvred</button>
     <button role="radio" aria-checked="false">Glass</button>
   </div>
   Also accepts aria-pressed / aria-selected / .is-selected and
   .tm-segmented__item on non-button children.                               */
.tm-segmented {
  display: inline-flex;
  max-width: 100%;
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--wash);
}
.tm-segmented > button,
.tm-segmented__item {
  position: relative;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: 500 var(--t-14)/1 var(--f-body);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out);
}
/* extends the hit area over the container padding: 36 + 4 + 4 = 44px */
.tm-segmented > button::before,
.tm-segmented__item::before {
  content: "";
  position: absolute;
  inset: -4px 0;
}
.tm-segmented > :is([aria-checked="true"], [aria-pressed="true"], [aria-selected="true"], .is-selected) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1), 0 0 0 1px rgba(17, 19, 24, .04);
}
@media (hover: hover) {
  .tm-segmented > :is(button, .tm-segmented__item):hover { color: var(--ink); }
}


/* ---- Toggle (switch) ----------------------------------------------------
   <label class="tm-toggle-row">
     <button class="tm-toggle" role="switch" aria-checked="false"></button>
     <span>Show prices</span>
   </label>
   Track 44 x 26; an invisible ::before lifts the hit area to 44px tall.     */
.tm-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  cursor: pointer;
}
.tm-toggle {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--hairline-strong);
  box-shadow: inset 0 0 0 1px rgba(17, 19, 24, .06);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out);
}
.tm-toggle::before {
  content: "";
  position: absolute;
  inset: -9px 0;
}
.tm-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(17, 19, 24, .25);
  transition: transform var(--dur-1) var(--ease-out);
}
.tm-toggle[aria-checked="true"] { background: var(--accent); }
.tm-toggle[aria-checked="true"]::after { transform: translateX(18px); }
.tm-toggle:disabled { cursor: not-allowed; opacity: .5; }
@media (hover: hover) {
  .tm-toggle:hover:not([aria-checked="true"], :disabled) { box-shadow: inset 0 0 0 1px var(--muted); }
  .tm-toggle[aria-checked="true"]:hover:not(:disabled) { background: var(--accent-deep); }
}


/* ---- Chip ---------------------------------------------------------------
   Pill 32px tall. Interactive chips (button / a) keep a 44px hit area.
   Selected via aria-pressed="true" or .is-selected.                         */
.tm-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px/1 var(--f-body);
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out);
}
.tm-chip > svg { width: 14px; height: 14px; flex: none; }
:is(button, a).tm-chip { cursor: pointer; }
:is(button, a).tm-chip::before {
  content: "";
  position: absolute;
  inset: -6px 0;
}
.tm-chip:is([aria-pressed="true"], .is-selected) {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--ink);
}
@media (hover: hover) {
  :is(button, a).tm-chip:hover { border-color: var(--ink); }
}


/* ---- Badge --------------------------------------------------------------
   <span class="tm-badge tm-badge--success">Published</span>
   Tinted background + strong text + a leading dot (state is also in text). */
.tm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--hairline);
  color: var(--ink-2);
  font: 600 var(--t-12)/1.2 var(--f-body);
  letter-spacing: .01em;
  white-space: nowrap;
}
.tm-badge::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.tm-badge--no-dot::before { display: none; }
.tm-badge--success { background: var(--success-tint); color: var(--success); }
.tm-badge--warning { background: var(--warning-tint); color: var(--warning); }
.tm-badge--danger  { background: var(--danger-tint);  color: var(--danger); }
.tm-badge--neutral { background: var(--hairline);     color: var(--ink-2); }
.tm-badge--accent  { background: var(--accent-tint);  color: var(--accent-deep); }


/* ---- Card --------------------------------------------------------------- */
.tm-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: var(--s5);
}
.tm-card--flush { padding: 0; overflow: hidden; }


/* ---- Keyboard key + code block ------------------------------------------ */
.tm-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--hairline-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font: 500 var(--t-12)/1 var(--f-mono);
  vertical-align: middle;
}

/* <pre class="tm-code"><code>…</code></pre> */
.tm-code {
  display: block;
  margin: 0;
  padding: var(--s4);
  border-radius: 12px;
  background: var(--dark);          /* #0E1016 */
  color: #E6E8EE;                   /* code text on dark */
  font: 400 13px/1.6 var(--f-mono);
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
  -webkit-font-smoothing: auto;
}
.tm-code code { font: inherit; color: inherit; background: none; }
.tm-code ::selection { background: rgba(143, 162, 255, .35); color: #FFFFFF; }


/* ---- Toast --------------------------------------------------------------
   <div class="tm-toast-region" role="status" aria-live="polite">
     <div class="tm-toast"><svg class="tm-toast__icon">…</svg>
       <span>Link copied</span>
       <button class="tm-toast__action">Undo</button></div>
   </div>
   Add .is-leaving before removing a toast to play the exit.                */
.tm-toast-region {
  position: fixed;
  z-index: 1000;
  right: var(--s5);
  bottom: var(--s5);
  display: grid;
  gap: var(--s2);
  width: min(380px, calc(100vw - 2 * var(--s4)));
  pointer-events: none;
}
.tm-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: 14px var(--s4);
  border-radius: var(--r-control);
  background: var(--dark-2);
  color: #FFFFFF;
  box-shadow: var(--shadow-3);
  font: 500 var(--t-14)/1.45 var(--f-body);
  pointer-events: auto;
  animation: tm-toast-in var(--dur-2) var(--ease-out) both;
}
.tm-toast > span { flex: 1 1 auto; min-width: 0; }
.tm-toast__icon,
.tm-toast > svg {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--cobalt-on-dark);
}
.tm-toast__action {
  flex: none;
  margin: -12px -8px -12px 0;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--cobalt-on-dark);
  font-weight: 600;
  cursor: pointer;
}
@media (hover: hover) {
  .tm-toast__action:hover { text-decoration: underline; text-underline-offset: .2em; }
}
.tm-toast.is-leaving { animation: tm-toast-out var(--dur-1) var(--ease-in) both; }

@keyframes tm-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes tm-toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(8px); }
}
@media (max-width: 480px) {
  .tm-toast-region {
    right: var(--s4);
    left: var(--s4);
    bottom: var(--s4);
    width: auto;
  }
}


/* --------------------------------------------------------------------------
   6. Reduced motion: zero out transitions and animations everywhere.
   The duration tokens are zeroed too so JS reading them stays in sync.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 0ms;
    --dur-2: 0ms;
    --dur-3: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
