/* Study Hall: one stylesheet for both sites. System fonts only; nothing is loaded from elsewhere. */
:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1f2430; --muted: #6b7280; --line: #e3dfd6;
  --accent: #2f5d8a; --accent-ink: #ffffff; --kid: #dfeaf5; --warn: #fff4d6; --bad: #fde8e4; --good: #e4f3e6;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
small { font-weight: normal; color: var(--muted); }
button, input, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: .5rem .9rem; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
input, textarea { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; background: #fff; width: 100%; }
:focus-visible { outline: 3px solid #9cc1e6; outline-offset: 1px; }
.muted, .hint { color: var(--muted); font-size: .9rem; }
.error { background: var(--bad); border-radius: 8px; padding: .5rem .75rem; }
.tag { font-size: .75rem; background: var(--warn); border-radius: 999px; padding: .1rem .5rem; white-space: nowrap; }
.notice { margin: 0; padding: .35rem .9rem; background: var(--warn); font-size: .85rem; text-align: center; border-bottom: 1px solid var(--line); }

/* login */
.login { max-width: 22rem; margin: 10vh auto; padding: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.login h1 { font-size: 1.6rem; margin-bottom: 1rem; }
.login .notice { border: 0; border-radius: 8px; margin-bottom: 1rem; text-align: left; }
.login label { display: block; margin-bottom: .8rem; font-size: .9rem; color: var(--muted); }
.login button { width: 100%; margin-top: .3rem; }

/* kid chat */
.app { display: flex; height: 100%; }
.side { width: 16rem; flex: none; display: flex; flex-direction: column; gap: .6rem; padding: .9rem; background: var(--panel); border-right: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.15rem; }
.side .new { width: 100%; }
.convs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.convs a { display: block; padding: .4rem .55rem; border-radius: 8px; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convs a:hover { background: var(--bg); }
.convs a.active { background: var(--kid); font-weight: 600; }
.who { font-size: .9rem; color: var(--muted); display: flex; justify-content: space-between; gap: .5rem; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.head h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: relative; flex: none; }
.menu summary { cursor: pointer; color: var(--accent); list-style: none; }
.menu-body { position: absolute; right: 0; top: 1.8rem; z-index: 5; width: 17rem; padding: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12); display: grid; gap: .8rem; }
.menu-body form { display: grid; gap: .4rem; }
.thread { flex: 1; overflow-y: auto; padding: 1rem; }
.ex { max-width: 50rem; margin: 0 auto 1.2rem; display: flex; flex-direction: column; gap: .45rem; }
.bubble { padding: .65rem .9rem; border-radius: 14px; overflow-wrap: anywhere; }
.bubble.kid { align-self: flex-end; max-width: 85%; background: var(--kid); white-space: pre-wrap; border-bottom-right-radius: 4px; }
.bubble.tutor { align-self: flex-start; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.note { align-self: flex-start; background: var(--warn); font-size: .95rem; }
.bubble.note p { margin: 0 0 .4rem; }
.bubble.note.serious { background: var(--good); font-size: 1rem; }
.bubble.note.denied, .bubble.note.failed { background: var(--bad); }
.bubble.pending { color: var(--muted); font-style: italic; }
.state { margin: 0; font-size: .85rem; color: var(--muted); }
.state.ok { color: #2d6a3a; }
.ctx-form { display: grid; gap: .4rem; margin-top: .4rem; }
.ctx-form button { justify-self: start; }
.empty { max-width: 32rem; margin: 12vh auto 0; text-align: center; color: var(--muted); }
.composer { display: flex; gap: .6rem; align-items: flex-end; padding: .7rem 1rem; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { resize: none; max-height: 9rem; }
.composer .send { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex: none; }
.composer .pic { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.composer .pic input { width: auto; }
.composer.busy button { opacity: .5; pointer-events: none; }
.drawing { max-width: 100%; border-radius: 8px; display: block; }
.sources { margin-top: .6rem; padding-top: .5rem; border-top: 1px dashed var(--line); font-size: .85rem; }
.sources span { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.sources ul { margin: .2rem 0 0; padding-left: 1.1rem; }

/* rendered model text */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md table, .md blockquote { margin: 0 0 .7rem; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1.05rem; margin: .9rem 0 .4rem; }
.md pre { background: #f4f5f7; border: 1px solid var(--line); border-radius: 8px; padding: .7rem; overflow-x: auto; font-size: .88rem; line-height: 1.45; }
.md code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: #f0f1f3; padding: .05rem .3rem; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: .3rem .6rem; text-align: left; }
.md blockquote { border-left: 3px solid var(--line); padding-left: .8rem; color: var(--muted); }
.md math { font-size: 1.12em; }
.md math[display="block"] { margin: .5rem 0; overflow-x: auto; max-width: 100%; }
.md a:not([href]) { color: inherit; text-decoration: none; }

/* parent site */
.p-top { display: flex; align-items: center; gap: 1.2rem; padding: .7rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.p-top nav { flex: 1; display: flex; gap: 1rem; }
.p-top form { font-size: .9rem; color: var(--muted); }
.p-main { max-width: 52rem; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.p-main h1 { margin-bottom: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.card blockquote { margin: .5rem 0; padding: .6rem .8rem; background: var(--kid); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card p { margin: .4rem 0; }
.meta { font-size: .85rem; color: var(--muted); margin: 0; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: .3rem; }
.decide { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.decide input { flex: 1; min-width: 12rem; }
.decide .yes { background: #2d6a3a; }
.decide .no { background: #a23b2a; }
.counts { border-collapse: collapse; width: 100%; font-size: .92rem; }
.counts th, .counts td { text-align: right; padding: .25rem .6rem; border-bottom: 1px solid var(--line); }
.counts th:first-child, .counts td:first-child { text-align: left; }
.counts .alarm { background: var(--bad); font-weight: 700; }
.list { padding-left: 1.1rem; }
.list li { margin-bottom: .4rem; }
.p-thread { padding: 0; overflow: visible; }
.v-do_my_work, .v-serious, .v-error { color: #a23b2a; }
.v-off_topic { color: #8a6d1a; }

/* phone width: the sidebar becomes a strip across the top */
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .side { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .5rem .6rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { flex: 1; }
  .side .new { width: auto; white-space: nowrap; padding: .4rem .6rem; }
  .convs { order: 5; flex: none; width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .convs a { max-width: 11rem; flex: none; background: var(--bg); }
  .who span { display: none; }
  .who button { white-space: nowrap; }
  .main { min-height: 0; }
  .head { padding: .45rem .7rem; }
  .thread { padding: .7rem; }
  .bubble.kid { max-width: 92%; }
  .composer { padding: .5rem .6rem; }
}
