/* Spațiul BuncarulIT: a squared school notebook ("caiet cu pătrățele").
   Paper with a faint blue grid and a red margin rule, school-pen ink for actions,
   yellow highlighter for Bufnița. Contrast computed: body text >= 7:1 on every surface. */
@font-face { font-family: "Lexend"; src: url(/static/fonts/lexend-latin-ext.woff2) format("woff2");
  font-weight: 300 700; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+2020, U+20A0-20C4, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Lexend"; src: url(/static/fonts/lexend-latin.woff2) format("woff2");
  font-weight: 300 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  --paper: #ffffff; --grid: #e6edf7; --desk: #eef2f8; --line: #cfd9ea;
  --text: #172033; --muted: #3d475b;
  --ink: #1e3a9a; --ink-soft: #dfe7f7; --margin: #e59aa1;
  --hl: #fff1a6; --hl-edge: #e3c341;
  --ok: #165a30; --ok-soft: #e2f2e7; --err: #a4161f;
  --r-s: 6px; --r-m: 12px;
  --margin-x: 64px;
  font-family: "Lexend", "Segoe UI", system-ui, sans-serif; font-size: 16px; line-height: 1.55;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--desk); }
body { display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ink); text-underline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }

/* Squared paper: grid + red margin rule, scrolls with the content. */
.paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent calc(var(--margin-x) - 4px), var(--margin) calc(var(--margin-x) - 4px),
      var(--margin) calc(var(--margin-x) - 2px), transparent calc(var(--margin-x) - 2px),
      transparent var(--margin-x), var(--margin) var(--margin-x), var(--margin) calc(var(--margin-x) + 2px), transparent calc(var(--margin-x) + 2px)),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px, 24px 24px;
  background-attachment: local;
}

/* Header: the notebook cover band; the open tab is a page of paper. */
.top { display: flex; align-items: flex-end; gap: 20px; padding: 10px 24px 0; background: var(--ink); color: #fff; }
.brand { font-weight: 700; font-size: 21px; padding-bottom: 12px; white-space: nowrap; }
.brand small { font-weight: 400; font-size: 15px; color: #dce4f5; margin-left: 6px; }
.tabs { display: flex; gap: 2px; flex: 1; align-items: flex-end; }
.tab { border: 0; background: transparent; padding: 10px 16px 11px; border-radius: var(--r-m) var(--r-m) 0 0;
  cursor: pointer; color: #dce4f5; font-weight: 700; text-decoration: none; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--paper); color: var(--ink); }
.top .right { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.who { color: #dce4f5; }
.top .btn { background: transparent; color: #fff; border-color: #6f86cf; }

.btn { border: 2px solid var(--line); background: var(--paper); padding: 8px 16px; border-radius: var(--r-s);
  cursor: pointer; font-weight: 700; min-height: 42px; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
@media (hover: hover) {
  .btn:hover:not(:disabled) { border-color: var(--ink); }
  .btn.primary:hover:not(:disabled) { background: #172e7c; }
  .tab:not([aria-selected="true"]):hover { background: rgba(255, 255, 255, .12); color: #fff; }
  .top .btn:hover { border-color: #fff; }
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus, .tab:focus, .room:focus { outline: none; }
.btn:focus-visible, .tab:focus-visible, .room:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, a:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }

input, textarea, select { border: 2px solid var(--line); background: var(--paper); border-radius: var(--r-s);
  padding: 9px 12px; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); }
textarea { resize: vertical; min-height: 46px; }
label { display: block; font-weight: 700; margin: 14px 0 6px; }
.err { color: var(--err); font-weight: 700; min-height: 1.2em; margin-top: 8px; }
.err:empty { min-height: 0; margin: 0; }
.note { color: var(--muted); font-size: 15px; }

main { flex: 1; min-height: 0; }
.view { height: 100%; }
.card { background-color: var(--paper); border: 2px solid var(--line); border-radius: var(--r-m); padding: 22px; }

/* Student view banner (teachers only) */
.as-student { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 8px 16px;
  background: var(--hl); border-bottom: 2px solid var(--hl-edge); font-weight: 700; }

/* Login / invite: a single notebook page */
.center { display: grid; place-items: center; height: 100%; padding: 24px; --margin-x: 40px; }
.login { width: min(460px, 100%); padding: 32px 32px 28px calc(var(--margin-x) + 24px); border: 0;
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px rgba(23, 32, 51, .45); }
.login h1 { margin: 0 0 6px; font-size: 30px; color: var(--ink); }
.login .btn.primary { min-width: 140px; justify-content: center; }

/* Chat */
.chat { display: grid; grid-template-columns: 220px minmax(0, 1fr) 210px; height: 100%; }
.side { background: var(--desk); padding: 18px 14px; overflow: auto; }
.side h3 { margin: 0 0 10px; font-size: 16px; color: var(--muted); }
.room { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px;
  border-radius: var(--r-s); cursor: pointer; font-weight: 700; margin-bottom: 2px; }
.room[aria-current="true"] { background: var(--paper); color: var(--ink); box-shadow: inset 4px 0 0 var(--ink); }
@media (hover: hover) { .room:not([aria-current="true"]):hover { background: #e3e9f3; } }
.online { padding: 0; margin: 0; }
.online li { list-style: none; padding: 5px 0; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.online li::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #2f8a50; flex: none; }
.online .empty { font-weight: 400; }
.online .empty::before { display: none; }
.stream { display: flex; flex-direction: column; min-height: 0; border-left: 2px solid var(--line);
  border-right: 2px solid var(--line); }
.msgs { flex: 1; overflow-y: auto; padding: 18px 28px 18px 0; display: flex; flex-direction: column; gap: 14px; }
.msgs .empty-room { margin-left: calc(var(--margin-x) + 16px); }

.msg { display: grid; grid-template-columns: var(--margin-x) minmax(0, 1fr); column-gap: 16px; max-width: 980px; }
.avatar { grid-column: 1; justify-self: center; width: 38px; height: 38px; border-radius: 50%; display: grid;
  place-items: center; color: #fff; font-weight: 700; font-size: 15px; background: var(--ink); }
.msg.cont .avatar { visibility: hidden; height: 0; }
.bubble { grid-column: 2; min-width: 0; }
.who-line { font-size: 15px; color: var(--muted); }
.who-line b { color: var(--text); font-size: 16px; margin-right: 6px; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.thread .bubble { margin-left: 22px; padding-left: 16px; border-left: 3px solid var(--line); }
.msg.thread .avatar { width: 30px; height: 30px; font-size: 13px; margin-left: 0; }

/* Bufnița: yellow highlighter strip */
.msg.bot .avatar { background: var(--hl); color: var(--text); box-shadow: inset 0 0 0 2px var(--hl-edge); }
.msg.bot .avatar svg { width: 24px; height: 24px; }
.msg.bot .card-hl { background: var(--hl); border-radius: 3px 14px 4px 12px; padding: 12px 16px 14px;
  box-shadow: 0 1px 0 var(--hl-edge); }
.msg.bot.thread .bubble { border-left-color: var(--hl-edge); }
.sources { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.sources li { background: var(--paper); border: 2px solid var(--hl-edge); border-radius: var(--r-s); padding: 8px 12px; }
.sources a { font-weight: 700; }
.sources .focus { color: var(--muted); font-size: 15px; display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.reply-btn { margin-top: 4px; background: none; border: 0; padding: 2px 0; color: var(--ink); font-weight: 700;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.composer { background: var(--paper); padding: 12px 20px 14px; border-top: 2px solid var(--line); }
.composer .row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 50px; }
.composer .btn.primary { min-height: 50px; padding: 0 22px; }
.replying { font-size: 15px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.hint-line { font-size: 14px; color: var(--muted); margin-top: 6px; }
.hint-line code { background: var(--hl); padding: 0 4px; border-radius: 3px; color: var(--text); font-family: inherit; font-weight: 700; }

/* Pages (quiz, prea greu, archive) */
.page { height: 100%; overflow: auto; padding: 28px 32px 48px calc(var(--margin-x) + 28px); }
.page > * { max-width: 1100px; }
.page h2 { margin: 0 0 6px; font-size: 30px; color: var(--ink); }
.page h3 { font-size: 20px; margin: 28px 0 12px; }
.page > .note:first-of-type { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.grid > * { min-width: 0; }
.topic { display: flex; flex-direction: column; gap: 8px; padding: 18px; }
.topic b { font-size: 18px; }
.topic .btn { align-self: flex-start; margin-top: auto; }
.meter { height: 8px; border-radius: 4px; background: var(--ink-soft); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); }
.q { margin: 0 0 16px; }
.q .text { white-space: pre-wrap; font-weight: 700; font-size: 18px; }
.q img { max-width: 280px; display: block; margin: 10px 0; background: #fff; border-radius: var(--r-s); }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 2px solid var(--line);
  border-radius: var(--r-s); margin: 8px 0; cursor: pointer; font-weight: 400; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--ink-soft); }
.opt input { width: auto; margin-top: 5px; accent-color: var(--ink); }
.res { margin-top: 8px; }
.res.ok { color: var(--ok); font-weight: 700; }
.res.bad { color: var(--err); font-weight: 700; }
.score { font-size: 22px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 14px 0; border-bottom: 2px solid var(--grid); }
.list .body { white-space: pre-wrap; }
.reply { margin-top: 8px; background: var(--hl); padding: 10px 14px; border-radius: 3px 12px 4px 10px; }
.archive a { font-size: 18px; font-weight: 700; }

@media (max-width: 860px) {
  :root { --margin-x: 46px; font-size: 16px; }
  .chat { grid-template-columns: 1fr; }
  .side { display: none; }
  .stream { border: 0; }
  .top { flex-wrap: wrap; padding: 8px 12px 0; gap: 4px 8px; align-items: center; }
  .brand { flex: 1; padding-bottom: 4px; font-size: 19px; }
  .brand small { display: none; }
  .top .right { padding-bottom: 4px; }
  .tabs { order: 3; flex: 0 0 100%; overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 9px 13px 10px; }
  .who { display: none; }
  .msgs { padding-right: 12px; }
  .msg { column-gap: 10px; }
  .avatar { width: 32px; height: 32px; font-size: 13px; }
  .msg.thread .bubble { margin-left: 4px; padding-left: 10px; }
  .composer { padding: 10px 12px; }
  .page { padding: 20px 14px 40px calc(var(--margin-x) + 12px); }
  .page h2 { font-size: 25px; }
  .login { padding: 26px 20px 22px calc(var(--margin-x) + 16px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
