/* StudySpace 0.3 - deep-purple space theme. System fonts only (no external requests). */
:root {
  --bg0: #080520; --bg1: #120a3c; --bg2: #1d1060;
  --surface: rgba(255,255,255,.055); --surface2: rgba(255,255,255,.095); --line: rgba(179,174,224,.2);
  --ink: #efecff; --muted: #b3aee0; --faint: #8c86bd;
  --purple: #8b5cf6; --purple-strong: #7c3aed; --lav: #c4b5fd; --pink: #f472b6; --mint: #6ee7b7; --yellow: #fcd34d; --blue: #7dd3fc; --coral: #fb923c; --danger: #fb7185;
  --radius: 16px; --shadow: 0 14px 40px rgba(6,2,32,.5);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Armenian", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 16px/1.55 var(--font);
  background:
    radial-gradient(1.2px 1.2px at 12% 18%, #fff, transparent 60%), radial-gradient(1px 1px at 78% 12%, #fff, transparent 60%),
    radial-gradient(1.4px 1.4px at 44% 64%, #ddd6fe, transparent 60%), radial-gradient(1px 1px at 90% 70%, #fff, transparent 60%),
    radial-gradient(1.2px 1.2px at 26% 86%, #fff, transparent 60%), radial-gradient(900px 500px at 85% -10%, rgba(139,92,246,.4), transparent 70%),
    radial-gradient(700px 500px at -10% 40%, rgba(236,72,153,.16), transparent 70%), linear-gradient(180deg, var(--bg1), var(--bg0) 70%);
  background-attachment: fixed;
}
a { color: var(--lav); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .88rem; }
.row { display: flex; align-items: center; } .wrap { flex-wrap: wrap; } .gap { gap: 10px; } .between { justify-content: space-between; } .end { justify-content: flex-end; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.ico { flex: none; }

/* topbar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 8px clamp(12px, 3vw, 28px); background: rgba(10,6,36,.82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; } .brand img { height: 34px; width: auto; display: block; }
.nav { display: flex; gap: 2px; align-items: center; flex: 1; }
.nav a, .nav button { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 10px; border: 0; background: none; font: inherit; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.nav a:hover, .nav button:hover { background: var(--surface2); color: var(--ink); }
.nav a[aria-current="page"] { background: rgba(139,92,246,.28); color: #fff; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; padding: 6px; background: #1a1250; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 40; }
.menu a, .menu button { display: flex; width: 100%; text-align: left; }
.nav .menu { left: 0; right: auto; }
.ai-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; background: var(--surface); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.ai-pill .full { display: none; } @media (min-width: 1560px) { .ai-pill .full { display: inline; } .ai-pill .short { display: none; } }
.ai-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); } .ai-pill.ok i { background: var(--mint); box-shadow: 0 0 8px var(--mint); } .ai-pill.warn i { background: var(--yellow); } .ai-pill.bad i { background: var(--danger); }
.langsel { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.langsel button { border: 0; background: none; color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.langsel button[aria-pressed="true"] { background: linear-gradient(135deg, var(--purple-strong), var(--purple)); color: #fff; }
.userbtn { display: inline-flex; gap: 8px; align-items: center; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); cursor: pointer; font: inherit; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: linear-gradient(135deg, var(--purple), var(--pink)); color: #fff; flex: none; }
.topbar .burger { display: none; }
.userbtn .uname { white-space: nowrap; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 1180px; margin: 0 auto; padding: clamp(14px, 3vw, 30px); }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 18px; }
.page-head p { margin: 0; color: var(--muted); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(14px, 2.4vw, 22px); }
.card.glow { box-shadow: 0 0 0 1px rgba(139,92,246,.25), var(--shadow); }
.grid { display: grid; gap: 16px; } .grid.cols { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } .grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.empty { display: grid; place-items: center; gap: 4px; padding: 30px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 0; }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; transition: transform .06s, background .12s, border-color .12s; }
.btn:hover { border-color: rgba(196,181,253,.6); background: rgba(139,92,246,.22); } .btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--purple-strong), var(--purple) 60%, #a78bfa); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(124,58,237,.4); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; } .btn.danger { background: rgba(251,113,133,.16); border-color: rgba(251,113,133,.5); color: #ffd1d9; } .btn.small { min-height: 32px; padding: 0 11px; font-size: .88rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface2); color: var(--ink); }
.field { display: grid; gap: 5px; } .field-label { font-size: .85rem; color: var(--muted); font-weight: 600; } .field-hint { font-size: .8rem; color: var(--faint); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; color: var(--ink); font: inherit; background: rgba(8,4,34,.55); border: 1px solid var(--line); border-radius: 12px;
}
textarea { min-height: 96px; resize: vertical; } select option { color: #111; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139,92,246,.3); }
input[type=checkbox], input[type=radio] { accent-color: var(--purple); width: 18px; height: 18px; }
input[type=range] { accent-color: var(--purple); width: 100%; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: rgba(8,4,34,.55); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.seg button, .seg label { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 9px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg [aria-pressed="true"], .seg [aria-selected="true"], .seg label.on { background: linear-gradient(135deg, var(--purple-strong), var(--purple)); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--surface2); color: var(--lav); border: 1px solid var(--line); }
.badge.teacher { background: linear-gradient(135deg, #f59e0b, #f472b6); color: #2a1048; border: 0; } .badge.mint { color: #052e24; background: var(--mint); border: 0; } .badge.warn { color: #3b2a00; background: var(--yellow); border: 0; } .badge.bad { color: #4a0716; background: var(--danger); border: 0; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px; background: rgba(8,4,34,.5); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; scrollbar-width: none; }
.tabs a { flex: none; padding: 9px 16px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--ink); background: var(--surface); } .tabs a[aria-current="page"] { background: linear-gradient(135deg, var(--purple-strong), var(--purple)); color: #fff; }
.tabs .count { background: rgba(255,255,255,.2); border-radius: 999px; font-size: .75rem; padding: 0 7px; }

/* classroom cards + banner */
.room { display: flex; flex-direction: column; overflow: hidden; padding: 0; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.room:hover { transform: translateY(-3px); box-shadow: 0 18px 44px rgba(124,58,237,.35); }
.room .art { height: 118px; } .room .art svg { width: 100%; height: 100%; display: block; }
.room .body { padding: 14px 16px 16px; display: grid; gap: 6px; } .room h3 { margin: 0; }
.room .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .86rem; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .2em; font-weight: 800; background: rgba(8,4,34,.6); border: 1px dashed var(--lav); padding: 3px 10px; border-radius: 10px; color: var(--yellow); }
.banner { position: relative; overflow: hidden; border-radius: 22px; border: 1px solid var(--line); margin-bottom: 18px; min-height: 170px; display: flex; align-items: end; }
.banner > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(8,4,32,.9), rgba(8,4,32,.1) 70%); }
.banner .in { position: relative; z-index: 1; padding: 18px clamp(14px, 3vw, 26px); width: 100%; display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; }
.banner h1 { margin: 0 0 4px; } .banner p { margin: 0; color: #ddd6fe; }

/* lists */
.list { display: grid; gap: 10px; } .item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.item .grow h3 { margin: 0 0 2px; font-size: 1rem; } .item p { margin: 0; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.kind { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: rgba(139,92,246,.25); color: var(--lav); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .88rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--purple); color: #fff; border-color: transparent; }
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--lav); background: rgba(139,92,246,.12); }
.status-pending { color: var(--yellow); } .status-failed { color: var(--danger); } .status-ready { color: var(--mint); }
table.t { width: 100%; border-collapse: collapse; } table.t th, table.t td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); } table.t th { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface); }
.scroll-x { overflow-x: auto; }
.bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; } .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--mint)); }
.stat { display: grid; gap: 2px; } .stat b { font-size: 1.8rem; line-height: 1; } .stat span { color: var(--muted); font-size: .85rem; }

/* anonymous questions */
.q { display: grid; gap: 10px; }
.q-body { font-size: 1.05rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.answers { display: grid; gap: 8px; margin-left: 12px; padding-left: 14px; border-left: 2px solid rgba(196,181,253,.35); }
.ans { padding: 10px 12px; border-radius: 12px; background: rgba(8,4,34,.45); overflow-wrap: anywhere; white-space: pre-wrap; }
.ans.teacher { border: 1px solid rgba(252,211,77,.55); background: rgba(252,211,77,.09); } .ans .who { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; font-size: .84rem; color: var(--muted); }

/* AI studio */
.studio { display: grid; grid-template-columns: 330px 1fr; gap: 18px; align-items: start; } .picker { max-height: 62vh; overflow: auto; display: grid; gap: 10px; }
.pick { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; background: var(--surface); } .pick:has(input:checked) { border-color: var(--purple); background: rgba(139,92,246,.2); } .pick.off { opacity: .5; }
.opt { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qcard { display: grid; gap: 14px; } .qtext { font-size: 1.2rem; font-weight: 600; overflow-wrap: anywhere; }
.choices { display: grid; gap: 8px; } .choice { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; display: flex; gap: 10px; }
.choice:hover:not(:disabled) { border-color: var(--lav); background: rgba(139,92,246,.2); } .choice.right { border-color: var(--mint); background: rgba(110,231,183,.18); } .choice.wrong { border-color: var(--danger); background: rgba(251,113,133,.18); }
.explain { padding: 12px 14px; border-radius: 12px; background: rgba(125,211,252,.1); border: 1px solid rgba(125,211,252,.35); }
.flash { perspective: 1000px; } .flip { position: relative; min-height: 230px; cursor: pointer; transform-style: preserve-3d; transition: transform .45s; } .flip.on { transform: rotateY(180deg); }
.flip > div { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; border-radius: 20px; border: 1px solid var(--line); backface-visibility: hidden; background: linear-gradient(135deg, rgba(124,58,237,.5), rgba(236,72,153,.28)); font-size: 1.25rem; overflow: auto; }
.flip > .back { transform: rotateY(180deg); background: linear-gradient(135deg, rgba(14,116,144,.55), rgba(124,58,237,.4)); }
.chat { display: grid; gap: 10px; max-height: 52vh; overflow: auto; padding: 4px; } .msg { padding: 10px 14px; border-radius: 14px; max-width: 92%; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.user { justify-self: end; background: linear-gradient(135deg, var(--purple-strong), var(--purple)); } .msg.bot { background: var(--surface2); border: 1px solid var(--line); }
.msg .tag { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--yellow); margin: 8px 0 2px; } .msg .tag.extra { color: var(--blue); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--lav); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; } @keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 40px; color: var(--muted); }

/* modal + toast */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(5,2,24,.72); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 14px; overflow: auto; }
.modal { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: #170f4a; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); } .modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal-head h2 { margin: 0; font-size: 1.1rem; } .modal-body { padding: 18px; }
.toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 11px 16px; border-radius: 12px; background: #261a6a; border: 1px solid var(--line); box-shadow: var(--shadow); } .toast.error { border-color: var(--danger); background: #4a1030; } .toast.ok { border-color: var(--mint); }
pre.text { white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(8,4,34,.6); border: 1px solid var(--line); border-radius: 12px; padding: 14px; max-height: 60vh; overflow: auto; font: .92rem/1.55 var(--font); }

/* welcome */
.welcome { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.welcome .panel { width: min(980px, 100%); display: grid; gap: 26px; }
.hero { text-align: center; } .hero img { width: min(420px, 80%); height: auto; } .hero p { color: var(--muted); font-size: 1.1rem; max-width: 560px; margin: 8px auto 0; }
.welcome .langsel { justify-self: center; }
.features { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; } .features span { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .9rem; color: var(--lav); }
.foot { text-align: center; color: var(--faint); font-size: .85rem; padding: 24px 12px 40px; }

.mathpage .mathtool { margin-top: 6px; }

@media (max-width: 1180px) {
  .topbar .burger { display: inline-grid; } .nav { position: fixed; inset: 52px 0 auto 0; flex-direction: column; align-items: stretch; background: #120a3c; padding: 10px; border-bottom: 1px solid var(--line); display: none; }
  .nav.open { display: flex; } .nav .menu { position: static; box-shadow: none; border: 0; background: none; padding-left: 14px; }
  .topbar { gap: 8px; } .topbar .spacer { flex: 1; }
}
@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; } .picker { max-height: 40vh; }
  .userbtn .uname, .userbtn .badge { display: none; } .ai-pill span { display: none; }
}
@media (max-width: 520px) { .brand img { height: 26px; } .topbar { padding-left: 10px; padding-right: 10px; gap: 6px; } .langsel button { padding: 5px 6px; font-size: .78rem; } .btn { padding: 0 13px; } }
@media (max-width: 400px) { .ai-pill { display: none; } }
/* Armenian words are long: tighten the top bar on laptops before it would have to collapse */
@media (min-width: 1181px) and (max-width: 1480px) { html[lang="hy"] .nav a svg, html[lang="hy"] .nav button svg { display: none; } html[lang="hy"] .nav a, html[lang="hy"] .nav button { padding: 8px 9px; } html[lang="hy"] .userbtn .badge { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
