/* TSplus PrivateBrain - shared base styles, design tokens and components (TSplus 2026 design system,
   see docs/design/tsplus/DESIGN.md). Module-specific styles live in admin.css, admin-widget.css and chat.css.
   Fonts are self-hosted (Inter 400/600/700, Caveat 700; SIL OFL, licenses in /fonts) because the CSP only allows 'self'. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/inter-latin-ext-400-normal.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-20C0,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-latin-400-normal.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; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/inter-latin-ext-600-normal.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-20C0,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-latin-600-normal.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; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/inter-latin-ext-700-normal.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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/inter-latin-700-normal.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; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/caveat-latin-ext-700-normal.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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/caveat-latin-700-normal.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; }

:root {
  /* ---- Design tokens (light theme) ---- */
  --surface: #FFF8F1;          /* page ground (cream) */
  --surface-raised: #FFFFFF;   /* cards, tables, panels */
  --surface-tint: #FFF9F1;     /* highlighted fill, table header, hover rows */
  --chip-neutral: #F2EDE6;     /* neutral pill background */
  --border: #F3E4D3;           /* 1px card/table borders */
  --ink: #37291F;              /* titles and body text */
  --ink-muted: #8B97A6;        /* decorative only on light (2.8:1) - never used for small text */
  --ink-soft: #54657A;         /* small secondary text, 5.7:1 on surface */
  --brand: #F0821F;            /* THE accent: fills, focus halo, selected states */
  --brand-strong: #F97D1C;     /* pressed states, end of gradients */
  --brand-light: #FFA430;      /* handwritten kickers (display size only) */
  --gradient-start: #FFAF48;
  --gradient-end: #FE813A;
  --peach: #FFD7AE;            /* soft orange fills, text on navy */
  --sand: #F3E4D3;             /* dividers, tracks */
  --navy: #1B2A41;             /* counterweight: header bar, dark sections */
  --slate: #54657A;
  --positive: #2FA36B;
  --positive-strong: #1E7A4E;  /* small positive text */
  --positive-bg: #E8F5EE;
  --negative: #B83A2E;
  --negative-bg: #FBE7E4;

  /* ---- Accessibility additions (derived from the tokens above) ----
     Button text: white on --brand is only ~2.6:1, so primary buttons keep the brand orange fill but use
     --ink-on-brand (#37291F = ink) text: 5.3:1 on #F0821F and 5.3:1 on #F97D1C (WCAG AA for normal text).
     Links and any small orange text use --brand-text (#A34A00): 5.9:1 on white and 5.6:1 on cream. */
  --ink-on-brand: #37291F;
  --brand-text: #A34A00;

  --input-border: #968572;      /* form control outline, 3.6:1 on white (WCAG 1.4.11) */
  --shadow-card: 0 6px 24px rgba(180, 120, 60, .10);
  --shadow-popover: 0 8px 24px rgba(55, 41, 31, .14);
  --radius-sm: 8px;
  --radius-card: 16px;
  --radius-pill: 999px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-hand: "Caveat", "Segoe Print", cursive;

  /* ---- Legacy aliases used by older scripts/styles ---- */
  --pb-primary: var(--brand);           /* overridden per widget on .pb-chat */
  --pb-primary-contrast: var(--ink-on-brand);
  --pb-bg: var(--surface);
  --pb-surface: var(--surface-raised);
  --pb-text: var(--ink);
  --pb-muted: var(--ink-soft);
  --pb-border: var(--border);
  --pb-danger: var(--negative);
  --pb-success: var(--positive-strong);
  --pb-radius: var(--radius-sm);
  --pb-font: var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; color: var(--ink); background: var(--surface); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { letter-spacing: -.02em; font-weight: 700; color: var(--ink); }
h1 { font-size: 34px; line-height: 1.15; margin: 0; }
h2 { font-size: 20px; line-height: 1.25; }
a { color: var(--brand-text); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; box-shadow: 0 0 0 5px rgba(240, 130, 31, .45); }

/* Product name: "TSplus Private" regular + "Brain" bold (partial _BrandName). */
.brand-name { font-weight: 400; letter-spacing: -.01em; white-space: nowrap; }
.brand-name strong { font-weight: 700; }

/* Handwritten kicker above titles: lower case, brand-light, display size only (22px+). */
.kicker { font-family: var(--font-hand); font-weight: 700; font-size: 24px; line-height: 1; color: var(--brand-light); text-transform: lowercase; margin: 0 0 4px; }
@media (prefers-contrast: more) { .kicker { color: var(--brand-text); } }

/* Buttons: pill-shaped. Primary = brand fill + ink text (see contrast note in :root). */
button, .button {
  font: inherit; font-weight: 700; font-size: 14px; line-height: 1.2; cursor: pointer; border: 1px solid var(--brand); background: var(--brand);
  color: var(--ink-on-brand); padding: 10px 20px; border-radius: var(--radius-pill); text-decoration: none; display: inline-block;
  transition: background-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
button:hover, .button:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--ink-on-brand); box-shadow: 0 4px 12px rgba(240, 130, 31, .30); }
button:active, .button:active { transform: translateY(1px); box-shadow: none; }
button.secondary, .button.secondary { background: var(--surface-raised); color: var(--ink); border-color: var(--sand); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-tint); border-color: var(--brand); color: var(--ink); box-shadow: none; }
button.danger, .button.danger { background: var(--negative); border-color: var(--negative); color: #fff; }
button.danger:hover, .button.danger:hover { background: #9C2F25; border-color: #9C2F25; color: #fff; box-shadow: none; }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.link-button { background: none; border: none; color: var(--brand-text); padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; border-radius: var(--radius-sm); }
.link-button:hover { background: none; color: var(--ink); box-shadow: none; }

/* Inputs: 8px radius. */
input, textarea, select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--ink); width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: .8; }
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--brand-text); }
input[readonly] { background: var(--chip-neutral); }
label { font-weight: 700; font-size: 13px; display: block; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.help { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.error-text { color: var(--negative); font-size: 13px; }
.inline { display: inline; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cards */
.card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 24px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; }
.card.highlight { background: var(--surface-tint); border: 1.5px solid var(--brand); }

/* Status badges (pills) */
.badge { display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 700; line-height: 1.5; background: var(--chip-neutral); color: var(--ink-soft); }
.badge.ok { background: var(--positive-bg); color: var(--positive-strong); }
.badge.warn { background: var(--peach); color: var(--ink); }
.badge.err { background: var(--negative-bg); color: var(--negative); }

/* Flash messages */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--positive-bg); color: var(--positive-strong); font-weight: 600; margin-bottom: 16px; border: 1px solid #CBE8D8; }
.flash-error { background: var(--negative-bg); color: var(--negative); border-color: #F2C9C4; }

/* Faint warm wave texture for light pages (pure SVG, decorative). */
.wave-bg {
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1440' height='420' viewBox='0 0 1440 420' fill='none'%3E%3Cg stroke='%23F0821F' stroke-width='1.2' opacity='.16'%3E%3Cpath d='M0 300C240 220 420 380 720 300S1200 220 1440 300'/%3E%3Cpath d='M0 330C240 250 420 410 720 330S1200 250 1440 330'/%3E%3Cpath d='M0 360C240 280 420 440 720 360S1200 280 1440 360'/%3E%3Cpath d='M0 390C240 310 420 470 720 390S1200 310 1440 390'/%3E%3C/g%3E%3Cg stroke='%23F0821F' stroke-width='1.2' opacity='.10'%3E%3Cpath d='M0 40C300 -30 520 110 820 40S1240 -20 1440 50'/%3E%3Cpath d='M0 68C300 -2 520 138 820 68S1240 8 1440 78'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center bottom, center top; background-size: 100% auto;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
