/* TruFrame theme — the single source of colour for every prototype page.
   Dark is the default; light is opt-in via <html data-theme="light">.

   ROLE TOKENS come first and are what new code should use. The legacy
   stone/ink/water/rust names below are ALIASES kept so existing CSS keeps
   working; they are not a second palette.

   THE ONE RULE THAT MATTERS: colour carries meaning here.
     white  = the printed drawing sheet, and nothing else
     blue   = interactive, or produced by the draftsman
     red    = measurement — a dimension, an encroachment, an overshoot
   If something is red and is not a number that matters, it is wrong.
   The on-screen viewing board is --board, not --sheet. Glare-white is
   what prints; the working surface is charcoal (dark) or warm off-white
   (light) so a long session is not a lamp in the face (Craig, 2026-09-12).

   WARNING for anyone editing: --ink used to mean BOTH "text colour" and
   "a dark surface". Those are now --text and --surface-deep and they move in
   opposite directions between themes. Do not reintroduce a token that means
   both. */

:root,
:root[data-theme="dark"] {
  --void:        #0B1420;
  --hull:        #101C2B;
  --surface-deep:#0B1420;
  --seam:        #1D2E42;
  --seam-hi:     #2A4159;
  /* Working surface behind the drawing. Not the printed sheet (--sheet). */
  --board:       #1B2126;

  --sheet:       #FFFFFF;
  --on-sheet:       #0B1420;   /* 18.5:1 on white — primary */
  --on-sheet-dim:   #4A515A;   /*  8.03:1 on white — secondary */
  --on-sheet-faint: #6B717A;   /*  4.92:1 on white — tertiary, still passes body */
  /* Status on a white card. Dark-theme --green / --red fail 4.5:1 on --sheet. */
  --sheet-ok:    #1A5C2C;   /* 8.04:1 on white */
  --sheet-bad:   #9B1C1C;   /* 8.15:1 on white */

  --text:        #E8EEF6;
  --text-dim:    #8FA4BC;
  --text-faint:  #70859E;   /* 4.88:1 on --void, 4.53:1 on --hull */

  --blue:        #2F6FED;
  --blue-edge:   #3E80FF;
  --blue-deep:   #1B4BA8;
  --blue-soft:   #16304F;
  /* Body links on the dark page. --blue is ~3.6:1 on --void — below AA
     and reads as a neon smear on dim copy (FAQ “Welcome”, Welcome → FAQ). */
  --link:        #B8D0FF;
  --link-hover:  #E8EEF6;
  --link-on-sheet:#1B4BA8;

  --red:         #E04B4B;
  --red-edge:    #F0716F;
  --red-soft:    #3A1A1E;

  --green:       #4F9A5E;
  --amber:       #C98A3A;

  --hairline:    rgba(255,255,255,.10);
  --hairline-hi: rgba(255,255,255,.18);
  --wash:        rgba(255,255,255,.06);
  --wash-hi:     rgba(255,255,255,.12);

  --radius:      10px;
}

:root[data-theme="light"] {
  --void:        #EEF1F5;
  --hull:        #FFFFFF;
  --surface-deep:#0E1721;
  --seam:        #D9E0E9;
  --seam-hi:     #BFCAD8;
  /* Warm off-white: easier on the eyes than glare-white or a cool grey. */
  --board:       #E6E2D8;

  --sheet:       #FFFFFF;
  --on-sheet:       #0B1420;   /* 18.5:1 on white — primary */
  --on-sheet-dim:   #4A515A;   /*  8.03:1 on white — secondary */
  --on-sheet-faint: #6B717A;   /*  4.92:1 on white — tertiary, still passes body */
  --sheet-ok:    #1A5C2C;
  --sheet-bad:   #9B1C1C;

  --text:        #0E1721;
  --text-dim:    #4C5D72;
  --text-faint:  #616F80;   /* 5.13:1 on white, 4.53:1 on --void */

  --blue:        #1B5BD7;
  --blue-edge:   #1B5BD7;
  --blue-deep:   #123F96;
  --blue-soft:   #E3ECFD;
  --link:        #123F96;
  --link-hover:  #0E1721;
  --link-on-sheet:#123F96;

  --red:         #C62F2F;
  --red-edge:    #D9534F;
  --red-soft:    #FBE9E9;

  --green:       #3E7A4B;
  --amber:       #A06A22;

  --hairline:    rgba(14,23,33,.14);
  --hairline-hi: rgba(14,23,33,.24);
  --wash:        rgba(14,23,33,.05);
  --wash-hi:     rgba(14,23,33,.10);
}

/* Legacy aliases. Existing pages reference these; new code should not. */
:root {
  --ink:         var(--text);
  --ink-soft:    var(--text-dim);
  --ink-rail:    var(--hull);
  --stone:       var(--void);
  --stone-panel: var(--hull);
  --stone-dim:   var(--seam-hi);
  --stone-line:  var(--seam);
  --water:       var(--blue);
  --water-bright:var(--blue-edge);
  --water-deep:  var(--blue-deep);
  --rust:        var(--red);
  --rust-soft:   var(--red-soft);
  --white:       var(--sheet);
}

html, body { background: var(--void); color: var(--text); }

/* Default <a> is #0000EE. On --void that is a bright smear on dim copy.
   Buttons and nav set their own colour. White cards use --link-on-sheet. */
a { color: var(--link); }
a:hover { color: var(--link-hover); }

.theme-toggle {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--seam); border-radius: var(--radius);
  cursor: pointer; padding: 0;
}
.theme-toggle svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle:hover { color: var(--text); border-color: var(--seam-hi); }
.theme-toggle-floating { position: fixed; top: 16px; right: 16px; z-index: 60; }

/* The assistant's launch button. Lives here rather than in each page because three surfaces now
   mount the agent, and a third copy is how copies drift apart. The shadow is a token so it
   follows the theme instead of being a frozen black. */
.tf-assistant-launch {
  position: fixed; right: 20px; bottom: 24px; z-index: 59; padding: 11px 18px;
  border-radius: 999px; border: none; background: var(--blue); color: #fff;
  font-weight: 600; cursor: pointer; font-size: 14px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--surface-deep) 40%, transparent);
}
.tf-assistant-launch:hover { background: var(--blue-deep); }
/* Pro's viewing-board dock sits at bottom:12px with its own Ask. The shared
   launch pill used to land on that Ask (Craig, 2026-09-12). Raise it above
   the dock. Lite / Settings / Studios have no dock, so they stay at 24px. */
body.tf-pro .tf-assistant-launch {
  bottom: 88px;
}
/* Sheet preview is a floating window that is almost the whole screen (Craig,
   2026-09-13). It covers the dock, so the pill drops to the bottom strip the
   window reserves for it, and stays clear of the window's Save / Download row
   and resize corner. */
body.sheet-preview-open .tf-assistant-launch {
  right: 20px;
  bottom: 24px;
}
/* My folder is a 340px drawer on the right. Same rule: do not cover Archive / Delete. */
body.folder-open .tf-assistant-launch {
  right: calc(340px + 20px);
}
/* Phone: sit above Lite's bottom tab bar and the home indicator. Pro keeps
   its dock offset. Do not cover the empty-state upload row. */
@media (max-width: 760px) {
  .tf-assistant-launch {
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
  body.tf-lite .tf-assistant-launch {
    bottom: calc(var(--tf-lite-phone-tabbar, 56px) + 10px + env(safe-area-inset-bottom, 0px));
  }
  body.tf-pro .tf-assistant-launch {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
}

::selection { background: var(--blue); color: #fff; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:.001ms !important; transition-duration:.001ms !important; }
}

/* Cookie banner — Accept and Reject are the same control. Analytics is opt-in. */
#tf-cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--hull); color: var(--text);
  border-top: 1px solid var(--seam);
  font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 13px;
}
.tf-cookie-copy { flex: 1 1 280px; color: var(--text); line-height: 1.45; }
.tf-cookie-copy a { color: var(--link); }
.tf-cookie-actions { display: flex; gap: 8px; }
.tf-cookie-btn {
  min-width: 140px; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font: 600 13px 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--void); color: var(--text); border: 1px solid var(--seam-hi);
}
@media (max-width: 760px) {
  body.tf-lite #tf-cookie-banner {
    bottom: calc(var(--tf-lite-phone-tabbar, 56px) + env(safe-area-inset-bottom, 0px));
  }
}
/* Accept must not look like the recommended choice. Same paint as Reject. */

/* First-run tour */
#tf-tour {
  /* Above the cookie banner (80) and the low-balance overlay (9999). A first-use
     walk that is covered by "0 credits" is not a walk. The warning can show after Done. */
  position: fixed; inset: 0; z-index: 10050; background: color-mix(in srgb, var(--void) 55%, transparent);
  display: grid; place-items: center; padding: 24px;
}
#tf-tour.tf-tour-proposal {
  /* Card sits at the bottom so the left rail (customer, draft, frames) stays visible. */
  place-items: end center;
  background: color-mix(in srgb, var(--void) 38%, transparent);
}
.tf-tour-card {
  width: min(440px, 100%); background: var(--hull); color: var(--text);
  border: 1px solid var(--seam); border-radius: 14px; padding: 22px 22px 18px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}
.tf-tour-card h2 { margin: 0 0 8px; font-size: 18px; }
.tf-tour-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.tf-tour-card p { margin: 0 0 16px; color: var(--text-dim); line-height: 1.5; }
.tf-tour-spot {
  outline: 2px solid var(--accent, var(--blue));
  outline-offset: 3px;
  border-radius: 6px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--blue) 22%, transparent);
  position: relative;
  z-index: 40;
}
.tf-tour-row { display: flex; align-items: center; gap: 10px; }
.tf-tour-row button {
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font: 600 13px 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--blue); color: #fff; border: none;
}
#tf-tour-skip, #tf-tour-back { background: transparent; color: var(--text); border: 1px solid var(--seam-hi); }
#tf-tour-back:disabled { opacity: 0.45; cursor: default; }
#tf-tour-count { margin-left: auto; color: var(--text-faint); font-size: 12px; }

/* First sheet coach — persistent after Check site, not a modal tour */
.tf-first-sheet-coach {
  position: absolute;
  left: 96px;
  bottom: 64px;
  width: min(400px, calc(100% - 120px));
  z-index: 8;
  background: var(--hull);
  color: var(--text);
  border: 1px solid var(--seam-hi);
  border-radius: 12px;
  padding: 12px 14px 12px 14px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--void) 45%, transparent);
}
.tf-first-sheet-coach[hidden] { display: none; }
.tf-first-sheet-coach.is-slim {
  width: auto;
  max-width: min(560px, calc(100% - 120px));
  padding: 8px 10px;
}
.tf-first-sheet-coach.is-slim .tf-coach-rail { margin: 0; }
.tf-coach-rail {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 0 22px 10px 0;
}
.tf-coach-rail-step {
  display: inline-flex; align-items: center; gap: 4px;
  font: 600 11px 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--seam);
  border-radius: 999px;
  padding: 3px 8px;
  cursor: pointer;
}
.tf-coach-rail-step.current {
  color: var(--text);
  border-color: var(--blue);
  background: var(--blue-soft);
}
.tf-coach-rail-step.done { color: var(--text); }
.tf-coach-check {
  display: inline-block; min-width: 10px; font-size: 11px; color: var(--link);
}
.tf-coach-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-faint); margin: 0 0 4px;
}
.tf-coach-title {
  margin: 0 0 6px; font-family: 'Space Grotesk', sans-serif;
  font-size: 16px; font-weight: 600; color: var(--text);
}
.tf-coach-text, .tf-coach-helper {
  margin: 0 0 8px; font-size: 13px; line-height: 1.45; color: var(--text-dim);
}
.tf-coach-toast, .tf-coach-warn {
  margin: 0 0 8px; font-size: 12.5px; line-height: 1.4;
  padding: 7px 8px; border-radius: 8px;
}
.tf-coach-toast {
  background: var(--blue-soft); color: var(--text); border: 1px solid var(--blue-edge);
}
.tf-coach-warn {
  background: color-mix(in srgb, var(--amber, #C9A227) 16%, var(--hull));
  color: var(--text); border: 1px solid var(--seam-hi);
}
.tf-coach-chips { display: flex; flex-direction: column; gap: 6px; margin: 0 0 10px; }
.tf-coach-chip, .tf-coach-tertiary {
  text-align: left; font: 500 12.5px 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text); background: transparent;
  border: 1px dashed var(--seam-hi); border-radius: 8px;
  padding: 7px 9px; cursor: pointer;
}
.tf-coach-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tf-coach-primary {
  background: var(--blue); color: var(--sheet); border: none;
  font: 600 13px 'IBM Plex Sans', system-ui, sans-serif;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.tf-coach-secondary, .tf-coach-dismiss {
  background: transparent; color: var(--text);
  border: 1px solid var(--seam-hi);
  font: 600 13px 'IBM Plex Sans', system-ui, sans-serif;
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.tf-coach-dismiss {
  position: absolute; top: 8px; right: 8px;
  padding: 2px 8px; font-size: 16px; line-height: 1;
}
.tf-coach-spot {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 6px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--blue) 22%, transparent);
}
.generate-sheet-cta {
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--blue);
  color: var(--sheet);
  border: none;
  font: 600 13px 'IBM Plex Sans', system-ui, sans-serif;
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  position: relative;
  z-index: 5;
}
.generate-sheet-cta[hidden] { display: none; }
/* Next to the control they clicked — outside the isolated stage, so a
   refused sheet ("draw the lot first") cannot look like a dead button.
   Same hole as #me-status / #64. */
.generate-sheet-status {
  font: 500 12px 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text);
  max-width: min(280px, 36vw);
  line-height: 1.35;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.generate-sheet-status[hidden],
.generate-sheet-status:empty { display: none; }
.tf-coach-notice {
  margin: 0 0 8px; font-size: 12.5px; line-height: 1.4;
  padding: 7px 8px; border-radius: 8px;
  background: var(--blue-soft); color: var(--text); border: 1px solid var(--blue-edge);
}
.tf-coach-notice[hidden] { display: none; }

/* ── Shared app / public header ─────────────────────────────────────────── */
:root {
  --tf-appbar-h: 56px;
  --tf-appbar-stack-h: var(--tf-appbar-h);
  --tf-active: var(--blue);
}
@media (max-width: 760px) {
  :root { --tf-appbar-h: calc(52px + env(safe-area-inset-top, 0px)); }
  html.tf-appbar-has-actions { --tf-appbar-stack-h: calc(var(--tf-appbar-h) + 44px); }
}

html.tf-has-appbar,
html.tf-has-appbar body {
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: visible;
}
html.tf-has-appbar body {
  display: flex;
  flex-direction: column;
}

.tf-appbar,
.tf-appbar.stage-topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  background: var(--hull);
  border-bottom: 1px solid var(--seam);
  box-sizing: border-box;
}
.tf-appbar-row {
  height: var(--tf-appbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}
.tf-appbar-left,
.tf-appbar-right,
.tf-appbar .topbar-left,
.tf-appbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tf-appbar-right { justify-content: flex-end; flex: 1 1 0; min-width: 0; }
.tf-appbar-left { flex: 0 0 auto; }
.tf-appbar-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}

.tf-appbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tf-appbar-brand img {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 5px; display: block;
}
.tf-appbar-brand b { color: var(--text); font-weight: 700; }
.tf-appbar-brand:hover { color: var(--text); }

.tf-tier-pills,
.tf-appbar .tier-pills {
  display: flex;
  gap: 3px;
  background: var(--wash);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 2px;
  flex: 0 0 auto;
}
.tf-tier-pill,
.tf-appbar .tier-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.tf-tier-pill:hover,
.tf-appbar .tier-pill:hover { color: var(--text); }
.tf-tier-pill.active,
.tf-appbar .tier-pill.active {
  background: var(--tf-active);
  color: #fff;
  font-weight: 700;
}
.tf-tier-pill.tf-locked,
.tf-appbar-link.tf-locked {
  opacity: 0.55;
}
.tf-tier-pill.tf-soon::after {
  content: " · soon";
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.tf-beta-tag,
.lite-beta-pill {
  display: inline-flex;
  align-items: center;
  height: 14px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  border: 1px solid var(--hairline-hi);
  background: var(--wash);
}
.tf-tier-pill.active .tf-beta-tag {
  color: #fff;
  border-color: color-mix(in srgb, #fff 40%, transparent);
  background: color-mix(in srgb, #fff 14%, transparent);
}

.tf-appbar-sec,
.tf-public-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.tf-appbar-link {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.tf-appbar-link:hover,
.tf-appbar-link.is-current { color: var(--text); }
.tf-appbar-gear {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim); border-radius: 8px; text-decoration: none;
}
.tf-appbar-gear svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.tf-appbar-gear:hover,
.tf-appbar-gear.is-current { color: var(--text); background: var(--wash); }

.tf-appbar-menu { position: relative; }
.tf-appbar-menu-list {
  position: fixed;
  top: calc(100% + 6px);
  left: 0;
  z-index: 120;
  min-width: 220px;
  padding: 6px;
  background: var(--hull);
  border: 1px solid var(--seam-hi);
  border-radius: 10px;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--surface-deep) 40%, transparent);
}
.tf-appbar-menu-list a,
.tf-appbar-menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: 500 13px 'IBM Plex Sans', sans-serif;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
}
.tf-appbar-menu-list a:hover,
.tf-appbar-menu-list button:hover { background: var(--wash); }
.tf-appbar-menu-list[hidden] { display: none !important; }
body > .tf-appbar-menu-list,
body > .tf-menu-list {
  position: fixed;
  z-index: 120;
}

.tf-appbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 0;
  flex-wrap: nowrap;
  overflow-x: hidden;
  overflow-y: hidden;
  justify-content: flex-start;
  position: relative;
  z-index: 2;
}
.tf-appbar-actions > * { flex: 0 0 auto; }
.tf-appbar-primary,
.tf-appbar-actions > .tf-appbar-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.credits-badge {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--wash);
  border: 1px solid var(--hairline);
  padding: 0 10px;
  border-radius: 9px;
  white-space: nowrap;
  text-decoration: none;
  flex: 0 0 auto;
}
.credits-badge .credits-value { color: var(--text); font-weight: 600; }
.credits-badge:hover { border-color: var(--hairline-hi); color: var(--text-dim); }

.tf-cta {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
  font: 600 13px 'IBM Plex Sans', sans-serif;
  background: var(--blue);
  color: #fff;
  border: 1px solid var(--blue);
  white-space: nowrap;
  flex: 0 0 auto;
}
.tf-cta:hover { background: var(--blue-deep); color: #fff; }
.tf-cta.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--seam-hi);
}
.tf-cta.ghost:hover { color: var(--text); border-color: var(--text-dim); }

.tf-appbar-overflow {
  display: none;
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--seam);
  background: transparent;
  color: var(--text);
  font: 600 13px 'IBM Plex Sans', sans-serif;
  cursor: pointer;
  flex: 0 0 auto;
}
.tf-appbar-overflow-panel {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--seam);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--hull);
}
.tf-appbar-overflow-panel[hidden] { display: none; }
.tf-appbar-overflow-panel .tf-appbar-link,
.tf-appbar-overflow-panel a,
.tf-appbar-overflow-panel button {
  display: block;
  width: 100%;
  text-align: left;
}
.tf-appbar-overflow-panel .tf-appbar-menu-list,
.tf-appbar-overflow-panel .tf-overflow-help {
  position: static;
  min-width: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

html.tf-has-appbar .app,
html.tf-has-appbar .shell,
html.tf-has-appbar .settings-shell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
html.tf-has-appbar .wrap,
html.tf-has-appbar main,
html.tf-has-appbar .card-wrap {
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}
html.tf-appbar-stack-actions { --tf-appbar-stack-h: calc(var(--tf-appbar-h) + 44px); }
html.tf-appbar-stack-actions .tf-appbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: var(--tf-appbar-h) 44px;
  height: auto;
  min-height: var(--tf-appbar-h);
  row-gap: 0;
}
html.tf-appbar-stack-actions .tf-appbar-left { grid-column: 1; grid-row: 1; }
html.tf-appbar-stack-actions .tf-appbar-right { display: contents; }
html.tf-appbar-stack-actions .tf-appbar-chrome { grid-column: 2; grid-row: 1; }
html.tf-appbar-stack-actions .tf-appbar-row .tf-appbar-actions {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 2;
  height: 44px;
  min-width: 0;
  max-width: 100%;
  width: auto;
  padding: 0 2px;
  border-top: 1px solid var(--seam);
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: hidden;
}

html.tf-has-appbar .app { height: calc(100vh - var(--tf-appbar-stack-h)); }
html.tf-has-appbar .shell { height: calc(100% - 0px); min-height: calc(100vh - var(--tf-appbar-stack-h)); }

@media (max-width: 900px) {
  html.tf-has-appbar .panel,
  html.tf-has-appbar .settings-sidebar {
    top: var(--tf-appbar-stack-h);
  }
}

.tf-file-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--hairline-hi);
  background: var(--wash);
  color: var(--text);
  font: 600 12px 'IBM Plex Sans', system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}
.tf-file-btn:hover { background: var(--wash-hi); color: var(--text); }
.tf-file-btn[aria-expanded="true"] {
  border-color: var(--hairline-hi);
  background: var(--wash-hi);
}
.tf-file-menu.tf-file-parked {
  display: none;
}
.tf-file-status {
  display: block;
  font: 500 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
  padding: 6px 10px 8px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tf-file-list .tf-file-item,
.tf-file-list .download-pill,
.tf-file-list .icon-pill,
.tf-file-list .btn,
.tf-file-list .tf-menu-btn {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: 500 13px 'IBM Plex Sans', system-ui, sans-serif;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}
.tf-file-list .tf-file-item:hover,
.tf-file-list .download-pill:hover,
.tf-file-list .icon-pill:hover,
.tf-file-list .btn:hover,
.tf-file-list .tf-menu-btn:hover {
  background: var(--wash);
  color: var(--text);
}
.tf-file-list .icon-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tf-file-list .icon-pill span { display: inline !important; }
.tf-file-list .tf-file-danger,
.tf-file-list #btn-clear-customer {
  color: var(--red);
}
.tf-file-list .tf-file-danger:hover,
.tf-file-list #btn-clear-customer:hover {
  background: var(--red-soft);
  color: var(--red);
}
.tf-file-list .tf-menu {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--seam);
}
.tf-file-list .tf-menu-list,
.tf-file-list .tf-menu.open .tf-menu-list,
.tf-file-list .tf-menu-list[hidden] {
  display: block !important;
  position: static !important;
  left: auto !important;
  top: auto !important;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}
.tf-file-list .tf-menu-item[hidden] { display: none !important; }
.tf-file-list .tf-menu-btn {
  font: 600 11px 'IBM Plex Mono', system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  pointer-events: none;
}
.tf-file-list #customer-folder-strip[hidden] { display: none !important; }
.tf-file-list #customer-folder-strip:not([hidden]) {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 2px;
}
.tf-optional-away { display: none !important; }
.tf-file-overflow-dock {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--seam);
}
.tf-appbar-overflow-panel .tf-file-list,
.tf-file-overflow-dock .tf-file-list {
  position: static;
  min-width: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
  display: flex;
  flex-direction: column;
}
.tf-appbar.tf-file-in-overflow .tf-appbar-overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Laptop / tablet: keep every top-bar control in the bar. Two rows so
   a 768–1100px header does not clip or overlap. Menu is phones only. */
@media (max-width: 1100px) and (min-width: 761px) {
  .tf-appbar-row { gap: 8px; padding: 0 12px; }
  .tf-appbar-left { gap: 6px; }
  .tf-appbar-link { padding: 5px 6px; font-size: 12.5px; }
  .tf-cta { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .tf-beta-tag,
  .lite-beta-pill { display: none; }
  .tf-tier-pill.tf-soon::after { content: ""; }
  .tf-tier-pill,
  .tf-appbar .tier-pill { padding: 4px 6px; font-size: 10px; }
  .tf-appbar #account-badge {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html.tf-appbar-has-actions { --tf-appbar-stack-h: calc(var(--tf-appbar-h) + 44px); }
  html.tf-appbar-has-actions .tf-appbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: var(--tf-appbar-h) 44px;
    height: auto;
    min-height: var(--tf-appbar-h);
    row-gap: 0;
  }
  html.tf-appbar-has-actions .tf-appbar-left { grid-column: 1; grid-row: 1; }
  html.tf-appbar-has-actions .tf-appbar-right { display: contents; }
  html.tf-appbar-has-actions .tf-appbar-chrome { grid-column: 2; grid-row: 1; }
  html.tf-appbar-has-actions .tf-appbar-row .tf-appbar-actions {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    height: 44px;
    min-width: 0;
    max-width: 100%;
    width: auto;
    padding: 0 2px;
    border-top: 1px solid var(--seam);
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: hidden;
  }

  .tf-appbar-public .tf-appbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    height: auto;
    min-height: var(--tf-appbar-h);
    align-items: center;
    column-gap: 8px;
    row-gap: 0;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .tf-appbar-public .tf-appbar-left { display: contents; }
  .tf-appbar-public .tf-appbar-brand { grid-column: 1; grid-row: 1; }
  .tf-appbar-public .tf-public-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
    min-width: 0;
    padding-bottom: 2px;
  }
  .tf-appbar-public .tf-appbar-right {
    grid-column: 2;
    grid-row: 1;
    flex: 0 0 auto;
  }
}

@media (max-width: 760px) {
  .tf-appbar-sec,
  .tf-public-nav { display: none; }
  .tf-appbar-brand b { display: none; }
  .tf-appbar-public .tf-cta { display: none; }
  .tf-appbar-overflow { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  html.tf-appbar-has-actions .tf-appbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: var(--tf-appbar-h) 44px;
    height: auto;
    min-height: var(--tf-appbar-h);
    row-gap: 0;
  }
  html.tf-appbar-has-actions .tf-appbar-left { grid-column: 1; grid-row: 1; }
  html.tf-appbar-has-actions .tf-appbar-right { display: contents; }
  html.tf-appbar-has-actions .tf-appbar-chrome { grid-column: 2; grid-row: 1; }
  .tf-appbar-row { padding: 0 8px; }
  .tf-beta-tag,
  .lite-beta-pill { display: none; }
  html.tf-appbar-has-actions .tf-appbar-left {
    min-width: 0;
  }
  html.tf-appbar-has-actions .tf-appbar-row .tf-appbar-actions {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    height: 44px;
    min-width: 0;
    max-width: 100%;
    width: auto;
    padding: 0 max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
    border-top: 1px solid var(--seam);
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: hidden;
  }
  /* Lite collapses New/History/ratings into More so Save + Download stay on
     screen. Other products still scroll the actions row. */
  html[data-tf-appbar-active="lite"].tf-appbar-has-actions .tf-appbar-row .tf-appbar-actions {
    overflow-x: hidden;
    gap: 8px;
  }
  .tf-appbar-overflow-panel .tf-appbar-link,
  .tf-appbar-overflow-panel a,
  .tf-appbar-overflow-panel button {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
  }
  .tf-appbar-chrome .credits-badge { display: none; }
  .tf-appbar-gear,
  .tf-appbar .theme-toggle {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px;
  }
  .tf-appbar #account-badge {
    height: 44px !important;
    min-height: 44px;
    padding: 0 10px !important;
    font-size: 11px !important;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
  }
  .account-badge-full { display: none; }
  .account-badge-compact { display: inline; }
  .tf-appbar-chrome { gap: 4px; }
  .tf-appbar-row {
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }
  .tf-tier-pill,
  .tf-appbar .tier-pill { padding: 6px 7px; font-size: 9.5px; min-height: 32px; }
  .tf-tier-pill.tf-soon::after { content: ""; }
}

.account-badge-compact { display: none; }
