/* AudiophileGPT page styles. Markup: index.html. Behavior: app.js.
   Look 2026-09-13: Tomasetti house dark purple, values lifted from
   assets/tomasetti-tokens.css (copied in, not imported, so this page stays
   one self-contained file with no fleet stylesheet dependency). The
   older-reader rules do not move with the palette: 18px base type with a
   three-step size control, AAA contrast on every muted line, and 48px
   minimum targets. */

:root {
  --bg: #0f0a1a;             /* t-bg, the family page ground */
  --panel: #1e1530;          /* t-surface: cards, bubbles, inputs */
  --panel-hover: #2a1d40;    /* t-surface-hover */
  --panel-warm: #241a3d;     /* the visitor's own bubbles, one step up */
  --ink: #e2d9ee;            /* t-ink. 14.3:1 on --bg, 12.8:1 on --panel. */
  --muted: #bca8d0;          /* 8.9:1 on --bg, 8.0:1 on --panel. Anything
                                dimmer (the tokens' #9a88b0 is 5.7:1 here)
                                fails AAA on this surface. */
  --line: rgba(216, 150, 255, .14);
  --line-strong: rgba(216, 150, 255, .30);
  --accent: #5b21b6;         /* fill violet. White text on it is 9.0:1, so
                                buttons keep AAA that the old brown (5.7:1)
                                only had for large type. */
  --accent-dark: #4c1d95;    /* hover/active fill */
  --accent-bright: #c084fc;  /* t-accent-bright: links and focus on dark,
                                7.4:1 on --bg */
  --accent-soft: rgba(124, 58, 237, .18);
  --accent-ink: #ffffff;
  --gold: #fbbf24;           /* quota.low. 10.4:1 on --panel. */
  --red: #fca5a5;            /* error text. The tokens' #f87171 is 6.3:1 on
                                --panel, which fails AAA; this is 9.0:1. */
  --radius: 16px;
  --tap: 3rem;               /* 48px at the default root size, more at step 3 */
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute has to beat the class rules further down. A UA
   `[hidden]` rule is the weakest thing in the cascade, so a class that sets
   `display` silently overrode it. Two real bugs came out of that: `.composer
   { display: flex }` meant the wall at zero free questions could not hide the
   ask box, so a spent visitor kept a working form and got a 402 out of it;
   and `.threadbar { display: flex }` meant the empty thread bar rendered on
   the welcome screen, putting a live "Delete this conversation" button in
   front of someone who had not asked anything yet. `!important` is the point
   here: it makes `hidden` mean hidden for every element, whatever the class
   says, which is what the attribute is for. */
[hidden] { display: none !important; }

html { font-size: 100%; }
html, body { height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 1.15rem;        /* 18.4px at the default root size */
  line-height: 1.65;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(1100px 700px at 85% -8%, rgba(124, 58, 237, .16), transparent 60%),
    radial-gradient(900px 600px at 95% 105%, rgba(157, 80, 229, .10), transparent 60%),
    var(--bg);
}
.pride { height: 6px; flex-shrink: 0; background: linear-gradient(90deg,
  #e40303 0%, #ff8c00 14%, #ffed00 28%,
  #008026 42%, #004dff 57%, #750787 72%,
  #d896ff 86%, #ff69b4 100%); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* One focus style everywhere, thick enough to find without hunting. */
a:focus-visible, button:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 4px;
}
a { color: var(--accent-bright); text-decoration: underline; }
a:hover { color: #d8b4fe; }

.skip {
  position: absolute; left: 8px; top: -100px; z-index: 40;
  background: var(--accent-bright); color: var(--bg);
  padding: 12px 18px; border-radius: var(--radius); text-decoration: none;
  font-weight: 650;
}
.skip:focus { top: 8px; }

/* ── shell ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 19rem 1fr; min-height: calc(100vh - 6px); }

/* ── sidebar: the memory ───────────────────────────────────────────── */
.sidebar {
  background: #160f26;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 16px; height: calc(100vh - 6px); position: sticky; top: 0;
  overflow-y: auto;
}
.newchat {
  min-height: var(--tap); width: 100%;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent-dark); border-radius: var(--radius);
  font: inherit; font-size: 1.05rem; font-weight: 650;
  cursor: pointer; padding: 12px 14px;
}
.newchat:hover { background: var(--accent-dark); }
.sideh {
  font-size: .95rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  margin-top: 6px; padding: 0 4px;
}
.convlist { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.convlist li { display: flex; }
.convopen {
  flex: 1; text-align: left; cursor: pointer; font: inherit;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius); padding: 11px 13px;
  min-height: var(--tap); color: var(--ink);
  display: flex; flex-direction: column; gap: 3px;
}
.convopen:hover { background: var(--panel-hover); border-color: var(--line); }
.convopen[aria-current="true"] {
  background: var(--panel); border-color: var(--accent-bright);
  box-shadow: inset 3px 0 0 var(--accent-bright);
}
.convtitle {
  font-size: 1rem; line-height: 1.4; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.convmeta { font-size: .85rem; color: var(--muted); }
.empty {
  font-size: .95rem; color: var(--muted); line-height: 1.55;
  padding: 6px 6px 0;
}
.sidefoot {
  margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--line);
  font-size: .85rem; color: var(--muted); line-height: 1.5;
}
.sidefoot b { color: var(--ink); font-weight: 600; }

/* ── main column ───────────────────────────────────────────────────── */
.col { display: flex; flex-direction: column; min-height: calc(100vh - 6px); min-width: 0; }
header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  background: rgba(15, 10, 26, .72);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; flex-direction: column; }
.brand h1 {
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 1.35rem; font-weight: 700; letter-spacing: .1px;
}
.brand .sub { font-size: .9rem; color: var(--muted); }
.headright { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

fieldset.textsize {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(30, 21, 48, .72); padding: 4px 10px 6px; margin: 0;
}
fieldset.textsize legend {
  font-size: .8rem; color: var(--muted); padding: 0 4px; font-weight: 600;
}
.sizebtns { display: flex; gap: 4px; }
.sizebtns button {
  min-width: 2.6rem; min-height: 2.4rem; cursor: pointer; font: inherit;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px; color: var(--ink); font-weight: 700; line-height: 1;
}
.sizebtns button:hover { background: var(--accent-soft); }
.sizebtns button[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent-bright);
}
.sizebtns button.s1 { font-size: 1rem; }
.sizebtns button.s2 { font-size: 1.2rem; }
.sizebtns button.s3 { font-size: 1.45rem; }
.menubtn {
  display: none; min-height: var(--tap); font: inherit; font-weight: 650;
  background: var(--panel); color: var(--ink); cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 16px;
}

main { flex: 1; width: 100%; max-width: 52rem; margin: 0 auto; padding: 20px 22px 8px; }

.welcome { padding: 26px 4px 4px; }
.welcome h2 {
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 1.9rem; font-weight: 700; line-height: 1.25;
}
.welcome p { color: var(--muted); margin-top: 14px; font-size: 1.05rem; line-height: 1.7; max-width: 40rem; }

.chiplabel {
  font-size: .95rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 30px 0 0; padding: 0 4px;
}
.chips { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 10px; }
.chip {
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink);
  padding: 15px 18px; border-radius: var(--radius); font: inherit;
  font-size: 1.05rem; line-height: 1.5; text-align: left; cursor: pointer;
  min-height: var(--tap);
}
.chip:hover { border-color: var(--accent-bright); background: var(--accent-soft); }

.chat { display: flex; flex-direction: column; gap: 20px; padding: 8px 0 12px; }
.msg { display: flex; flex-direction: column; max-width: 90%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai { align-self: flex-start; align-items: flex-start; }
.who {
  font-size: .85rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 6px; padding: 0 3px;
}
.bubble {
  padding: 15px 18px; border-radius: var(--radius); font-size: 1.1rem;
  line-height: 1.7; overflow-wrap: break-word;
}
.msg.user .bubble { background: var(--panel-warm); border: 1px solid var(--line-strong); }
.msg.ai .bubble { background: var(--panel); border: 1px solid var(--line); }
.bubble strong { font-weight: 700; }
.bubble code {
  font-family: Consolas, 'Courier New', monospace; font-size: .95em;
  background: rgba(192, 132, 252, .12); padding: 1px 5px; border-radius: 6px;
}
.msg.offtopic .bubble { border-left: 5px solid var(--accent-bright); }
.msg.err .bubble { border-left: 5px solid var(--red); color: var(--red); }
.preserve { white-space: pre-wrap; }

.thinking { display: flex; gap: 6px; padding: 18px 20px; align-items: center; }
.thinking span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-bright); animation: bounce 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,100% { transform: translateY(0); opacity:.4; } 50% { transform: translateY(-5px); opacity:1; } }

.threadbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.threadbar h2 {
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 1.05rem; font-weight: 650; flex: 1; min-width: 12rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.danger {
  min-height: var(--tap); font: inherit; font-size: .95rem; cursor: pointer;
  background: var(--panel); color: var(--red); font-weight: 650;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 15px;
}
.danger:hover { border-color: var(--red); background: rgba(252, 165, 165, .08); }

.quota {
  font-size: 1rem; color: var(--muted); padding: 10px 3px 6px;
  border-top: 1px solid var(--line); margin-top: 10px;
}
.quota.low { color: var(--gold); font-weight: 700; }
.quota b { color: var(--ink); }

.plans {
  border: 1px solid var(--line-strong); background: var(--panel);
  border-radius: var(--radius); padding: 24px 26px; margin: 12px 0 20px;
}
.plans h2 {
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 1.4rem; font-weight: 700;
}
.plans p { font-size: 1.05rem; line-height: 1.7; color: var(--muted); margin-top: 12px; }
.plans p b { color: var(--ink); font-weight: 700; }
.plans a.cta {
  display: inline-block; margin-top: 18px; background: var(--accent);
  color: var(--accent-ink); padding: 14px 22px; border-radius: var(--radius);
  font-size: 1.05rem; font-weight: 700; text-decoration: none;
  min-height: var(--tap);
}
.plans a.cta:hover { background: var(--accent-dark); }
.plannote { margin-top: 14px; font-size: .9rem; color: var(--muted); }

/* Wall rows: the two ways forward, stacked, separated by hairlines. The
   rows replace the old paragraph-plus-single-button wall, which asked a
   spent visitor to read past the thing they wanted. */
.planrows { margin-top: 18px; }
.planrow {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: 16px 0;
  border-top: 1px solid var(--line);
}
.planrow:last-child { border-bottom: 1px solid var(--line); }
.planwhat { flex: 1; min-width: 14rem; display: flex; flex-direction: column; gap: 4px; }
.planwhat b { color: var(--ink); font-size: 1.05rem; font-weight: 700; }
.planwhat span { color: var(--muted); font-size: .95rem; line-height: 1.6; }
.ctabtn {
  min-height: var(--tap); cursor: pointer; font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent-dark); border-radius: var(--radius);
  padding: 12px 18px; font-size: 1rem;
}
.ctabtn:hover { background: var(--accent-dark); }
.ctabtn[disabled] { opacity: .55; cursor: wait; }

/* ── the account block (sidebar) ─────────────────────────────────────── */
.acct { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.acctopen {
  min-height: var(--tap); width: 100%; cursor: pointer; font: inherit;
  font-weight: 650; font-size: 1rem;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 12px 14px;
}
.acctopen:hover { background: var(--panel-hover); border-color: var(--accent-bright); }
.acctform { display: flex; flex-direction: column; gap: 8px; }
.acctform label {
  font-size: .9rem; font-weight: 650; color: var(--ink); padding-left: 2px;
}
.acctform input {
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink);
  border-radius: var(--radius); padding: 12px 14px;
  font: inherit; font-size: 1rem; outline: none; width: 100%;
  min-height: var(--tap);
}
.acctform input:focus { border-color: var(--accent-bright); }
.accterr { color: var(--red); font-size: .9rem; line-height: 1.5; }
.acctbtns { display: flex; gap: 8px; }
.acctbtns button {
  flex: 1; min-height: var(--tap); cursor: pointer; font: inherit;
  font-weight: 700; font-size: .95rem; border-radius: var(--radius);
  padding: 10px 12px;
}
.acctbtns #acctIn { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent-dark); }
.acctbtns #acctIn:hover { background: var(--accent-dark); }
.acctbtns #acctUp { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.acctbtns #acctUp:hover { border-color: var(--accent-bright); background: var(--accent-soft); }
.acctbtns button[disabled] { opacity: .55; cursor: wait; }
.acctnote { font-size: .85rem; color: var(--muted); line-height: 1.55; }
.acctwho { display: flex; flex-direction: column; gap: 2px; }
.acctmail { font-weight: 650; font-size: .95rem; overflow-wrap: anywhere; }
.accttier { font-size: .85rem; color: var(--muted); }
.acctout {
  margin-top: 8px; min-height: var(--tap); cursor: pointer; font: inherit;
  font-size: .9rem; font-weight: 650;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 14px;
}
.acctout:hover { color: var(--ink); border-color: var(--line-strong); }

/* The post-checkout page (billing.py success_url) reuses the wall panel. */
.welcomepage { max-width: 52rem; margin: 0 auto; padding: 40px 22px; }

.composer {
  position: sticky; bottom: 0;
  background: rgba(15, 10, 26, .72);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 14px 22px 18px;
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  max-width: 52rem; margin: 0 auto; width: 100%;
}
.field { flex: 1; min-width: 14rem; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .95rem; font-weight: 700; color: var(--ink); padding-left: 2px; }
textarea {
  resize: none; min-height: var(--tap); max-height: 14rem;
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink);
  border-radius: var(--radius); padding: 14px 16px;
  font: inherit; font-size: 1.1rem; line-height: 1.55; outline: none;
  width: 100%;
}
textarea::placeholder { color: var(--muted); opacity: 1; }
button.send {
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent-bright); border-radius: var(--radius);
  min-height: var(--tap); padding: 15px 26px;
  font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer;
  flex: 0 0 auto;
}
button.send:hover { background: var(--accent-dark); }
button.send[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.backdrop { display: none; }

/* Glass bars without backdrop-filter support fall back to solid ground, so
   the sticky bars never go translucent enough to blur what is under them. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header, .composer { background: var(--bg); }
  fieldset.textsize { background: var(--panel); }
}

/* ── narrow ────────────────────────────────────────────────────────── */
@media (max-width: 60rem) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(21rem, 88vw); z-index: 30;
    transform: translateX(-102%); transition: transform .18s ease;
    box-shadow: 2px 0 24px rgba(0, 0, 0, .5);
  }
  body[data-drawer="open"] .sidebar { transform: none; }
  body[data-drawer="open"] .backdrop {
    display: block; position: fixed; inset: 0; z-index: 20;
    background: rgba(5, 2, 12, .6); border: 0;
  }
  .menubtn { display: block; }
  .msg { max-width: 100%; }
  .welcome h2 { font-size: 1.6rem; }
  main { padding: 16px 16px 8px; }
  .composer { padding: 12px 16px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .composer, .headright, .threadbar, .pride { display: none; }
  body { background: #fff; color: #111; }
  .msg.user .bubble, .msg.ai .bubble { background: #fff; border-color: #ccc; }
  .welcome p, .plans p { color: #333; }
}
