@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');
:root {
  /* S-Block brand: logo blue #2363ec, site blue hsl(217 91% 60%), Playfair Display headings, Source Sans 3 text */
  --bg: #ffffff; --side: #f5f7fb; --panel: #ffffff; --card: #ffffff; --line: #e3e7ee; --line2: #edf0f5;
  --text: #262b33; --muted: #6b7280; --dim: #9aa1ad; --accent: #2363ec; --accent-ink: #ffffff; --accent-soft: #eaf1ff; --link: #2363ec;
  --warn: #b45309; --err: #dc2626; --chip: #eef2f8; --code: #f3f5f9; --shadow: 0 6px 24px rgba(20, 40, 90, .08);
  --c1: #2363ec; --c2: #b7791f; --c3: #15803d; --c4: #7c3aed;
  --radius: 16px; --font: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Sans 3", ui-sans-serif, system-ui, sans-serif;
  --display: "Playfair Display", Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1322; --side: #0a0f1b; --panel: #111a2c; --card: #152034; --line: #263450; --line2: #1c2740;
    --text: #e9edf5; --muted: #9ba6bb; --dim: #6c7891; --accent: #2f6ff0; --accent-ink: #ffffff; --accent-soft: #172a52; --link: #8db2ff;
    --chip: #1d2a44; --code: #1a2540; --shadow: 0 8px 30px rgba(0,0,0,.45);
    --c1: #8db2ff; --c2: #e8b75c; --c3: #6fd38e; --c4: #b996ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .dim { color: var(--dim); }
.error { color: var(--err); min-height: 1.4em; margin: 6px 0 0; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--dim); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--err); }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--chip); color: var(--text); }

/* login */
.login-page { display: grid; place-items: center; min-height: 100%; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 14px; text-align: left; margin: 18px 0; box-shadow: var(--shadow); }
.login-card label, .form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, textarea, select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 500; color: var(--text); text-decoration: none; font-size: 16px; }
.brand b { font-weight: 700; }
.brand.big { font-size: 26px; gap: 12px; }

/* layout */
.app { display: grid; grid-template-columns: 264px 1fr auto; height: 100%; }
.sidebar { background: var(--side); border-right: 1px solid var(--line2); display: flex; flex-direction: column; padding: 14px 10px 10px; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 12px; }
.new-chat { justify-content: flex-start; margin: 0 2px 8px; background: transparent; border-color: transparent; font-weight: 600; }
.new-chat span { color: var(--link); font-size: 18px; line-height: 1; }
.new-chat:hover { background: var(--chip); }
.side-nav { display: grid; gap: 2px; margin-bottom: 10px; }
.side-nav a, .chat-list a { display: block; padding: 7px 12px; border-radius: 9px; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav a:hover, .chat-list a:hover { background: var(--chip); }
.side-nav a.on, .chat-list a.on { background: var(--chip); font-weight: 600; }
.side-label { font-size: 12px; color: var(--dim); padding: 6px 12px; font-weight: 600; letter-spacing: .3px; }
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.chat-list a { font-size: 14px; }
.side-bottom { border-top: 1px solid var(--line2); padding-top: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.me:hover { background: var(--chip); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.me small { display: block; color: var(--muted); font-size: 12px; }
.main { min-width: 0; display: flex; flex-direction: column; height: 100%; overflow: hidden; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid transparent; min-height: 52px; }
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.only-mobile { display: none; }
.scrim { display: none; }

/* chat */
.chat-scroll { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }
.thread { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; }
.msg-user { justify-self: end; max-width: 85%; background: var(--card); border: 1px solid var(--line2); border-radius: 18px 18px 6px 18px; padding: 11px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-user.collapsed { max-height: 9.5em; overflow: hidden; position: relative; }
.msg-user .more { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); cursor: pointer; background: none; border: 0; padding: 0; }
.msg-ai { overflow-wrap: anywhere; }
.msg-ai .md { font-family: var(--serif); font-size: 16.5px; line-height: 1.6; }
.msg-ai .tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.activity { display: grid; gap: 4px; margin: 4px 0 8px; }
.activity div { font-size: 13px; color: var(--muted); }
.activity div::before { content: '↳ '; color: var(--dim); }
.note { color: var(--muted); font-family: var(--serif); font-size: 15.5px; }
.msg-error { color: var(--err); }
.typing::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.md p { margin: 0 0 .8em; } .md > :last-child { margin-bottom: 0; }
.md h1 { font-size: 1.5em; line-height: 1.25; margin: .2em 0 .6em; } .md h2 { font-size: 1.22em; margin: 1.3em 0 .5em; } .md h3 { font-size: 1.05em; margin: 1.1em 0 .4em; }
.md ul, .md ol { padding-left: 1.4em; margin: 0 0 .9em; } .md li { margin: .2em 0; }
.md code { background: var(--code); border-radius: 5px; padding: 1px 5px; font-size: .88em; font-family: ui-monospace, Menlo, monospace; }
.md pre { background: var(--code); border-radius: 10px; padding: 12px; overflow-x: auto; } .md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; width: 100%; margin: .6em 0 1.1em; font-family: var(--font); font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.md th { font-weight: 600; color: var(--muted); }
.md blockquote { border-left: 3px solid var(--line); margin: 0 0 .9em; padding-left: 12px; color: var(--muted); }
.md a.cite { display: inline-block; font: 500 11.5px/1.5 var(--font); background: var(--chip); color: var(--muted); text-decoration: none; border-radius: 6px; padding: 0 6px; margin: 0 1px; vertical-align: 1px; max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md a.cite:hover { background: var(--accent-soft); color: var(--link); }

.tip { position: fixed; z-index: 50; max-width: 320px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 12px; padding: 10px 12px; font-size: 13px; pointer-events: none; }
.tip b { display: block; margin-bottom: 3px; color: var(--text); }
.tip span { color: var(--muted); }

/* research card */
.rcard { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.rcard:hover { border-color: var(--dim); }
.rcard .t { font-weight: 600; font-size: 14px; }
.rcard .s { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rcard .grow { flex: 1; min-width: 0; }
.rcard .chev { color: var(--dim); }
.dots { display: inline-flex; gap: 2px; }
.dots i { width: 16px; height: 16px; border-radius: 4px; background: var(--chip); display: grid; place-items: center; font: 700 9px/1 var(--font); color: var(--muted); font-style: normal; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.doc-card { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px 16px; cursor: pointer; margin-top: 10px; }
.doc-card:hover { border-color: var(--accent); }
.doc-card .k { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
.doc-card .h { font-family: var(--display); font-size: 18px; font-weight: 600; margin: 4px 0; }
.doc-card .p { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* composer */
.composer-wrap { padding: 0 16px 14px; }
.composer { max-width: 760px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 12px 12px 8px 16px; position: relative; }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; padding: 4px 0; max-height: 40vh; min-height: 28px; font-size: 15.5px; outline: none; }
.composer .row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.composer .grow { flex: 1; }
.plus { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); }
.plus:hover, .plus[aria-expanded="true"] { background: var(--chip); color: var(--text); }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 10px; padding: 6px 10px; background: var(--accent-soft); color: var(--link); font-size: 13px; font-weight: 600; border: 0; cursor: pointer; }
.send { width: 36px; height: 36px; border-radius: 11px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 18px; cursor: pointer; }
.send:disabled { opacity: .35; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.menu { position: absolute; bottom: 52px; left: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 250px; z-index: 20; }
.menu button { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; cursor: pointer; align-items: flex-start; }
.menu button:hover { background: var(--chip); }
.menu small { display: block; color: var(--muted); font-size: 12.5px; }
.menu .check { margin-left: auto; color: var(--link); font-weight: 700; }
.under { max-width: 760px; margin: 8px auto 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.under .grow { flex: 1; }
.coach { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.coach span { border: 1px dashed var(--line); border-radius: 20px; padding: 2px 9px; color: var(--dim); transition: all .25s; }
.coach span.ok { border-style: solid; color: var(--text); }
.coach span.ok.k1 { border-color: var(--c1); } .coach span.ok.k2 { border-color: var(--c2); } .coach span.ok.k3 { border-color: var(--c3); } .coach span.ok.k4 { border-color: var(--c4); }
.coach span.ok::before { content: '✓ '; }

/* empty state */
.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 16px; }
.hero h2 { font-family: var(--display); font-weight: 600; font-size: 34px; text-align: center; margin: 0 0 22px; }
.hero h2 .mark { display: inline-block; width: .9em; height: .9em; vertical-align: -.08em; margin-right: .15em; }
.starters { max-width: 760px; margin: 14px auto 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.starters button { border: 1px solid var(--line); background: transparent; border-radius: 20px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.starters button:hover { color: var(--text); border-color: var(--dim); }

/* guide strip */
.guide { max-width: 760px; margin: 0 auto 10px; background: var(--accent-soft); border-radius: 12px; padding: 9px 12px; display: flex; gap: 10px; align-items: center; font-size: 13.5px; }
.guide b { color: var(--link); }
.guide .grow { flex: 1; }
.guide .bar { width: 70px; height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; flex: none; }
.guide .bar i { display: block; height: 100%; background: var(--accent); }

/* side panel */
.panel { width: min(46vw, 640px); border-left: 1px solid var(--line2); background: var(--panel); display: flex; flex-direction: column; min-height: 0; height: 100%; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line2); min-height: 52px; }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { flex: 1; overflow-y: auto; padding: 18px 22px 40px; }
.panel .md { font-family: var(--serif); font-size: 16px; }
.split { position: relative; }
.dropdown { position: absolute; right: 0; top: 38px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 30; min-width: 210px; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.dropdown button:hover { background: var(--chip); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; font-size: 14px; }
.steps li .b { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); margin-top: 7px; flex: none; }
.steps li.live .b { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.domains { display: grid; gap: 5px; margin: 6px 0 4px 19px; }
.domains div { display: grid; grid-template-columns: 150px 70px 1fr; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.domains div span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.domains em { display: block; height: 4px; border-radius: 3px; background: var(--line); }
.feed { margin-top: 14px; display: grid; gap: 6px; }
.feed div { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.feed div b { color: var(--text); font-weight: 500; }

/* pages (learn, admin, account) */
.page { flex: 1; overflow-y: auto; padding: 8px 16px 60px; }
.page-in { max-width: 860px; margin: 0 auto; }
.page h2 { font-family: var(--display); font-weight: 600; font-size: 32px; margin: 10px 0 6px; }
.page h3 { font-size: 17px; margin: 28px 0 8px; }
.video { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 16/9; border: 1px solid var(--line); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.lcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.lcard h4 { margin: 0 0 6px; font-size: 15px; }
.lcard p { margin: 0; color: var(--muted); font-size: 14px; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vs .lcard.good { border-color: var(--c3); }
.quote { font-family: var(--serif); font-size: 15.5px; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.hl1 { background: color-mix(in srgb, var(--c1) 22%, transparent); } .hl2 { background: color-mix(in srgb, var(--c2) 22%, transparent); }
.hl3 { background: color-mix(in srgb, var(--c3) 22%, transparent); } .hl4 { background: color-mix(in srgb, var(--c4) 22%, transparent); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.checklist li .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 13px; color: transparent; margin-top: 1px; }
.checklist li.done .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.checklist li small { display: block; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table.admin { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.admin th, table.admin td { padding: 8px 10px; border-bottom: 1px solid var(--line2); text-align: left; white-space: nowrap; }
table.admin th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
table.admin input { width: 64px; padding: 4px 6px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat { display: inline-block; margin-right: 18px; }
.stat b { font-size: 20px; display: block; }
.badge { font-size: 11.5px; border-radius: 6px; padding: 1px 6px; background: var(--chip); color: var(--muted); }
.badge.admin { background: var(--accent-soft); color: var(--link); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 100; max-width: 90vw; }
.toast.on { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1100px) {
  .panel { position: fixed; inset: 0 0 0 auto; width: min(100vw, 620px); z-index: 40; box-shadow: var(--shadow); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 45; transform: translateX(-100%); transition: transform .2s; }
  .app.side-open .sidebar { transform: none; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 44; }
  .only-mobile { display: inline-block; }
  .hero h2 { font-size: 27px; }
  .vs { grid-template-columns: 1fr; }
  .panel { width: 100vw; }
  .domains div { grid-template-columns: 1fr 60px 60px; }
}
@media print {
  body * { visibility: hidden; }
}

/* brand touches */
.brand img { border-radius: 7px; }
.md h1, .md h2 { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
.msg-ai .md, .panel .md { font-size: 16.5px; }
.brand span { letter-spacing: -.01em; }
.brand b { color: var(--link); }
.btn.primary:hover { filter: brightness(1.08); }
.login-page { background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
