/* Theme tokens. Light is the original warm sunset design; Dark is the blue-and-gold design. data-theme is set before first paint by /theme.js. */
:root, [data-theme="light"] {
  --navy: #072645; --navy-2: #17467a; --terra: #a84e2c; --terra-dark: #8f3d20; --gold: #d99532; --gold-deep: #856300; --canvas-a: #fdeedd; --canvas-b: #fff7ed; --h2: #7a3517;
  --bg: #fff7ed; --panel: #fff7ed; --ink: #2b2320; --muted: #5b4a3a; --line: #e0c9a6; --line-strong: #e0c9a6;
  --bot: #ffffff; --user: #0e3a66; --user-ink: #ffffff; --link: #1d5ea8; --err: #8f2222; --chip: #fde9cc; --chip-line: #d9a766; --chip-ink: #3a2418; --input: #ffffff;
  --page-bg: #fff7ed; --log-bg: linear-gradient(180deg, #fdeedd, #fff7ed);
  --top-bg: linear-gradient(90deg, #b85c38, #9a4424); --top-line: #d99532; --top-ink: #fff; --top-edge: rgba(255,255,255,.55); --top-hover: rgba(255,255,255,.14);
  --accent: #d99532; --focus: #1d5ea8; --focus-field: #a84e2c;
  --chip-accent: #d99532; --chip-hover: #fbdcae; --chip-hover-line: #c27a2c; --chip-active: #f6cd91; --chip-shadow: rgba(143,61,32,.2);
  --pri-bg: #a84e2c; --pri-hover: #8f3d20; --pri-line: #a84e2c; --pri-ink: #fff; --pri-glow: none;
  --sec-bg: #a84e2c; --sec-hover: #8f3d20; --sec-line: #a84e2c; --sec-ink: #fff;
  --out-line: #a84e2c; --out-ink: #8f3d20; --out-hover-bg: #a84e2c; --out-hover-ink: #fff; --out-bg: transparent;
  --abtn-bg: #fff; --abtn-hover: #fde9cc;
  --dis-bg: #efe3d0; --dis-line: #dcc9a8; --dis-ink: #6b5f4c; --placeholder: #757575;
  --field-bg: #fff; --err-bg: #fff1ee; --rq-err-bg: #fdecea; --rq-err-ink: #5c1410; --rq-err-line: #b3261e; --ferr: #b3261e;
  --about-line: #d99532; --hero-ink: #7a3517;
  --tile-bg: #072645; --tile-line: #d99532; --tile-ink: #fff;
}
[data-theme="dark"] {
  --navy: #04122b; --navy-2: #17467a; --terra: #4fc3f7; --terra-dark: #8fd8ff; --gold: #e8a33d; --gold-deep: #8fd8ff; --canvas-a: #062046; --canvas-b: #0a2c58; --h2: #ffffff;
  --bg: #04122b; --panel: #0b2142; --ink: #d9e7f7; --muted: #93aecb; --line: rgba(120,180,255,.16); --line-strong: rgba(120,180,255,.28);
  --bot: #0e2a50; --user: linear-gradient(160deg, #1d5a9c 0%, #17467a 100%); --user-ink: #ffffff; --link: #8fd8ff; --err: #ff8d8d; --chip: #0e2a50; --chip-line: rgba(120,180,255,.28); --chip-ink: #d9e7f7; --input: #0e2a50;
  --page-bg: linear-gradient(178deg, #04122b 0%, #062046 55%, #0a2c58 100%);
  --log-bg: radial-gradient(1200px 500px at 50% 108%, rgba(56,160,255,.30), transparent 60%), radial-gradient(900px 420px at 50% -12%, rgba(30,90,180,.35), transparent 65%), linear-gradient(178deg, #04122b 0%, #062046 55%, #0a2c58 100%);
  --top-bg: linear-gradient(90deg, #0a2a54, #0d3568); --top-line: rgba(120,180,255,.28); --top-ink: #fff; --top-edge: rgba(120,180,255,.28); --top-hover: rgba(79,195,247,.16);
  --accent: #4fc3f7; --focus: #4fc3f7; --focus-field: #4fc3f7;
  --chip-accent: #4fc3f7; --chip-hover: #12335f; --chip-hover-line: #4fc3f7; --chip-active: #163d6f; --chip-shadow: rgba(79,195,247,.18);
  --pri-bg: linear-gradient(180deg, #f2b654 0%, #e8a33d 55%, #c97f1e 100%); --pri-hover: linear-gradient(180deg, #f6c36e 0%, #eeae4c 55%, #d58a25 100%); --pri-line: #c97f1e; --pri-ink: #23160a; --pri-glow: 0 4px 14px rgba(232,163,61,.35);
  --sec-bg: rgba(79,195,247,.12); --sec-hover: rgba(79,195,247,.24); --sec-line: #4fc3f7; --sec-ink: #8fd8ff;
  --out-line: #4fc3f7; --out-ink: #8fd8ff; --out-hover-bg: rgba(79,195,247,.2); --out-hover-ink: #ffffff; --out-bg: transparent;
  --abtn-bg: #0e2a50; --abtn-hover: #12335f;
  --dis-bg: #12315c; --dis-line: rgba(120,180,255,.16); --dis-ink: #6f8aa8; --placeholder: #93aecb;
  --field-bg: #0b2142; --err-bg: #2f1820; --rq-err-bg: #3a1512; --rq-err-ink: #ffd9d4; --rq-err-line: #ff8a80; --ferr: #ff8a80;
  --about-line: #4fc3f7; --hero-ink: #ffffff; --tile-bg: #0b2142; --tile-line: #4fc3f7;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
.app { height: 100dvh; }
body { background: var(--page-bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.app { max-width: 780px; height: 100%; margin: 0 auto; display: flex; flex-direction: column; background: var(--panel);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 4px solid var(--top-line); background: var(--top-bg); color: var(--top-ink); }
.logo { width: 44px; height: 44px; flex: none; border-radius: 50%; }
h1 { flex: 1; min-width: 0; margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: .01em; color: var(--top-ink); }
.badge { font-size: .7rem; font-weight: 700; letter-spacing: .08em; border: 1px solid var(--top-ink); color: var(--top-ink); border-radius: 999px; padding: 2px 9px; }
.ghost { border: 1px solid var(--top-edge); background: transparent; color: var(--top-ink); min-height: 44px; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .84rem; cursor: pointer; }
.ghost:hover { border-color: var(--top-ink); background: var(--top-hover); }
.top button:focus-visible, .top a:focus-visible { outline-color: var(--top-ink); }
button:focus-visible, textarea:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.log { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; background: var(--log-bg); }
.welcome { margin: 0 auto auto; max-width: 560px; text-align: left; padding: 8px 0 18px; }
.hero { display: block; width: 88px; height: 88px; margin: 0 auto 10px; border-radius: 50%; }
.welcome h2 { margin: 0 0 8px; font-size: 1.75rem; line-height: 1.2; font-weight: 800; color: var(--h2); }
.lead { margin: 0 0 6px; font-size: 1.02rem; }
.disclose { margin: 0 0 18px; font-size: .84rem; color: var(--muted); }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.chips button { border: 1px solid var(--chip-line); border-left: 5px solid var(--chip-accent); background: var(--chip); color: var(--chip-ink); border-radius: 10px; padding: 13px 15px; min-height: 48px; font: inherit; font-size: 1rem; font-weight: 600;
  line-height: 1.4; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s; }
.chips button:hover { border-color: var(--chip-hover-line); border-left-color: var(--chip-accent); background: var(--chip-hover); box-shadow: 0 2px 8px var(--chip-shadow); }
.chips button:active { background: var(--chip-active); box-shadow: none; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 85%; padding: 11px 15px; border-radius: 10px; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; }
.bot .bubble { background: var(--bot); border: 1px solid var(--line); }
.user .bubble { background: var(--user); color: var(--user-ink); white-space: pre-wrap; }
.bubble p.cut { margin-top: .6em; font-style: italic; color: var(--muted); border-top: 1px dashed var(--line); padding-top: .5em; }
.bubble p { margin: 0 0 .65em; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: .3em 0 .65em; padding-left: 1.3em; } .bubble li { margin-bottom: .25em; }
.bubble strong { font-weight: 650; }
.err .bubble { border-color: var(--err); color: var(--err); }
.cta { margin-top: 12px; } .cta a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 10px; background: var(--sec-bg); box-shadow: inset 0 0 0 1px var(--sec-line); color: var(--sec-ink); font-weight: 700; text-decoration: none; }
.cta a:hover { background: var(--sec-hover); } .cta a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.src { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); line-height: 1.5; }
.src a { color: var(--link); text-decoration: none; border-bottom: 1px dotted currentColor; word-break: break-word; }
.src a:hover { border-bottom-style: solid; }
.src .lab { text-transform: uppercase; letter-spacing: .07em; font-size: .68rem; font-weight: 700; margin-right: 6px; }
.src .sep { margin: 0 4px; }
.src details { margin-top: 4px; } .src summary { cursor: pointer; }
.src details p { margin: 4px 0 0; }
.composer { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel); }
textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 11px 14px; font: inherit; background: var(--input); color: var(--ink); max-height: 120px; }
textarea:focus { border-color: var(--focus-field); }
textarea::placeholder { color: var(--placeholder); opacity: 1; }
#send { border: 1px solid var(--pri-line); border-radius: 8px; padding: 0 22px; min-height: 44px; background: var(--pri-bg); color: var(--pri-ink); box-shadow: var(--pri-glow); font: inherit; font-weight: 700; cursor: pointer; }
#send:hover:not(:disabled) { background: var(--pri-hover); border-color: var(--pri-line); }
#send:disabled { background: var(--dis-bg); border-color: var(--dis-line); color: var(--dis-ink); box-shadow: none; cursor: not-allowed; }
.verify { padding: 8px 18px; border-top: 1px solid var(--line); background: var(--panel); } .verify p { margin: 0 0 6px; font-size: .82rem; color: var(--muted); }
.status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 18px; border-top: 1px solid var(--line); background: var(--panel); font-size: .86rem; color: var(--muted); }
.status.bad { background: var(--err-bg); color: var(--err); border-top-color: var(--err); }
.retry { min-height: 40px; border: 1px solid var(--sec-line); border-radius: 8px; background: var(--sec-bg); color: var(--sec-ink); padding: 0 14px; font: inherit; font-weight: 600; cursor: pointer; }
.note { padding: 6px 18px max(12px, env(safe-area-inset-bottom)); font-size: .75rem; color: var(--muted); text-align: center; }
.note a { color: var(--link); }
.dots span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: b 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes b { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.consult { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.consult p { margin: 0; font-size: 14.5px; color: var(--muted); }
.consult a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 2px solid var(--out-line); color: var(--out-ink); background: var(--out-bg); font-weight: 700; font-size: 15px; text-decoration: none; }
.consult a:hover { background: var(--out-hover-bg); color: var(--out-hover-ink); } .consult a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.consult { flex-direction: column; align-items: flex-start; }
.consult .acts { display: flex; flex-wrap: wrap; gap: 8px; }
.consult .bk, .cta .bk, .rq .bk { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 2px solid var(--pri-line); background: var(--pri-bg); color: var(--pri-ink); box-shadow: var(--pri-glow); font: inherit; font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; }
.consult .bk:hover, .cta .bk:hover, .rq .bk:hover { background: var(--pri-hover); border-color: var(--pri-line); } .consult .bk:focus-visible, .cta .bk:focus-visible, .rq .bk:focus-visible, .rq .alt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.rq { display: block; max-width: 100%; } .rq h3 { margin: 0 0 8px; font-size: 1.1em; font-weight: 800; color: var(--h2, var(--terra-dark)); }
.rq p { margin: 0 0 10px; line-height: 1.5; } .rq .rq-warn, .rq .rq-small { font-size: 13.5px; color: var(--muted); }
.rq label { display: block; margin: 0 0 10px; font-weight: 600; font-size: 14.5px; }
.rq input:not([type=checkbox]), .rq select, .rq textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; min-height: 44px; padding: 8px 10px; font: inherit; font-size: 16px; font-weight: 400; color: var(--ink); background: var(--field-bg); border: 1px solid var(--line-strong); border-radius: 8px; }
.rq textarea { min-height: 76px; resize: vertical; } .rq .rq-out { min-height: 140px; font-size: 14px; }
.rq-ck { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 400 !important; } .rq-ck input { width: 22px; height: 22px; flex: none; margin: 2px 0 0; }
.rq-opt { margin: 0 0 10px; } .rq-opt summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; list-style: none; } .rq-opt summary::-webkit-details-marker { display: none; } .rq-opt summary::after { content: "+"; margin-left: 8px; font-size: 1.2em; } .rq-opt[open] summary::after { content: "\2212"; }
.rq-err { margin: 0 0 10px; padding: 8px 10px; border-left: 4px solid var(--rq-err-line); background: var(--rq-err-bg); color: var(--rq-err-ink); border-radius: 6px; font-size: 14px; }
.rq-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.rq .alt, .cta .alt-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 2px solid var(--out-line); background: var(--out-bg); color: var(--out-ink); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.rq .alt:hover { background: var(--out-hover-bg); color: var(--out-hover-ink); }
.cta { display: flex; flex-wrap: wrap; gap: 8px; }
.cta a.alt { background: var(--out-bg); border: 2px solid var(--out-line); color: var(--out-ink); } .cta a.alt:hover { background: var(--out-hover-bg); color: var(--out-hover-ink); }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; } .chips button { transition: none; } .log { scroll-behavior: auto; } }
@media (max-width: 560px) {
  .app { border: 0; }
  .top { gap: 9px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .logo { width: 34px; height: 34px; } h1 { font-size: .94rem; line-height: 1.15; } .ghost { padding: 6px 11px; }
  .welcome .assess { display: none; }
  .log { padding: 14px; overscroll-behavior: contain; }
  .hero { width: 56px; height: 56px; } .welcome h2 { font-size: 1.35rem; }
  .chips button, .assess button, .abar button, .ghost { min-height: 44px; }
  .chips { grid-template-columns: 1fr; }
  .bubble { max-width: 94%; }
  .composer { padding: 10px 12px; }
}

.about { margin: 0 18px; padding: 8px 12px; border-left: 3px solid var(--about-line); background: var(--bot); border-radius: 0 10px 10px 0; font-size: .8rem; color: var(--muted); }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--link); cursor: pointer; text-decoration: underline; }

.assess { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }
.assess .alab { width: 100%; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.assess button { border: 1px solid var(--gold-deep); background: transparent; color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .86rem; cursor: pointer; }
.assess button:hover { background: var(--bot); }
.assess small { color: var(--muted); font-size: .75rem; }
.msg.assess-msg { display: block; }

.abar { padding: 8px 18px 0; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); background: var(--panel); }
.abar + .composer { border-top: 0; padding-top: 8px; }
@media (max-width: 520px) { .abar { padding: 8px 12px 0; } }
.abar button { flex: 1 1 auto; justify-content: center; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; border: 2px solid var(--out-line); background: var(--abtn-bg); color: var(--out-ink); font-weight: 700; border-radius: 8px; padding: 0 14px; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.abar button:hover { background: var(--abtn-hover); }
.abar button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.rq-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.consult[hidden] { display: none; }
.rq-ferr { margin: -4px 0 10px; font-size: 13.5px; font-weight: 600; color: var(--ferr); } .rq [aria-invalid=true] { border-color: var(--ferr) !important; }

/* Header monogram (BG) and appearance selector. Same circular mark in both themes; Light keeps the navy disc with the gold ring, Dark uses the cyan ring. To use an approved logo later, replace the .mono element. */
.mono { display: flex; width: 44px; height: 44px; flex: none; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid var(--tile-line); background: var(--tile-bg); color: var(--tile-ink); font-weight: 800; font-size: .95rem; letter-spacing: .02em; line-height: 1; }
.themesel { flex: none; display: inline-flex; }
.themesel select { min-height: 44px; border: 1px solid var(--top-edge); border-radius: 999px; background-color: transparent; color: var(--top-ink); font: inherit; font-size: .84rem; padding: 0 10px; cursor: pointer; }
.themesel select:hover { border-color: var(--top-ink); background-color: var(--top-hover); }
.themesel option { color: #1c2330; background: #fff; }
[data-theme="dark"] .themesel option { color: #d9e7f7; background: #0b2142; }
@media (max-width: 560px) { .top { gap: 6px; } .badge { flex: none; } .mono { width: 34px; height: 34px; font-size: .78rem; } .themesel select { padding: 0 4px; font-size: .8rem; } }

/* Assessment module: its own dark rules follow the OS setting, so the chosen theme is applied explicitly here. */
[data-theme="light"] .bga { --a-gold-deep: #7a5600; --a-runs: #1f7a4d; --a-gaps: #8a5300; --a-inactive: #a12a2a; --a-some: #8a5300; }
[data-theme="light"] .bga-yn button.on { background: var(--a-navy); }
[data-theme="dark"] .bga { --a-navy: #04122b; --a-gold: #4fc3f7; --a-gold-deep: #8fd8ff; --a-runs: #4fc58a; --a-gaps: #f0b24a; --a-inactive: #ff8d8d; --a-some: #f0b24a; }
[data-theme="dark"] .bga-yn button.on, [data-theme="dark"] .bgr-scale button.on { background: #1d5a9c; border-color: #1d5a9c; }
[data-theme="dark"] .bga-opt .bga-tag:not(.alt) { color: #04122b; }
@media (max-width: 360px) { .top { flex-wrap: wrap; row-gap: 6px; } .themesel { margin-left: auto; } }

.brand { flex: 1; min-width: 0; line-height: 1.2; } .brand h1 { margin: 0; }
.tagline { display: block; margin-top: 1px; font-size: .74rem; font-weight: 500; letter-spacing: .02em; color: var(--top-ink); opacity: .92; }
@media (max-width: 360px) { .brand { flex: 1 1 130px; } }
