/* ============================================================
   Crim Law Study — Design System
   A clean, academic legal-study aesthetic.
   ============================================================ */

:root {
  /* Palette */
  --ink:        #1c2434;   /* primary text / deep slate */
  --ink-soft:   #47526a;
  --parchment:  #f7f4ed;   /* page background */
  --paper:      #ffffff;   /* card surfaces */
  --line:       #e4ddcf;   /* hairline borders */
  --navy:       #2b3a67;   /* primary brand */
  --navy-deep:  #1f2c52;
  --indigo:     #4156a6;
  --amber:      #c8861d;   /* accent / highlights */
  --amber-soft: #f3e6c8;
  --green:      #2f8f5b;
  --green-soft: #e1f1e7;
  --red:        #c0392b;
  --red-soft:   #fbe7e3;
  --gold:       #b9912f;

  --shadow-sm: 0 1px 2px rgba(28,36,52,.06), 0 2px 6px rgba(28,36,52,.05);
  --shadow-md: 0 4px 14px rgba(28,36,52,.10);
  --shadow-lg: 0 18px 50px rgba(28,36,52,.18);

  --radius:    14px;
  --radius-sm: 9px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono:  "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fdfbf4 0%, transparent 60%),
    var(--parchment);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px;
  padding: 0 26px; height: 62px;
  background: rgba(247,244,237,.86);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: .2px; }
.brand .seal {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(140deg, var(--navy), var(--indigo));
  display: grid; place-items: center; color: #fff; font-family: var(--serif);
  font-weight: 700; box-shadow: var(--shadow-sm);
}
.brand b { font-family: var(--serif); font-size: 1.12rem; }
.brand span { color: var(--ink-soft); font-weight: 500; font-size: .82rem; }

nav.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: nowrap; overflow-x: auto;
  max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav.tabs::-webkit-scrollbar { height: 0; }
@media print {
  .app-header, nav.tabs, .subject-switch, .chat-fab, .chat-scrim, .chat-drawer,
  .pomo, .pomo-fab, #splash, .btn-row, button { display: none !important; }
  body, .app, main { background: #fff !important; color: #000 !important; }
  .card, .ai-text, .bubble { box-shadow: none !important; }
  a[href^="#"] { color: #000 !important; text-decoration: none; }
}
nav.tabs a {
  text-decoration: none; color: var(--ink-soft); flex: 0 0 auto; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  transition: background .18s, color .18s;
}
nav.tabs a:hover { background: #efe9dc; color: var(--ink); }
nav.tabs a.active { background: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }
.subject-switch { margin-left: auto; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px; background: var(--paper); font-weight: 700; font-size: .85rem; color: var(--navy); cursor: pointer; }
.subject-switch + nav.tabs { margin-left: 12px; }

main { max-width: 1120px; margin: 0 auto; padding: 30px 24px 90px; }

/* ---------- Typography ---------- */
h1 { font-family: var(--serif); font-size: 2.05rem; margin: 0 0 6px; letter-spacing: -.2px; }
h2 { font-family: var(--serif); font-size: 1.42rem; margin: 0 0 10px; }
h3 { font-size: 1.06rem; margin: 0 0 8px; }
.lede { color: var(--ink-soft); font-size: 1.04rem; margin: 0 0 26px; max-width: 70ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 700; color: var(--amber); }
a.link { color: var(--indigo); }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px){ .grid.cols-3,.grid.cols-4{ grid-template-columns: repeat(2,1fr);} }
@media (max-width: 620px){ .grid.cols-2,.grid.cols-3,.grid.cols-4{ grid-template-columns: 1fr;} }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 28px 30px; }
.card.hover { transition: transform .16s, box-shadow .16s; cursor: pointer; }
.card.hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm); transition: transform .16s, box-shadow .16s, border-color .16s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #d8cdb6; }
.tile .ico { font-size: 1.7rem; }
.tile h3 { margin: 12px 0 4px; }
.tile p { margin: 0; color: var(--ink-soft); font-size: .92rem; }

/* ---------- Stat numbers ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-family: var(--serif); font-size: 2.1rem; line-height: 1; }
.stat .lbl { color: var(--ink-soft); font-size: .82rem; }
.stat .num.good { color: var(--green); } .stat .num.bad { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  transition: transform .12s, box-shadow .14s, background .14s, border-color .14s;
  font-family: inherit;
}
.btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-deep); }
.btn.amber { background: var(--amber); color: #fff; border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 13px; font-size: .84rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Chips / pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: #efe9dc; color: var(--ink-soft); border: 1px solid var(--line);
}
.chip.unit { background: #e8ecf7; color: var(--navy); border-color: #d3dcf0; }
.chip.easy { background: var(--green-soft); color: var(--green); border-color: #c4e6d1; }
.chip.medium { background: var(--amber-soft); color: var(--gold); border-color: #ebd9b0; }
.chip.hard { background: var(--red-soft); color: var(--red); border-color: #f1cdc6; }
.chip.sel { background: var(--navy); color:#fff; border-color: var(--navy); cursor:pointer; }
.chip.selectable { cursor: pointer; }

/* ---------- Quiz ---------- */
.quiz-wrap { max-width: 760px; margin: 0 auto; }
.progress { height: 8px; background: #e9e2d4; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--indigo), var(--navy)); transition: width .3s; }
.q-meta { display: flex; align-items: center; gap: 8px; margin: 18px 0 10px; flex-wrap: wrap; }
.q-stem { font-size: 1.16rem; font-family: var(--serif); line-height: 1.5; margin: 6px 0 20px; }
.options { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex; gap: 13px; align-items: flex-start; text-align: left;
  padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); cursor: pointer; font-size: .98rem; font-family: inherit; color: var(--ink);
  transition: border-color .14s, background .14s, box-shadow .14s; width: 100%;
}
.opt:hover:not(:disabled) { border-color: #c3b894; box-shadow: var(--shadow-sm); }
.opt .key {
  flex: 0 0 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  background: #eee7d8; color: var(--ink-soft); font-weight: 700; font-size: .9rem;
}
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.correct .key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .key { background: var(--red); color: #fff; }
.opt.dim { opacity: .72; }
.opt:disabled { cursor: default; }

.explains { margin-top: 18px; display: flex; flex-direction: column; gap: 9px; }
.exp {
  display: flex; gap: 11px; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: .9rem; border: 1px solid var(--line); background: #faf8f2;
}
.exp .ek { flex: 0 0 22px; height: 22px; border-radius: 6px; display:grid; place-items:center; font-weight:700; font-size:.78rem; color:#fff; }
.exp.r { background: var(--green-soft); border-color: #c4e6d1; } .exp.r .ek { background: var(--green); }
.exp.w { background: #faf6f5; border-color: #eccfca; } .exp.w .ek { background: var(--red); }
.exp .src { color: var(--ink-soft); font-style: italic; }

.result-hero { text-align: center; padding: 24px 0 8px; }
.result-ring { width: 168px; height: 168px; margin: 0 auto 14px; }

/* ---------- Learn ---------- */
.learn-toc { position: sticky; top: 78px; }
.toc-item { display:flex; gap:10px; align-items:center; padding:9px 12px; border-radius:9px; text-decoration:none; color:var(--ink-soft); font-size:.9rem; }
.toc-item:hover { background:#efe9dc; color:var(--ink); }
.toc-item.active { background:#e8ecf7; color:var(--navy); font-weight:600; }
.toc-item .dot { width:9px;height:9px;border-radius:50%;background:#cfc6b1;flex:0 0 auto; }
.toc-item.done .dot { background: var(--green); }

.lesson { max-width: 780px; }
.lesson .concept { margin: 0 0 34px; }
.lesson .concept p { font-size: 1.02rem; }
.lesson .keyrule {
  border-left: 4px solid var(--amber); background: #fdfaf1; padding: 12px 16px;
  border-radius: 0 10px 10px 0; margin: 16px 0; font-size: .98rem;
}
.lesson .keyrule b { color: var(--gold); }
.scene {
  background: linear-gradient(180deg, #fbfaf6, #f4f0e6);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 18px 0; box-shadow: var(--shadow-sm); overflow: hidden;
}
.scene-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.scene-head .t { font-weight: 700; font-size: .92rem; color: var(--navy); }
.scene-stage { position: relative; min-height: 220px; }

.check {
  border: 1px dashed #d6c8a4; background: #fdfbf3; border-radius: var(--radius);
  padding: 16px 18px; margin: 18px 0;
}
.check .tag { font-size:.72rem; font-weight:700; letter-spacing:.1em; text-transform:uppercase; color:var(--amber); }

/* ---------- Charts ---------- */
.chart-card { padding: 18px 20px; }
svg.chart { width: 100%; display: block; overflow: visible; }
.bar { transition: width .6s cubic-bezier(.2,.8,.2,1); }
.legend { display:flex; gap:14px; flex-wrap:wrap; font-size:.82rem; color:var(--ink-soft); }
.legend i { display:inline-block; width:11px;height:11px;border-radius:3px;margin-right:5px;vertical-align:middle; }

.weakrow { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--line); }
.weakrow:last-child{border-bottom:none;}
.weakrow .meter { flex:1; height:9px;background:#ece5d6;border-radius:999px;overflow:hidden; }
.weakrow .meter > i { display:block;height:100%; }
.weakrow .pct { font-variant-numeric: tabular-nums; font-weight:700; width:46px; text-align:right; }

/* ---------- Misc ---------- */
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.row { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.spread { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.divider { height:1px; background:var(--line); margin:22px 0; border:0; }
.empty { text-align:center; color:var(--ink-soft); padding:50px 20px; }
.empty .big { font-size: 2.4rem; margin-bottom: 8px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color:#fff; padding:11px 20px; border-radius:999px; font-size:.9rem;
  opacity:0; transition: all .3s; z-index: 200; box-shadow: var(--shadow-lg);
}
.toast.show { opacity:1; transform: translateX(-50%) translateY(0); }
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from{opacity:0; transform: translateY(8px);} to{opacity:1; transform:none;} }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.45;} }

select, input[type=search], input[type=text], input[type=number], input[type=password], textarea {
  font-family: inherit; font-size:.9rem; padding:8px 12px; border-radius:9px;
  border:1px solid var(--line); background:var(--paper); color:var(--ink);
}
textarea { width:100%; min-height:120px; resize:vertical; line-height:1.5; font-size:1rem; padding:12px 14px; }
label.fld { display:flex; flex-direction:column; gap:5px; font-size:.8rem; color:var(--ink-soft); font-weight:600; }

/* ---------- Pomodoro widget ---------- */
#pomo-host { position: fixed; right: 18px; bottom: 18px; z-index: 120; }
.pomo {
  width: 210px; background: var(--paper); border: 2px solid var(--navy);
  border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow-lg);
}
.pomo-top { display:flex; justify-content:space-between; align-items:center; }
.pomo-phase { font-weight:800; font-size:.86rem; }
.pomo-x { background:none;border:none;cursor:pointer;font-size:1.1rem;color:var(--ink-soft);line-height:1; }
.pomo-time { font-family: var(--serif); font-size: 2.6rem; text-align:center; font-variant-numeric: tabular-nums; line-height:1.1; margin:2px 0 6px; }
.pomo-dots { display:flex; gap:6px; justify-content:center; margin-bottom:10px; }
.pomo-dot { width:9px;height:9px;border-radius:50%;background:#ddd5c2; }
.pomo-dot.on { background: var(--navy); }
.pomo-btns { display:flex; gap:6px; justify-content:center; }
.pomo-foot { text-align:center; font-size:.72rem; color:var(--ink-soft); margin-top:9px; }
.pomo-fab { width:52px;height:52px;border-radius:50%;border:2px solid var(--navy);background:var(--paper);
  font-size:1.5rem;cursor:pointer;box-shadow:var(--shadow-md); }
@media (max-width:620px){ #pomo-host{ right:10px; bottom:10px; } .pomo{ width:180px; } }

/* ---------- Flashcards ---------- */
.flash-wrap { max-width: 640px; margin: 0 auto; }
.flash {
  perspective: 1600px; height: 320px; margin: 18px 0; cursor: pointer;
}
.flash-inner {
  position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.2,.8,.2,1);
  transform-style: preserve-3d;
}
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position:absolute; inset:0; backface-visibility:hidden; -webkit-backface-visibility:hidden;
  display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  padding:30px; border-radius:18px; border:1px solid var(--line); background:var(--paper);
  box-shadow: var(--shadow-md);
}
.flash-face .role { position:absolute; top:14px; left:18px; font-size:.7rem; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--amber); }
.flash-face .content { font-size:1.25rem; font-family:var(--serif); line-height:1.45; }
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(160deg,#fbfaf6,#f3eee2); }
.flash-face .mnem { margin-top:14px; font-size:.85rem; color:var(--indigo); font-family:var(--sans); }
.flash-hint { text-align:center; color:var(--ink-soft); font-size:.82rem; }
.grade-btns { display:grid; grid-template-columns:repeat(4,1fr); gap:9px; margin-top:16px; }
.grade-btns .btn { justify-content:center; flex-direction:column; gap:1px; padding:11px 6px; }
.grade-btns .btn small { font-weight:500; opacity:.75; font-size:.72rem; }
.g-again{ border-color:#f1cdc6; color:var(--red);} .g-hard{ border-color:#ebd9b0; color:var(--gold);}
.g-good{ border-color:#c4e6d1; color:var(--green);} .g-easy{ border-color:#cfe; color:var(--indigo);}

/* ---------- Recall (free text) ---------- */
.recall-wrap { max-width: 720px; margin: 0 auto; }
.recall-prompt { font-size:1.18rem; font-family:var(--serif); line-height:1.5; margin:10px 0 14px; }
.grade-card { border-radius:14px; padding:16px 18px; margin-top:16px; border:1px solid var(--line); }
.grade-card.correct{ background:var(--green-soft); border-color:#c4e6d1;}
.grade-card.partial{ background:var(--amber-soft); border-color:#ebd9b0;}
.grade-card.incorrect{ background:var(--red-soft); border-color:#f1cdc6;}
.grade-score { font-family:var(--serif); font-size:2rem; }
.kp { display:flex; gap:8px; align-items:flex-start; font-size:.88rem; margin:4px 0; }
.kp .ic{ flex:0 0 auto; }
.model-ans { background:#faf8f2; border:1px solid var(--line); border-radius:11px; padding:12px 15px; margin-top:12px; font-size:.94rem; }
.ai-badge { display:inline-flex;align-items:center;gap:5px;font-size:.72rem;font-weight:700;color:var(--indigo);
  background:#eef1fb;border:1px solid #d3dcf0;border-radius:999px;padding:3px 9px; }
.ai-out { white-space:pre-wrap; background:#f7f9ff; border:1px solid #dde4f5; border-radius:11px; padding:13px 15px; margin-top:10px; font-size:.92rem; line-height:1.55; }

/* ---------- Focus session ---------- */
.focus-hero { text-align:center; padding:10px 0 4px; }
.focus-time { font-family:var(--serif); font-size:4.4rem; line-height:1; font-variant-numeric:tabular-nums; }
.break-card { text-align:center; padding:40px 20px; }
.break-card .big { font-size:3rem; }

/* settings rows */
.set-row { display:flex; justify-content:space-between; align-items:center; gap:14px; padding:12px 0; border-bottom:1px solid var(--line); }
.set-row:last-child{border-bottom:none;}
.seg { display:inline-flex; border:1px solid var(--line); border-radius:999px; overflow:hidden; }
.seg button { border:none; background:var(--paper); padding:7px 14px; cursor:pointer; font-family:inherit; font-size:.85rem; color:var(--ink-soft); }
.seg button.on { background:var(--navy); color:#fff; }

/* ---------- Splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, #3a4a7e, #1c2747);
  transition: opacity .5s ease; opacity: 1;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { animation: splashpop .7s cubic-bezier(.2,.8,.2,1) both; }
.splash-title { color: #f7f4ed; font-family: var(--serif); font-size: 1.7rem; margin-top: 10px; animation: fadeIn .6s .25s both; }
.splash-sub { color: #aab4d4; font-size: .9rem; animation: fadeIn .6s .4s both; }
@keyframes splashpop { from { opacity:0; transform: scale(.7) translateY(8px); } to { opacity:1; transform: none; } }

/* ---------- AI chat ---------- */
.chat { display: flex; flex-direction: column; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 440px; overflow-y: auto; padding: 4px; }
.chat-log:empty::after { content: "Ask a question to start."; color: var(--ink-soft); font-size: .9rem; padding: 16px; text-align:center; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg-b { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: .92rem; line-height: 1.5; white-space: pre-wrap; }
.msg.user .msg-b { background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .msg-b { background: #f3f5fb; color: var(--ink); border: 1px solid #e1e6f3; border-bottom-left-radius: 4px; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 2px; }
.refs-label { font-size: .76rem; color: var(--ink-soft); }
.ref-chip { text-decoration: none; font-size: .76rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: #eef1fb; color: var(--indigo); border: 1px solid #d3dcf0; }
.ref-chip:hover { background: #e2e8f8; }
.ref-chip .ref-u { color: var(--ink-soft); font-weight: 500; }
.chat-bar { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.chat-input { flex: 1; min-height: 44px; max-height: 140px; }
.chat-sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- Leaderboard ---------- */
.lb-head, .lb-row { display: flex; align-items: center; gap: 8px; padding: 10px 6px; }
.lb-head { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.lb-row { border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: none; }
.lb-row.me { background: #eef2fb; border-radius: 8px; }
.lb-c { width: 72px; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }

/* ---------- Concept maps ---------- */
.approaches { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.approach-row { display: flex; gap: 8px; font-size: .86rem; align-items: baseline; }
.approach-tag { flex: 0 0 92px; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--navy); background: #e8ecf7; border: 1px solid #d3dcf0; border-radius: 6px; padding: 2px 6px; text-align: center; }
.concept-quote { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: .9rem;
  border-left: 3px solid var(--amber); padding: 4px 0 4px 10px; margin: 4px 0; }
.chip.sel { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---- global AI chat widget ---- */
.hidden { display: none !important; }
.input { width: 100%; padding: 9px 11px; border: 1.5px solid var(--line, #d8d2c4); border-radius: 9px;
  background: var(--paper); color: var(--ink, #222); font: inherit; }
.btn.ghost.danger, .btn.danger { color: var(--red, #c0392b); border-color: #f1cdc6; }
.chip.selectable.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.chat-fab { position: fixed; left: 18px; bottom: 18px; z-index: 120;
  width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--navy);
  background: var(--navy); color: #fff; font-size: 1.4rem; cursor: pointer;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.18)); transition: transform .15s; }
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }

.chat-scrim { position: fixed; inset: 0; z-index: 1150; background: rgba(15,20,35,.38); }
.chat-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1200;
  width: min(440px, 94vw); background: var(--paper); border-left: 2px solid var(--navy);
  box-shadow: -10px 0 30px rgba(0,0,0,.22); display: flex; flex-direction: column;
  padding: 14px; gap: 8px; animation: drawerIn .22s ease; }
.chat-drawer .chat { flex: 1; min-height: 0; }
.chat-drawer .chat-log { max-height: none; flex: 1; }
.chat-drawer-head { display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1px solid var(--line, #e4ddcd); padding-bottom: 8px; }
@keyframes drawerIn { from { transform: translateX(20px); opacity: .4; } to { transform: none; opacity: 1; } }
