:root {
  --bg: #0a0c10;
  --panel: #12161d;
  --panel-2: #171c25;
  --panel-3: #1c222d;
  --line: #242b38;
  --line-soft: #1b212b;
  --text: #eef1f6;
  --muted: #8b94a6;
  --dim: #646d7f;
  --accent: #ff5a3c;
  --accent-2: #ffb03a;
  --ok: #39d98a;
  --bad: #ff4d5e;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 20px 50px rgba(0,0,0,.45);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 12% -12%, rgba(255, 90, 60, .16), transparent 62%),
    radial-gradient(820px 480px at 102% -4%, rgba(255, 176, 58, .07), transparent 58%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: rgba(255, 90, 60, .32); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262d3a; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #343d4d; background-clip: content-box; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; margin-bottom: 10px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---------- sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(18, 22, 29, .92), rgba(10, 12, 16, .92));
  min-height: 0;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }

.face { width: 42px; height: 42px; flex: none; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .16em;
  background: linear-gradient(100deg, #fff 10%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .06em; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }

.nav-item:hover { background: rgba(255, 255, 255, .04); color: var(--text); }

.nav-item.active {
  background: linear-gradient(90deg, rgba(255, 90, 60, .16), rgba(255, 90, 60, .04));
  color: #fff;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.nav-item.active svg { color: var(--accent); opacity: 1; }

.side-foot {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, .02);
}

.foot-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.foot-label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.foot-value b { font-size: 15px; }

.xpbar {
  height: 7px;
  margin: 12px 0 7px;
  border-radius: 6px;
  background: #1b2029;
  overflow: hidden;
}

.xpbar i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s ease;
}

.xp-text { font-size: 11.5px; color: var(--dim); }

/* ---------- main ---------- */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 30px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); max-width: 50%; }
.status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(57, 217, 138, .12); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 3px rgba(255, 77, 94, .12); }

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 30px 30px;
}

/* ---------- primitives ---------- */

.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(23, 28, 37, .9), rgba(18, 22, 29, .9));
  padding: 20px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
}

.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.side { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--dim); font-size: 12.5px; margin-top: 10px; line-height: 1.5; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  user-select: none;
}

.btn:hover { background: var(--panel-3); border-color: #2e3747; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn svg { width: 16px; height: 16px; }

.btn.primary {
  background: linear-gradient(180deg, #ff6a4d, #f04a2c);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(255, 90, 60, .26);
}
.btn.primary:hover { background: linear-gradient(180deg, #ff7a5f, #ff5334); }

.btn.danger { border-color: rgba(255, 77, 94, .35); color: #ff8a95; background: rgba(255, 77, 94, .08); }
.btn.danger:hover { background: rgba(255, 77, 94, .14); }

.btn.ghost { background: transparent; }

.btn.small { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}

.icon-btn:hover { color: var(--text); background: var(--panel-3); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.rec { color: #fff; background: var(--accent); border-color: transparent; animation: pulse 1.4s infinite; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .03);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .02em;
}

.chip {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .02);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.chip:hover { color: var(--text); border-color: #39424f; background: rgba(255, 255, 255, .04); }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 1px dashed rgba(255, 176, 58, .4);
  border-radius: 12px;
  background: rgba(255, 176, 58, .06);
  font-size: 13px;
  color: #f2cf94;
}

.banner .btn { flex: none; }

/* ---------- chat ---------- */

.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 12px; }

.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.tutor-head { display: flex; align-items: center; gap: 12px; }
.tutor-name { font-weight: 650; font-size: 15px; }

.avatar { width: 38px; height: 38px; flex: none; }
.avatar.big { width: 48px; height: 48px; }

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 10px; max-width: 86%; animation: rise .22s ease; }
.msg.user { margin-left: auto; justify-content: flex-end; }
.msg.bot { align-self: flex-start; }

.stack { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.bubble {
  padding: 12px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  border-top-left-radius: 5px;
  background: var(--panel-2);
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble b { color: #fff; }
.bubble code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .07);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  color: #ffd7a3;
}

.msg.user .bubble {
  background: linear-gradient(180deg, #ff6449, #ef4b2d);
  border-color: transparent;
  border-top-left-radius: 15px;
  border-top-right-radius: 5px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 90, 60, .2);
}

.msg.bot .bubble { border-top-left-radius: 5px; }

.bubble.error { border-color: rgba(255, 77, 94, .45); background: rgba(255, 77, 94, .08); color: #ffb6bd; }

.words { display: flex; flex-wrap: wrap; gap: 6px; }

.word-chip {
  padding: 5px 10px;
  border: 1px dashed rgba(255, 176, 58, .45);
  border-radius: 999px;
  background: rgba(255, 176, 58, .07);
  color: #ffd79a;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s ease;
}

.word-chip:hover { background: rgba(255, 176, 58, .14); }
.word-chip:disabled { opacity: .5; cursor: default; border-style: solid; }

.msg-tools { display: flex; gap: 8px; }

.ghost-mini {
  padding: 2px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.ghost-mini:hover { color: var(--text); background: rgba(255, 255, 255, .05); }

.chat-bar {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  transition: border-color .15s ease;
}

.chat-bar:focus-within { border-color: rgba(255, 90, 60, .45); }

.chat-bar textarea {
  flex: 1;
  min-height: 40px;
  max-height: 150px;
  padding: 9px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  resize: none;
}

.chat-bar textarea::placeholder { color: var(--dim); }

.send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}

.send:hover { background: #ff6f53; }
.send:active { transform: scale(.96); }
.send:disabled { opacity: .5; cursor: wait; }
.send svg { width: 20px; height: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chat-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.chat-hint { text-align: center; margin-top: 2px; }

.empty-chat { margin: auto; text-align: center; max-width: 460px; padding: 24px; }
.empty-chat .face { width: 76px; height: 76px; margin-bottom: 14px; }
.empty-chat p { color: var(--muted); font-size: 14px; }
.empty-chat b { color: var(--text); }

.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

/* ---------- drills ---------- */

.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }

.topic {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}

.topic:hover { border-color: rgba(255, 90, 60, .45); background: rgba(255, 90, 60, .06); transform: translateY(-1px); }

.topic-ic {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
  border-radius: 9px;
  background: rgba(255, 90, 60, .14);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.drill { display: flex; flex-direction: column; gap: 14px; }
.drill-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.prompt { font-size: 17px; line-height: 1.5; margin: 2px 0 0; }

.options { display: flex; flex-direction: column; gap: 8px; }

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .02);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.option:hover:not(:disabled) { border-color: #3a4352; background: rgba(255, 255, 255, .04); }
.option:disabled { cursor: default; }

.option.correct { border-color: rgba(57, 217, 138, .55); background: rgba(57, 217, 138, .1); color: #a9f3ce; }
.option.wrong { border-color: rgba(255, 77, 94, .55); background: rgba(255, 77, 94, .1); color: #ffb3ba; }

.answer-row { display: flex; gap: 10px; }
.answer-row input { flex: 1; }

.feedback { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.feedback.ok { border-color: rgba(57, 217, 138, .4); background: rgba(57, 217, 138, .06); }
.feedback.bad { border-color: rgba(255, 77, 94, .4); background: rgba(255, 77, 94, .06); }

.fb-head { font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ok); }
.feedback.bad .fb-head { color: var(--bad); }
.fb-answer { margin-top: 6px; font-size: 14px; }
.fb-answer b { color: #fff; }
.fb-explain { margin-top: 6px; color: var(--muted); font-size: 13.5px; }
.snark { margin-top: 10px; padding-left: 11px; border-left: 2px solid rgba(255, 90, 60, .5); color: #ffc0ae; font-size: 13.5px; font-style: italic; }

.summary { text-align: center; padding: 10px 0; }
.summary .big-score { font-size: 46px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.summary .big-score small { font-size: 18px; color: var(--muted); font-weight: 600; }

/* ---------- vocabulary ---------- */

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

input[type="text"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0e1218;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(255, 90, 60, .55);
  box-shadow: 0 0 0 3px rgba(255, 90, 60, .1);
}

input::placeholder { color: #4f5869; }

.form-stack { display: flex; flex-direction: column; gap: 0; }

.vocab-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; padding-right: 4px; }

.vocab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: rgba(255, 255, 255, .02);
}

.vocab-item .wi-main { flex: 1; min-width: 0; }
.word-en { font-weight: 600; font-size: 14.5px; }
.word-ru { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.boxes { display: flex; gap: 3px; flex: none; }
.boxes i { width: 6px; height: 6px; border-radius: 50%; background: #2a3140; }
.boxes i.on { background: var(--accent-2); }

.review { text-align: center; padding: 34px 22px; }
.word-front { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin: 10px 0 6px; }
.word-back { font-size: 18px; color: var(--accent-2); margin-top: 8px; }
.review-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.mini-stats { display: flex; gap: 18px; margin-top: 8px; flex-wrap: wrap; }
.mini-stats div { display: flex; flex-direction: column; }
.mini-stats b { font-size: 20px; }
.mini-stats span { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- pronunciation ---------- */

.big-mic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 74px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #1b212c, #151a22);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.big-mic:hover { border-color: rgba(255, 90, 60, .5); }
.big-mic svg { width: 24px; height: 24px; }
.big-mic.rec { background: linear-gradient(180deg, #ff6a4d, #ef4b2d); border-color: transparent; color: #fff; animation: pulse 1.5s infinite; }

.pron-live { min-height: 20px; margin-top: 10px; color: var(--muted); font-size: 14px; font-style: italic; }

.score-ring {
  --p: 0;
  width: 118px;
  height: 118px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--p) * 1%), #1d2430 0);
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #12161d;
}

.score-ring b {
  position: relative;
  z-index: 1;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.score-label { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }

.wordcmp { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.wordcmp span { padding: 4px 9px; border-radius: 7px; font-size: 13px; }
.wordcmp .w-ok { background: rgba(57, 217, 138, .13); color: #a9f3ce; }
.wordcmp .w-bad { background: rgba(255, 77, 94, .13); color: #ffb3ba; text-decoration: line-through; }
.wordcmp .w-extra { background: rgba(255, 176, 58, .12); color: #ffd79a; }

.ai-fb { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 14px; }

/* ---------- progress ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.stat { padding: 16px; border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(255, 255, 255, .02); }
.stat b { display: block; font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.stat span { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 8px; }

.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart .colbar { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart .colbar i {
  width: 100%;
  max-width: 42px;
  min-height: 4px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, var(--accent), rgba(255, 90, 60, .35));
  transition: height .4s ease;
}
.chart .col span { font-size: 11px; color: var(--dim); }
.chart .col b { font-size: 11.5px; color: var(--muted); font-weight: 600; }

.topic-row { display: grid; grid-template-columns: 1fr 110px 48px; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.topic-row:last-child { border-bottom: 0; }
.topic-row .tbar { height: 6px; border-radius: 4px; background: #1d2430; overflow: hidden; }
.topic-row .tbar i { display: block; height: 100%; border-radius: 4px; background: var(--ok); }
.topic-row .tbar i.low { background: var(--bad); }
.topic-row .tbar i.mid { background: var(--accent-2); }
.topic-row em { font-style: normal; color: var(--muted); text-align: right; font-size: 12.5px; }

.empty-note { padding: 26px 10px; text-align: center; color: var(--dim); font-size: 13.5px; }

/* ---------- settings ---------- */

.presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }

.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: #0e1218; gap: 3px; }
.segbtn {
  padding: 7px 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segbtn:hover { color: var(--text); }
.segbtn.on { background: rgba(255, 90, 60, .16); color: #ffb8a8; box-shadow: 0 0 0 1px rgba(255, 90, 60, .35) inset; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  max-width: min(520px, 90vw);
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #1b212b;
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(57, 217, 138, .5); }
.toast.bad { border-color: rgba(255, 77, 94, .55); }

/* ---------- auth ---------- */

.auth-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(900px 520px at 20% 0%, rgba(255, 90, 60, .16), transparent 60%),
    radial-gradient(700px 420px at 100% 10%, rgba(255, 176, 58, .07), transparent 55%),
    var(--bg);
}

.auth-root[hidden] { display: none; }

.auth-card {
  width: min(400px, 100%);
  padding: 28px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(23, 28, 37, .97), rgba(15, 19, 25, .97));
  box-shadow: var(--shadow);
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-name { font-size: 22px; }
.auth-card h2 { margin-bottom: 4px; }
.auth-card > .muted { margin-bottom: 16px; }
.auth-error { min-height: 18px; margin: 4px 0 10px; color: #ff8a95; font-size: 12.5px; }
.auth-submit { width: 100%; }

/* ---------- sidebar user ---------- */

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
}

.su-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.su-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.su-text span { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; }
.side-user .icon-btn { width: 34px; height: 34px; }

/* ---------- admin ---------- */

.user-list { display: flex; flex-direction: column; gap: 8px; }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
}

.u-main { flex: 1; min-width: 0; }
.u-name { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.u-meta { font-size: 12px; color: var(--dim); margin-top: 3px; }
.u-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.role-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
}

.role-badge.admin { background: rgba(255, 90, 60, .15); color: #ffb8a8; }
.role-badge.off { background: rgba(255, 77, 94, .15); color: #ffb3ba; }

/* ---------- animations ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 60, .35); } 50% { box-shadow: 0 0 0 8px rgba(255, 90, 60, 0); } }

.spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */

@media (max-width: 1120px) {
  .grid.two, .grid.side { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); height: auto; min-height: 100dvh; }
  .sidebar { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
  .brand { flex: none; }
  .brand-text { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav-item { width: auto; padding: 9px; }
  .nav-item span { display: none; }
  .side-foot { margin: 0; padding: 8px 10px; flex: none; }
  .side-foot .foot-row, .side-foot .xpbar { display: none; }
  .xp-text { display: none; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px; }
  .chat { height: calc(100dvh - 150px); }
  .msg { max-width: 94%; }
  .topic-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .su-text { display: none; }
  .side-user { padding: 6px; }
  .auth-root { padding: 14px; }
}
