/* ---------- Tyro Buddy shell: warm cream + orange, Home / Chat / Library / Profile ---------- */
:root {
  --bg: #fbf6ef; --panel: #ffffff; --ink: #1f1a16; --muted: #8a8076; --line: #f0e6da;
  --brand: #f57c1f; --brand-2: #ff9a3d; --gold: #e39b2f; --gold-soft: #fff3e4;
  --user: #f57c1f; --user-ink: #ffffff; --sec: #faf1e6; --mark: #ffe2b8;
  --shadow: 0 4px 18px rgba(90, 55, 20, .07);
  --hero1: #2a1910; --hero2: #5b3517;
  --t1: #fff1e3; --t1i: #f57c1f; --t2: #eeeefe; --t2i: #5b5bd6; --t3: #eaf6ee; --t3i: #2f9e5b;
  --t4: #fdeef1; --t4i: #e5486a; --t5: #e9f3fd; --t5i: #2f7fd6; --t6: #fff4e6; --t6i: #f08a24;
  --tab-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15110d; --panel: #201a15; --ink: #f3ece4; --muted: #a99d90; --line: #30271f;
    --brand: #ff8a2b; --brand-2: #ffa24f; --gold: #f0b04f; --gold-soft: #3a2a18;
    --user: #e8731a; --sec: #2a221b; --mark: #5c3d14; --shadow: 0 4px 18px rgba(0, 0, 0, .35);
    --t1: #3a2614; --t2: #26263f; --t3: #1d3326; --t4: #3d2028; --t5: #1c2b3d; --t6: #3b2a16;
  }
}
:root[data-theme="dark"] {
  --bg: #15110d; --panel: #201a15; --ink: #f3ece4; --muted: #a99d90; --line: #30271f;
  --brand: #ff8a2b; --brand-2: #ffa24f; --gold: #f0b04f; --gold-soft: #3a2a18;
  --user: #e8731a; --sec: #2a221b; --mark: #5c3d14; --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  --t1: #3a2614; --t2: #26263f; --t3: #1d3326; --t4: #3d2028; --t5: #1c2b3d; --t6: #3b2a16;
}

[hidden] { display: none !important; }
body { display: block; min-height: 100%; font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
button { color: inherit; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: none; place-items: center; padding: 24px 20px; padding-top: max(24px, env(safe-area-inset-top));
  background: radial-gradient(120% 70% at 50% 0%, var(--gold-soft), var(--bg) 60%); }
body.signed-out .auth { display: grid; }
body.signed-out .app-shell { display: none; }
.auth-card { width: min(400px, 100%); text-align: center; }
.auth-logo { width: 96px; height: 96px; margin: 0 auto 6px; border-radius: 28px; padding: 14px; background: linear-gradient(145deg, var(--hero1), var(--hero2)); box-shadow: 0 12px 30px rgba(90, 50, 15, .3); }
.auth-logo { background: #120c0a; }
.auth-logo img, .auth-logo svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.auth-title { margin: 10px 0 2px; font-size: 28px; letter-spacing: -.3px; }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; }
#authForm { display: grid; gap: 14px; text-align: left; }
.af > span:first-child { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px 2px; }
.af input { width: 100%; height: 50px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); padding: 0 14px; font: inherit; font-size: 15.5px; }
.af input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.pw-eye { position: absolute; right: 6px; top: 6px; width: 38px; height: 38px; border: 0; background: none; color: var(--muted); border-radius: 10px; display: grid; place-items: center; }
.auth-err { margin: 0; color: #d64545; font-size: 13.5px; background: color-mix(in srgb, #d64545 10%, transparent); padding: 9px 12px; border-radius: 10px; }
.auth-go { height: 52px; border: 0; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 700; font-size: 16px; margin-top: 4px; box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 35%, transparent); }
.auth-go:disabled { opacity: .6; }
.auth-switch { margin: 18px 0 6px; font-size: 14px; color: var(--muted); }
.auth-switch button { border: 0; background: none; color: var(--brand); font-weight: 700; padding: 4px; }
.auth-note { font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- Views + tab bar ---------- */
.app-shell { max-width: 720px; margin: 0 auto; min-height: 100vh; }
.view { padding: 0 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
.view[hidden] { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; background: var(--panel);
  border-top: 1px solid var(--line); padding: 6px 8px max(8px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(90, 55, 20, .06); }
.tabbar button { flex: 1; max-width: 120px; border: 0; background: none; display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabbar button.on { color: var(--brand); }
.tabbar button.on .ic { fill: color-mix(in srgb, var(--brand) 18%, transparent); }
body[data-view="chat"] .tabbar { display: none; }
.icon-btn { width: 40px; height: 40px; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; color: var(--ink); flex: 0 0 auto; }
.icon-btn:hover { background: var(--sec); }
.sec-row { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 2px 10px; }
.sec-row h3 { margin: 0; font-size: 18px; letter-spacing: -.2px; }
.see-all { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 14px; }
.muted-ic { color: var(--muted); }

/* ---------- Home ---------- */
#view-home { padding-top: 0; }
.hero { position: relative; overflow: hidden; margin: 0 -16px; padding: max(18px, env(safe-area-inset-top)) 22px 64px; color: #fff;
  background: radial-gradient(90% 80% at 85% 25%, rgba(255, 190, 110, .28), transparent 60%), linear-gradient(160deg, var(--hero1) 0%, #3b2313 55%, var(--hero2) 100%);
  border-radius: 0 0 30px 30px; }
.hero-art { position: absolute; right: -46px; top: 64px; width: 190px; height: 190px; opacity: .55; filter: drop-shadow(0 8px 24px rgba(255, 170, 70, .35)); pointer-events: none; }
.hero-top { position: relative; display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-bottom: 26px; }
.hero-btn { position: relative; width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; }
.dot-red { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: #ff4d4f; border: 2px solid #3b2313; }
.avatar-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); background: #d8cfc6; color: #3b2a1c; font-weight: 700; font-size: 14px; }
.hero-hi { position: relative; margin: 0; font-size: 26px; font-weight: 400; color: #fff; max-width: 78%; overflow-wrap: anywhere; }
.hero-h { position: relative; margin: 2px 0 12px; font-size: 32px; line-height: 1.12; letter-spacing: -.5px; max-width: 70%; }
.hero-p { position: relative; margin: 0; max-width: 72%; font-size: 14.5px; line-height: 1.5; color: rgba(255, 255, 255, .85); }
.hero-ask { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; margin: -34px 4px 0; background: var(--panel); border-radius: 22px;
  padding: 8px 8px 8px 18px; box-shadow: 0 12px 30px rgba(90, 55, 20, .12); }
.hero-ask input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 15.5px; height: 44px; }
.hero-ask input:focus { outline: none; }
.go, .ask .send { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 40%, transparent); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; }
.tile { border: 0; border-radius: 20px; padding: 18px 8px 14px; display: grid; justify-items: center; gap: 10px; font-size: 13.5px; line-height: 1.3; color: var(--ink); min-height: 112px; align-content: center; transition: transform .12s; }
.tile:active { transform: scale(.97); }
.tile .ic { width: 34px; height: 34px; stroke-width: 1.6; }
.t1 { background: var(--t1); } .t1 .ic { color: var(--t1i); }
.t2 { background: var(--t2); } .t2 .ic { color: var(--t2i); }
.t3 { background: var(--t3); } .t3 .ic { color: var(--t3i); }
.t4 { background: var(--t4); } .t4 .ic { color: var(--t4i); }
.t5 { background: var(--t5); } .t5 .ic { color: var(--t5i); }
.t6 { background: var(--t6); } .t6 .ic { color: var(--t6i); }
.q-list { display: grid; gap: 10px; }
.q-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); background: var(--panel); border-radius: 16px; padding: 15px 14px 15px 18px; text-align: left; font-size: 14.5px; color: var(--ink); }
.q-row .ic { width: 18px; height: 18px; color: var(--muted); }

/* ---------- Chat ---------- */
.chat-view { padding: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.chat-view[hidden] { display: none; }
.chat-top { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.bot-av { width: 46px; height: 46px; border-radius: 50%; background: #241812; color: var(--gold); display: grid; place-items: center; flex: 0 0 auto; }
.bot-av .ic { width: 24px; height: 24px; }
.bot-av img { width: 72%; height: 72%; object-fit: contain; }
.hero-art { object-fit: contain; }
.bot-av.sm { width: 38px; height: 38px; margin-top: 2px; }
.bot-av.sm .ic { width: 20px; height: 20px; }
.chat-title { flex: 1; min-width: 0; line-height: 1.25; }
.chat-title b { display: block; font-size: 18px; }
.chat-title small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2fb36b; margin-right: 6px; vertical-align: 1px; }
.icon-btn.ai-chip { border: 0; padding: 0; color: var(--ink); background: none; }
.icon-btn.ai-chip.on, .icon-btn.ai-chip.cloud { color: var(--brand); }
.chat-view .log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; gap: 16px; }
.msg { position: relative; flex-wrap: wrap; align-items: flex-start; }
.msg.bot .bubble { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px 20px 20px 20px; padding: 14px 16px; box-shadow: var(--shadow); max-width: calc(100% - 48px); }
.msg.user .bubble { background: var(--brand); color: #fff; border-radius: 20px 20px 6px 20px; padding: 12px 16px; max-width: 82%; font-size: 15px; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 25%, transparent); }
.stamp { flex-basis: 100%; font-size: 11px; color: var(--muted); padding: 4px 6px 0 52px; }
.msg.user .stamp { text-align: right; padding-right: 6px; }
.msg.pending .stamp, .welcome-msg .stamp { display: none; }
.ans ol, .ans ul.points { padding-left: 0; list-style: none; counter-reset: pt; }
.ans ul.points > li { position: relative; padding-left: 36px; margin: 10px 0; counter-increment: pt; }
.ans ul.points > li::before { content: counter(pt); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12.5px; font-weight: 700; display: grid; place-items: center; }
.engine-tag .dot { background: var(--brand); }
.actions { margin: 10px 0 0; gap: 8px; }
.actions button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.actions button.on, .actions button:hover { border-color: var(--brand); color: var(--brand); background: var(--gold-soft); }
.followups .chip { border-color: var(--line); background: var(--sec); color: var(--ink); }
.welcome-msg .followups { margin-top: 10px; }
.welcome-msg .mini { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.chat-view .bar { padding: 8px 12px max(10px, env(safe-area-inset-bottom)); background: var(--bg); }
.ask { border-radius: 24px; border: 1px solid var(--line); padding: 6px; gap: 4px; align-items: center; }
.ask .in-btn { color: var(--muted); }
.ask .send { width: 44px; height: 44px; }
.mic.rec { color: #fff; }

/* ---------- Sheets (history) ---------- */
.sheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-h b { font-size: 18px; }
.new-chat { display: inline-flex; gap: 6px; align-items: center; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 600; padding: 8px 12px; }
.new-chat .ic { width: 18px; height: 18px; }
#historySheet .chat-list { max-height: 60vh; }
.chat-list li.cur { background: var(--gold-soft); }

/* ---------- Library ---------- */
#view-library { padding-top: max(16px, env(safe-area-inset-top)); }
.lib-search { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); }
.lib-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 15px; height: 42px; }
.lib-search input:focus { outline: none; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tool { border: 1px solid var(--line); background: var(--panel); border-radius: 18px; padding: 16px 8px 14px; display: grid; justify-items: center; gap: 6px; text-align: center; color: var(--ink); }
.tool .ic { width: 32px; height: 32px; color: var(--brand); stroke-width: 1.6; margin-bottom: 4px; }
.tool b { font-size: 13.5px; line-height: 1.25; }
.tool small { font-size: 12px; color: var(--muted); line-height: 1.35; }
.promo { position: relative; overflow: hidden; display: flex; align-items: center; margin-top: 18px; border-radius: 22px; padding: 22px 20px; color: #fff;
  background: radial-gradient(70% 90% at 90% 60%, rgba(255, 180, 90, .25), transparent 60%), linear-gradient(150deg, #241812, #4a2c16); }
.promo b { font-size: 21px; display: block; }
.promo p { margin: 6px 0 14px; font-size: 14px; color: rgba(255, 255, 255, .85); max-width: 70%; }
.promo-go { border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; padding: 10px 18px; }
.promo-art { position: absolute; right: 8px; bottom: 6px; width: 110px; height: 110px; fill: none; stroke: #f0b04f; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 13px 14px; font-size: 14px; text-align: left; color: var(--ink); }
.cat .ic { color: var(--ink); }
.lib-results { margin-top: 14px; }
.lib-back { display: inline-flex; gap: 6px; align-items: center; border: 0; background: none; color: var(--brand); font-weight: 600; padding: 6px 2px; }
.lib-back .ic { width: 18px; height: 18px; }
.lib-h { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; font-size: 19px; }
.lib-h .ic { color: var(--brand); }
.topics { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.topic { display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.topic-ask { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px 14px; text-align: left; color: var(--ink); }
.topic-ask b { display: block; font-size: 14px; font-weight: 600; }
.topic-ask small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-read { width: 46px; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; color: var(--brand); display: grid; place-items: center; }
.ask-ai { display: flex; gap: 8px; align-items: center; justify-content: center; width: 100%; margin-top: 14px; border: 0; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 700; padding: 13px; }
.dict { display: grid; gap: 8px; margin-top: 12px; }
.dict-item { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px 14px; }
.dict-item summary { cursor: pointer; font-size: 15px; }
.dict-item p { margin: 8px 0 0; font-size: 14px; }
.dict-item .chip { margin-top: 10px; }

/* ---------- Profile ---------- */
#view-profile { padding-top: max(20px, env(safe-area-inset-top)); }
.prof-head { display: flex; align-items: center; gap: 14px; margin: 6px 2px 16px; }
.prof-av { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(145deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; font-size: 22px; display: grid; place-items: center; }
.prof-head b { display: block; font-size: 20px; }
.prof-head small { color: var(--muted); font-size: 14px; }
#view-profile .me-card { width: 100%; background: linear-gradient(135deg, var(--gold-soft), var(--panel)); }
.menu-list { display: grid; margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.menu-list button { display: flex; align-items: center; gap: 14px; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 15px 16px; text-align: left; font-size: 15px; color: var(--ink); }
.menu-list button:last-child { border-bottom: 0; }
.menu-list button span { flex: 1; }
.menu-list .ic { color: var(--brand); }
.menu-list .chev { width: 18px; height: 18px; color: var(--muted); }
.menu-list .danger, .menu-list .danger .ic { color: #d64545; }
.prof-note { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* ---------- Overlays on top of the tab bar ---------- */
.sheet-wrap, .ai-panel, .arena { z-index: 30; }
.toast-wrap, .toast { z-index: 40; }

@media (min-width: 760px) {
  .hero { margin: 0; border-radius: 0 0 30px 30px; }
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .tools { grid-template-columns: repeat(6, 1fr); }
  .cats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 380px) {
  .hero-h { font-size: 27px; }
  .tiles, .tools { gap: 8px; }
  .tile { font-size: 12.5px; }
}

/* ---------- Category pages + Civil Procedure Guide ---------- */
.cat-hero { display: flex; gap: 14px; align-items: center; margin: 6px 0 4px; padding: 18px; border-radius: 20px; color: #fff;
  background: radial-gradient(80% 120% at 100% 0%, rgba(255, 180, 90, .3), transparent 60%), linear-gradient(150deg, #241812, #4a2c16); }
.cat-hero > .ic { width: 46px; height: 46px; padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, .1); color: #f0b04f; flex: 0 0 auto; }
.cat-hero h3 { margin: 0 0 4px; font-size: 19px; }
.cat-hero p { margin: 0; font-size: 13.5px; line-height: 1.45; color: rgba(255, 255, 255, .82); }
.sec-h2 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 22px 2px 10px; }
.browse-btn { display: flex; gap: 8px; align-items: center; justify-content: center; width: 100%; margin-top: 18px; padding: 13px;
  border: 1.5px dashed var(--line); background: none; border-radius: 14px; color: var(--muted); font-weight: 600; }
.browse-btn .ic { width: 18px; height: 18px; }
.timeline { list-style: none; margin: 18px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 22px; bottom: 22px; width: 2px; background: color-mix(in srgb, var(--brand) 30%, transparent); }
.timeline li { position: relative; margin-bottom: 10px; }
.timeline button { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 0; text-align: left; color: var(--ink); }
.tl-n { position: relative; z-index: 1; width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: 0 0 0 4px var(--bg); }
.tl-t { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.tl-t b { display: block; font-size: 15px; }
.tl-t small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.4; }
.timeline .ic { width: 18px; height: 18px; color: var(--muted); }
.forgot { justify-self: end; border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 14px; padding: 2px 4px; margin-top: -4px; }
#resetForm { display: grid; gap: 14px; text-align: left; }
#resetForm .forgot { justify-self: center; margin-top: 0; }
#resetStep2 { display: grid; gap: 14px; }
.auth-ok { margin: 0; color: #1f8a4c; font-size: 13.5px; background: color-mix(in srgb, #2fb36b 12%, transparent); padding: 9px 12px; border-radius: 10px; }

/* ---------- Legal Dictionary ---------- */
.dict-tools { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; margin: 0 -2px; }
.dict-filter { margin-top: 0; height: 46px; border-radius: 14px; background: var(--panel); }
.az { display: flex; gap: 4px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.az::-webkit-scrollbar { display: none; }
.az button { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-weight: 700; font-size: 13px; }
.az button:active { background: var(--brand); color: #fff; }
.dict { margin-top: 4px; display: grid; gap: 8px; }
.dict-letter { margin: 14px 2px 2px; font-size: 22px; color: var(--brand); }
.dict-item { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px 14px; content-visibility: auto; contain-intrinsic-size: 52px; }
.dict-item summary { cursor: pointer; font-size: 15px; display: flex; align-items: center; gap: 8px; list-style: none; }
.dict-item summary::-webkit-details-marker { display: none; }
.dict-item summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 18px; }
.dict-item[open] summary::after { content: "–"; }
.dict-item .tag { font-size: 11px; font-weight: 700; color: var(--brand); background: var(--gold-soft); border-radius: 999px; padding: 2px 8px; }
.dict-item p { margin: 8px 0 0; font-size: 14.5px; line-height: 1.55; }
.dict-note { color: var(--muted); font-style: italic; border-left: 3px solid var(--brand); padding-left: 10px; }
.dict-analogy { color: var(--muted); }
.dict-item .chip { margin-top: 10px; }
.dict-count { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* ---------- Settings (full-screen page) ---------- */
#settings.sheet-wrap { background: var(--bg); display: block; overflow-y: auto; }
.set-page { max-width: 640px; margin: 0 auto; min-height: 100%; padding-bottom: max(24px, env(safe-area-inset-bottom)); animation: fade .2s; }
.set-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); }
.set-top b { font-size: 18px; }
.set-top span { width: 40px; }
.set-body { padding: 4px 16px; display: grid; gap: 16px; }
.set-me { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.set-me .prof-av { width: 54px; height: 54px; font-size: 19px; flex: 0 0 auto; }
.set-me b { display: block; font-size: 17px; }
.set-me small { color: var(--muted); }
.set-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.set-card h3 { margin: 0; padding: 14px 16px 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; border: 0; background: none; text-align: left; color: var(--ink); font: inherit; }
.set-row + .set-row, .set-pad + .set-row, .set-row.tap { border-top: 1px solid var(--line); }
.set-row.stack { padding-bottom: 4px; }
.set-row .chev, .set-row > .ic { width: 18px; height: 18px; color: var(--muted); }
.set-lbl { flex: 1; min-width: 0; }
.set-lbl b { display: block; font-size: 15px; font-weight: 600; }
.set-lbl small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; margin-top: 2px; }
.set-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; }
.set-ic .ic { width: 19px; height: 19px; }
.c-or { background: var(--t1); color: var(--t1i); } .c-bl { background: var(--t5); color: var(--t5i); } .c-gr { background: var(--t3); color: var(--t3i); }
.c-pu { background: var(--t2); color: var(--t2i); } .c-pk { background: var(--t4); color: var(--t4i); } .c-ink { background: var(--sec); color: var(--ink); }
.set-pad { padding: 4px 16px 14px 64px; display: grid; gap: 10px; }
.set-pad .seg { width: 100%; display: flex; }
.set-pad .seg button { flex: 1; padding: 8px 6px; }
.set-pad .field { margin-top: 0; }
.key-field { position: relative; }
.key-field .field { padding-right: 46px; }
.key-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.set-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.set-adv summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.set-adv .field { margin-top: 8px; }
.disclaimer { display: flex; gap: 12px; margin: 8px 16px 6px; padding: 12px 14px; border-radius: 14px; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.disclaimer .ic { width: 22px; height: 22px; color: var(--brand); flex: 0 0 auto; margin-top: 2px; }
.disclaimer p { margin: 0; font-size: 13.5px; line-height: 1.5; }
@media (max-width: 380px) { .set-pad { padding-left: 16px; } }

/* ---------- One-time disclaimer ---------- */
.notice-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(20, 12, 6, .55); animation: fade .2s; }
.notice { width: min(420px, 100%); background: var(--panel); color: var(--ink); border-radius: 24px; padding: 24px 22px 20px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.notice > .ic { width: 48px; height: 48px; padding: 11px; border-radius: 16px; background: var(--gold-soft); color: var(--brand); }
.notice h3 { margin: 12px 0 8px; font-size: 20px; }
.notice p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.notice p b { color: var(--ink); }
.notice .auth-go { width: 100%; margin-top: 8px; }

/* ---------- Reader (study notes, cases, statutes) ---------- */
#reader.arena { background: var(--bg); display: block; overflow-y: auto; padding: 0; place-items: initial; }
.rd-page { max-width: 720px; margin: 0 auto; min-height: 100%; animation: fade .2s; }
.rd-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px 12px 10px 6px;
  padding-top: max(8px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.rd-title { flex: 1; min-width: 0; }
.rd-cat { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--brand); background: var(--gold-soft); border-radius: 999px; padding: 2px 9px; margin-bottom: 3px; }
.rd-title b { display: block; font-size: 16px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rd-body { padding: 8px 20px max(32px, env(safe-area-inset-bottom)); font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; font-size: 17px; line-height: 1.7; color: var(--ink); }
.rd-h { font-family: "Inter", system-ui, sans-serif; font-size: 18px; line-height: 1.35; margin: 26px 0 8px; letter-spacing: -.2px; }
.rd-pass { padding: 2px 0; scroll-margin-top: 90px; }
.rd-pass.hit { margin: 6px -12px; padding: 10px 12px 12px; border-radius: 14px; background: var(--gold-soft); border-left: 4px solid var(--brand); }
.rd-pass p { margin: 0 0 14px; }
.rd-pass i { font-style: italic; }
.rd-pass b { font-weight: 700; }
.ps-h { font-family: "Inter", system-ui, sans-serif; font-size: 15.5px; font-weight: 700; color: var(--ink); margin: 20px 0 8px; line-height: 1.4; }
.ps-list { margin: 0 0 14px; display: grid; gap: 6px; }
.ps-li { display: grid; grid-template-columns: 36px 1fr; gap: 4px; }
.ps-li.sub { padding-left: 28px; }
.ps-mk { font-family: "Inter", system-ui, sans-serif; font-weight: 700; color: var(--brand); font-size: 14.5px; padding-top: 2px; }
.rd-ask { font-family: "Inter", system-ui, sans-serif; margin-top: 4px; background: var(--panel); }
.rd-more { display: block; width: 100%; margin: 14px 0; padding: 12px; border-radius: 12px; border: 1.5px dashed var(--line); background: none; color: var(--muted);
  font-family: "Inter", system-ui, sans-serif; font-weight: 600; font-size: 14px; }
.rd-foot { font-family: "Inter", system-ui, sans-serif; text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }
.ps-mini { font-size: 14.5px; line-height: 1.6; }
.ps-mini p { margin: 0 0 10px; }
.ps-mini .ps-h { font-size: 14px; margin: 12px 0 6px; }
.ps-mini .ps-li { grid-template-columns: 30px 1fr; }
.set-card a { color: var(--brand); font-weight: 600; text-decoration: none; }

/* Answer language (English / Pidgin): first-run notice and chat welcome */
.ntc-lang-h { margin: 14px 0 6px; }
.notice .ntc-lang { display: flex; width: 100%; margin-bottom: 16px; }
.notice .ntc-lang button { flex: 1; padding: 9px 6px; font-size: 14px; }
.lang-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted, #8a7a6b); }
.lang-pick .seg button { padding: 5px 12px; }

/* ---------- AI answer card: four clear sections ---------- */
.ans .ans-sec { margin: 0 0 14px; }
.ans .ans-sec:last-child { margin-bottom: 0; }
.ans .ans-h { margin: 0 0 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.ans .sec-short { background: var(--gold-soft); border-radius: 12px; padding: 12px 14px; }
.ans .sec-short p { font-size: 16px; line-height: 1.6; margin: 0 0 6px; }
.ans .sec-short p:last-child { margin: 0; }
.ans ol.points { padding-left: 0; list-style: none; counter-reset: pt; margin: 0; }
.ans ol.points > li { position: relative; padding-left: 36px; margin: 12px 0; counter-increment: pt; }
.ans ol.points > li::before { content: counter(pt); position: absolute; left: 0; top: 1px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12.5px; font-weight: 700; display: grid; place-items: center; }
.ans .pt-t { font-weight: 700; color: var(--ink); }
.ans .pt-d { color: var(--muted); }
.ans ul.sub { list-style: none; padding-left: 2px; margin: 6px 0 0; }
.ans ul.sub > li { position: relative; padding-left: 16px; margin: 6px 0; font-size: 15px; }
.ans ul.sub > li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.ans ul.bullets { padding-left: 20px; }
.ans ul.auths { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.ans ul.auths > li { padding: 6px 0 6px 12px; margin: 0; font-size: 14.5px; }
.ans ul.auths > li + li { border-top: 1px dashed var(--line); }
.ans ul.auths i, .ans ul.auths .pt-t { font-style: italic; font-weight: 600; }
.ans .sec-tip { border-left: 4px solid var(--brand); background: var(--sec); border-radius: 0 12px 12px 0; padding: 10px 14px; }
.ans .sec-tip .ans-h::before { content: "🎯 "; }
.ans .sec-tip p { margin: 0; }
.ans .cite { font-size: 10.5px; font-weight: 700; color: var(--brand); background: var(--gold-soft); border-radius: 6px; padding: 0 4px; margin-left: 2px; vertical-align: super; line-height: 1; }
.ans .cite + .cite { margin-left: 2px; }
.ans code { font-size: 13.5px; background: var(--sec); border-radius: 5px; padding: 1px 5px; }
.ans .ans-table { overflow-x: auto; margin: 8px 0 12px; }
.ans table { border-collapse: collapse; width: 100%; font-size: 14px; }
.ans th, .ans td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.ans th { background: var(--sec); font-weight: 700; }

/* "AI tutor is off" line above the chat box */
.ai-hint { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; padding: 6px 10px 6px 12px; border-radius: 999px; background: var(--sec); color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.ai-hint .dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.ai-hint[data-state="loading"] .dot { background: var(--brand); animation: recpulse 1.2s infinite; }
.ai-hint span:nth-child(2) { flex: 1; }
.ai-hint .linkish { font-size: 12.5px; font-weight: 700; color: var(--brand); white-space: nowrap; }
.ai-hint .hint-x { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }

/* Contact & privacy links (Settings → About, sign-in page) */
.set-card a.set-row { color: var(--ink); font-weight: inherit; text-decoration: none; }
.auth-note a { color: var(--brand); font-weight: 600; text-decoration: none; }
