/* friends - claude-code terminal x twitch, everywhere */
* { box-sizing: border-box; }
:root {
  --bg: #0b0e11; --card: #0f1418; --panel: #121a22; --line: #242b32; --line-soft: #1c2229;
  --text: #dfe3e7; --muted: #71808c; --dim: #47525c;
  --accent: #d97757; --accent-hi: #e08a6e; --purple: #a970ff; --red: #eb4034;
  --s0: #82b4ff; --s1: #d97757; --s2: #58c08a; --s3: #c9a2ff;
  --d-label: #dfe3e7; --d-val: #71808c; --d-axis: #47525c;
  --d-shade: rgba(130, 180, 255, 0.16); --d-boxbg: #14251c; --d-bodybg: #1a222b;
  --hover: #12171d;
}
[data-theme="light"] {
  --bg: #f6f4ef; --card: #ffffff; --panel: #fbfaf7; --line: #ded9cd; --line-soft: #eae6dc;
  --text: #23262b; --muted: #6b7280; --dim: #9aa1ab;
  --accent: #c9603e; --accent-hi: #b5502f; --purple: #7a3fa8; --red: #c22e24;
  --s0: #2456a6; --s1: #c03434; --s2: #2e7d43; --s3: #7a3fa8;
  --d-label: #26292d; --d-val: #6b6f75; --d-axis: #c2bcae;
  --d-shade: rgba(36, 86, 166, 0.12); --d-boxbg: #eaf2e8; --d-bodybg: #ffffff;
  --hover: #efece4;
}
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.55;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1.2rem; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--accent); text-decoration: none; }
.brand::before { content: '❯ '; }
nav { display: flex; gap: 1rem; align-items: center; }
nav a { color: var(--muted); }
.who { color: var(--dim); }
main { max-width: 1000px; margin: 1.4rem auto; padding: 0 1rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.1rem 1.3rem; margin-bottom: 1rem; }
.narrow { max-width: 430px; margin: 3rem auto; }
h1 { font-size: 1.15rem; margin-top: 0; }
h2 { font-size: 0.78rem; color: var(--accent); margin: 1.2rem 0 0.5rem;
  text-transform: uppercase; letter-spacing: 0.12em; }
h2::before { content: '## '; color: var(--dim); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.85rem; }
.err { color: #ff8484; min-height: 1em; }
.err-inline { color: #ff8484; }
input, textarea, button, select {
  font: inherit; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); padding: 0.45rem 0.65rem;
}
input:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
form { display: flex; flex-direction: column; gap: 0.55rem; margin: 0.8rem 0; }
button { background: var(--accent); border-color: var(--accent); color: #14100d;
  font-weight: 700; cursor: pointer; }
button:hover { background: var(--accent-hi); }
button:disabled { opacity: 0.55; cursor: default; }
button.danger { background: #431717; border-color: #7a2b2b; color: #ffb0b0; }
button.danger:hover { background: #5a1e1e; }

/* badges */
.badge { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; border-radius: 4px;
  padding: 0.05rem 0.4rem; display: inline-flex; align-items: center; gap: 0.3rem; }
.live-badge { color: #fff; background: var(--red); }
.live-badge .dot { width: 0.5em; height: 0.5em; border-radius: 50%; background: #fff;
  animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.lobby-badge { color: #fff; background: var(--purple); }

/* home */
.space { display: flex; align-items: baseline; gap: 0.55rem; padding: 0.5rem 0.65rem;
  border: 1px solid var(--line); border-radius: 7px; margin: 0.35rem 0; color: var(--text); }
.space:hover { border-color: var(--accent); text-decoration: none; }
.space .muted { margin-left: auto; }
.feed-item { padding: 0.42rem 0; border-bottom: 1px solid var(--line-soft); font-size: 0.85rem; }
.feed-item .muted { margin-right: 0.5rem; }

/* sources */
.source { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start;
  padding: 0.7rem 0; border-bottom: 1px solid var(--line-soft); }
.src-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }

/* term frame (chat + lobby + post) */
.term-head { display: flex; align-items: baseline; gap: 0.7rem; padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line-soft); }
.term-title { font-weight: 700; color: var(--text); font-size: 1.05rem; }
h1.term-title { margin: 0; }
.viewers { margin-left: auto; color: var(--accent); font-size: 0.85rem; }
.term-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 0.7rem; }

/* chat */
.chat { height: 56vh; overflow-y: auto; padding: 0.5rem 0.2rem; margin: 0 0 0.6rem;
  font-size: 0.88rem; display: flex; flex-direction: column; }
.chat .msg:first-child { margin-top: auto; }  /* messages hug the bottom, twitch-style */
.msg { padding: 0.1rem 0.2rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg > span:last-child { white-space: pre-wrap; }  /* keeps the tutor's ASCII sketches aligned */
.msg:hover { background: var(--hover); }
.msg .t { color: var(--dim); font-size: 0.74rem; margin-right: 0.5rem; }
.msg b { font-weight: 700; margin-right: 0.45rem; }
.msg b::after { content: ':'; color: #55606a; }
.msg.agent, .msg.agent b { color: var(--accent); }
.msg.agent b::after { content: ''; }
#send { flex-direction: row; align-items: center; gap: 0.5rem; margin: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 0.25rem 0.6rem; }
#send .prompt { color: var(--accent); font-weight: 700; }
#send input { flex: 1; border: none; background: transparent; outline: none; padding: 0.35rem 0; }
#send input:focus { outline: none; }
#send button { padding: 0.25rem 0.8rem; }

/* agent intro line */
.intro { color: var(--accent); border: 1px dashed #4a3327; border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.88rem; }

/* lobby posts + threads */
.post-row { display: flex; gap: 0.6rem; align-items: center; padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft); }
.post-main { display: flex; gap: 0.55rem; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.post-head { display: flex; gap: 0.6rem; align-items: baseline; }
.vote { padding: 0.1rem 0.5rem; background: var(--bg); border-color: var(--line);
  color: var(--muted); font-size: 0.82rem; font-weight: 400; }
.vote:hover { background: #161c22; color: var(--accent); }
.vote.on { color: var(--accent); border-color: var(--accent); background: #1d1410; }
.postbody { white-space: pre-wrap; }
.comment { padding: 0.4rem 0; overflow-wrap: anywhere; }
.indent { margin-left: 1.4rem; border-left: 1px solid var(--line); padding-left: 0.8rem; }
.reply { font-size: 0.8rem; margin-left: 0.5rem; color: var(--muted); }
.replybox { margin: 0.4rem 0; display: flex; gap: 0.5rem; }
.replybox textarea { flex: 1; }

/* link previews + video */
.pv-chip { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.02rem 0.5rem; white-space: nowrap; }
.pv-chip:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.pv-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); flex: none; }
.preview { display: flex; gap: 0.8rem; border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin: 0.6rem 0; color: var(--text); max-width: 560px; }
.preview:hover { border-color: var(--accent); text-decoration: none; }
.preview img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; flex: none; }
.pv-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.pv-site { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.pv-desc { color: var(--muted); font-size: 0.83rem; }
.embed { width: 100%; max-width: 560px; aspect-ratio: 16 / 9; border: 1px solid var(--line);
  border-radius: 8px; background: #000; display: block; margin: 0.6rem 0; }
iframe.embed { border: 1px solid var(--line); }
.msg-embed { margin: 0.25rem 0 0.35rem 1.2rem; }
.msg-embed .preview, .msg-embed .embed { max-width: 380px; }
.msg-embed .preview img { width: 56px; height: 56px; }

/* homework-together lane */
.tutor-badge { color: #14100d; background: #58c08a; }
.meter { margin: 0.3rem 0 0; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1rem 0; }
@media (max-width: 700px) { .plans { grid-template-columns: 1fr; } }
.plans .plan { border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; }
.plans .plan.current { border-color: var(--accent); }
.plans .plan .price { font-size: 1.6rem; font-weight: 700; margin: 0.2rem 0; }
.plans .plan ul { padding-left: 1.2rem; margin: 0.6rem 0; }
.plans .plan li { margin: 0.25rem 0; }
label.muted { margin-bottom: -0.35rem; }

/* explainer: modern stepper - diagram-first, theme-aware */
.board {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem 1.15rem 0.9rem; margin: 0.5rem 0 0.6rem;
  max-width: 680px; white-space: normal;
}
.board-title { font-weight: 700; font-size: 1.02rem; margin-bottom: 0.8rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--line-soft); }
.board-main { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; }
.board-work { flex: 1 1 15rem; min-width: 0; }
.board-side { flex: 1 1 16rem; min-width: 14rem; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; gap: 0.7rem; position: relative; padding-bottom: 1rem; }
.step:last-child { padding-bottom: 0.2rem; }
.step::before { content: ''; position: absolute; left: 12px; top: 28px; bottom: 2px;
  width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step-dot { flex: none; width: 25px; height: 25px; border-radius: 50%; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: #fff; background: var(--dim); }
.step.understand .step-dot { background: var(--s0); }
.step.plan .step-dot { background: var(--s3); }
.step.solve .step-dot { background: var(--s1); }
.step.lookback .step-dot { background: var(--s2); }
.step-body { min-width: 0; flex: 1; padding-top: 0.15rem; }
.step-phase { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; margin-right: 0.45rem; }
.step.understand .step-phase { color: var(--s0); }
.step.plan .step-phase { color: var(--s3); }
.step.solve .step-phase { color: var(--s1); }
.step.lookback .step-phase { color: var(--s2); }
.step.lesson .step-phase { color: var(--accent); }
.step-head { font-weight: 700; font-size: 0.95rem; }
.step-text { color: var(--muted); font-size: 0.88rem; margin-top: 0.1rem; }
.step-diagram { margin-top: 0.5rem; }
.board-practice { display: flex; gap: 0.6rem; align-items: baseline; margin-top: 0.9rem;
  border-top: 1px solid var(--line-soft); padding-top: 0.7rem; font-size: 0.9rem; }
.board-practice .bp-tag { flex: none; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px; padding: 0.05rem 0.55rem; }
.board .mathchip { background: transparent; border: none; border-bottom: 2px solid var(--s0);
  border-radius: 0; color: var(--s0); padding: 0 0.1rem; font: inherit; font-weight: 600; }
.board .mathchip:hover { background: var(--d-shade); }

.dwrap { margin: 0.4rem 0 0.2rem; }
.dtitle { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.diagram { width: 100%; max-width: 460px; height: auto; display: block;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 10px; }
.diagram .daxis { stroke: var(--d-axis); stroke-width: 1.5; }
.diagram .dbar { fill: var(--s1); }
.diagram .dpoint { fill: var(--s2); }
.diagram .dline { stroke: var(--s0); stroke-width: 2; fill: none; }
.diagram .dlabel { fill: var(--d-label); font-size: 12px; font-family: inherit; }
.diagram .dval { fill: var(--d-val); font-size: 11px; }
.diagram .dshade { fill: var(--d-shade); stroke: none; }
.diagram .dbody { fill: var(--d-bodybg); stroke: var(--d-axis); stroke-width: 1.5; }
.diagram .dbox { fill: var(--d-boxbg); stroke: var(--s2); stroke-width: 1.3; }
.diagram .darrow { stroke: var(--s2); stroke-width: 2; }
.diagram .dhead { fill: var(--s2); }

/* TI-84-style calculator */
.calcbtn { padding: 0.05rem 0.5rem; background: var(--bg); border-color: var(--line);
  color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.calcbtn:hover { color: var(--accent); background: var(--bg); border-color: var(--accent); }
.calc { border: 1px solid #30363d; border-radius: 12px; background: #22262c;
  padding: 0.6rem; margin: 0 0 0.6rem; max-width: 400px; }
.lcd { background: #9db89a; color: #17210f; border: 2px solid #10150c; border-radius: 6px;
  padding: 0.4rem 0.55rem; font-size: 0.9rem; }
.lcd-line { display: flex; align-items: baseline; }
#calc-mode { font-weight: 700; }
#calc-expr { flex: 1; background: transparent; border: none; outline: none;
  color: #17210f; font: inherit; padding: 0; caret-color: #17210f; }
#calc-hist { max-height: 5.6rem; overflow-y: auto; }
.lcd-in { opacity: 0.85; }
.lcd-out { text-align: right; font-weight: 700; }
.lcd-err { color: #6e1f12; font-weight: 700; }
#calc-graph .diagram { margin-top: 0.4rem; }
.calc .keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.3rem; margin-top: 0.5rem; }
.calc .keys button { padding: 0.32rem 0.1rem; font-size: 0.78rem; background: #2b3037;
  border: 1px solid #3a4148; border-bottom-width: 2.5px; color: var(--text); font-weight: 600; }
.calc .keys button:hover { background: #343a42; }
.calc .keys button[data-k="ENTER"], .calc .keys button[data-k="share"] {
  background: var(--accent); border-color: var(--accent-hi); color: #14100d; }
.calc .keys button[data-k="Y="], .calc .keys button[data-k="GRAPH"] {
  background: #1f3d5c; border-color: #2b567a; color: #bcd6ee; }
.subjects { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: baseline; margin: 0.2rem 0 0.6rem; }
.subjects span:not(.muted) { border: 1px solid var(--line); border-radius: 999px;
  padding: 0.05rem 0.6rem; font-size: 0.78rem; color: var(--accent); }
.dtable { border-collapse: collapse; margin: 0.3rem 0; font-size: 0.85rem; }
.dtable th, .dtable td { border: 1px solid var(--line); padding: 0.25rem 0.6rem; text-align: left; }
.dtable th { color: var(--accent); }

/* threads toggle + rooms + library */
details.threads { border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 0.4rem 0.7rem; margin: 0.7rem 0 0.2rem; }
details.threads summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
details.threads[open] summary { color: var(--accent); }
.roomform { flex-direction: row; margin: 0.45rem 0; }
.roomform input { flex: 1; }
.lib-topic { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin: 0.8rem 0 0.25rem; }
.lesson-link { display: block; padding: 0.3rem 0.55rem; border: 1px solid var(--line);
  border-radius: 7px; margin: 0.25rem 0; color: var(--text); }
.lesson-link:hover { border-color: var(--accent); text-decoration: none; }
.lesson-page { max-width: none; margin-top: 0.8rem; }
#lfilter { width: 100%; margin: 0.4rem 0 0.6rem; }

/* math chips: typed notation that applies onto the calculator */
.mathchip { display: inline; padding: 0 0.3rem; background: #1d1410; border: 1px solid #4a3327;
  border-radius: 5px; color: var(--accent); font: inherit; cursor: pointer; font-weight: 400; }
.mathchip:hover { border-color: var(--accent); background: #241812; }
.mathchip .mc-i { font-size: 0.72em; opacity: 0.65; margin-left: 0.2rem; }
.board .mathchip { background: transparent; border: none; border-bottom: 2px solid var(--s0);
  border-radius: 0; color: var(--s0); padding: 0 0.1rem; font: inherit; font-weight: 600; }
.board .mathchip:hover { background: rgba(36, 86, 166, 0.08); }

/* public wiki */
.wiki-hero h1 { font-size: 1.6rem; color: var(--accent); }
.wiki-hero p { max-width: 46rem; }
.btn { display: inline-block; background: var(--accent); color: #14100d; font-weight: 700;
  border-radius: 7px; padding: 0.4rem 1rem; margin-right: 0.5rem; }
.btn:hover { background: var(--accent-hi); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); }
.wiki-q { border-left: 3px solid var(--accent); padding-left: 0.7rem; margin: 0.6rem 0; }
.wiki-q a { white-space: nowrap; }
.wiki-cta { border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem; margin-top: 1rem; }
.wiki-cta .btn { margin-left: 0.5rem; }
.wiki-foot { display: block; text-align: center; padding: 1.2rem 1rem 2rem; }
#board-root h2 { margin: 0.8rem 0 0.2rem; }

.agecheck { display: flex; gap: 0.5rem; align-items: center; color: var(--muted); font-size: 0.88rem; }
.agecheck input { width: auto; }

.navside { display: flex; gap: 1rem; align-items: center; }
#theme-toggle { background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: 0.1rem 0.5rem; font-size: 0.85rem; cursor: pointer; font-weight: 400; }
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* leave modal */
.modal { background: #170f10; border: 1px solid #7a2b2b; border-radius: 8px; padding: 1rem;
  margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.6rem; max-width: 480px; }
.hidden { display: none !important; }

/* wiki curriculum + search */
.courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.6rem; }
.course-card { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.7rem 0.85rem;
  border: 1px solid var(--line); border-radius: 9px; color: var(--text); }
.course-card:hover { border-color: var(--accent); text-decoration: none; }
.wsearch input { width: 15rem; max-width: 34vw; font-size: 0.82rem; padding: 0.3rem 0.6rem; }
.bigsearch { flex-direction: row; gap: 0.5rem; }
.bigsearch input { flex: 1; }
.search-hit { padding: 0.6rem 0; border-bottom: 1px solid var(--line-soft); }
.search-hit p { margin: 0.15rem 0 0; }

/* the hidden network */
.ghostbtn { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-weight: 400; }
.ghostbtn:hover { color: var(--accent); border-color: var(--accent); background: transparent; }
.whisper { display: flex; gap: 0.6rem; align-items: center; margin: 0 0 0.5rem; padding: 0.45rem 0.7rem;
  border: 1px dashed var(--accent); border-radius: 8px; color: var(--accent); font-size: 0.88rem; }
.whisper i { color: var(--text); font-style: normal; font-weight: 600; }
.whisper button { padding: 0.15rem 0.6rem; font-size: 0.8rem; }
.trace { font-size: 0.8rem; }
