/* ============================================================
   Научход — общий стиль для всех страниц
   Идея: лист инженерной тетради — миллиметровка на фоне,
   разделы как листы чертежа со «штампом» в углу.
   ============================================================ */

:root {
  --paper: #F3F6F9;
  --sheet: #FFFFFF;
  --ink: #14233F;
  --ink-2: #4A5873;
  --line: #D5DDE8;
  --grid: rgba(20, 35, 63, .05);
  --accent: #E2541B;
  --accent-ink: #FFFFFF;
  --free: #0F7B6C;
  --free-bg: #E2F4F0;
  --busy: #E9EDF2;
  --busy-ink: #8D97A8;
  --warn-bg: #FFF1E8;
  --error: #C0352B;
  --error-bg: #FDECEA;

  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Golos Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1626; --sheet: #152036; --ink: #E6ECF5; --ink-2: #A2AEC4; --line: #2A3853;
    --grid: rgba(230, 236, 245, .04); --accent: #FF7A45; --accent-ink: #1A0E07;
    --free: #4FD1B8; --free-bg: #123A37; --busy: #1E2A42; --busy-ink: #6E7B94; --warn-bg: #3A2418;
    --error: #FF8A80; --error-bg: #3D1D1D;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1626; --sheet: #152036; --ink: #E6ECF5; --ink-2: #A2AEC4; --line: #2A3853;
  --grid: rgba(230, 236, 245, .04); --accent: #FF7A45; --accent-ink: #1A0E07;
  --free: #4FD1B8; --free-bg: #123A37; --busy: #1E2A42; --busy-ink: #6E7B94; --warn-bg: #3A2418;
  --error: #FF8A80; --error-bg: #3D1D1D;
  color-scheme: dark;
}

/* ---------- основа ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--f-body);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
main { flex: 1; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 700; }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 500; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.narrow { max-width: 480px; }
.mono { font-family: var(--f-mono); font-size: .82rem; letter-spacing: .02em; }
.muted { color: var(--ink-2); }
.small { font-size: .88rem; }
.eyebrow {
  font-family: var(--f-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--accent);
}
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }

/* ---------- шапка ---------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--sheet); border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 18px; padding-block: 12px; flex-wrap: wrap; }
.logo {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  font-family: var(--f-display); font-weight: 700; font-size: 1.15rem;
}
nav.menu { display: flex; gap: 2px; flex-wrap: wrap; }
nav.menu a {
  text-decoration: none; padding: 6px 10px; border-radius: var(--r);
  font-size: .92rem; color: var(--ink-2);
}
nav.menu a:hover { background: var(--busy); color: var(--ink); }
nav.menu a[aria-current="page"] { color: var(--ink); background: var(--busy); font-weight: 500; }
.account { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-size: .72rem; font-family: var(--f-mono);
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: var(--r); cursor: pointer; font-weight: 500;
  text-decoration: none; transition: transform .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---------- заголовок страницы ---------- */
.page-head { padding-block: 36px 8px; display: flex; gap: 24px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; }
.page-head p { max-width: 62ch; margin-top: 8px; color: var(--ink-2); }
.stamp {
  font-family: var(--f-mono); font-size: .7rem; border: 1px solid var(--ink);
  display: grid; grid-template-columns: auto auto; min-width: 220px; background: var(--sheet);
}
.stamp span { padding: 3px 8px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.stamp span:nth-child(2n) { border-right: 0; }
.stamp span:nth-last-child(-n+2) { border-bottom: 0; }
.stamp span:nth-child(2n+1) { color: var(--ink-2); }

/* ---------- лист (белая подложка) ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(18px, 3vw, 32px); }
.section { padding-block: 20px 40px; }

/* ---------- фильтры ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--line); background: var(--sheet); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: .88rem; text-decoration: none;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.search { flex: 1 1 240px; min-width: 0; }

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--line); border-radius: var(--r); padding: 18px;
  display: flex; flex-direction: column; gap: 12px; background: var(--sheet); min-width: 0;
}
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.meta { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: .76rem; padding: 2px 8px; border-radius: 4px; background: var(--busy); color: var(--ink-2); }
.tag.free { background: var(--free-bg); color: var(--free); }
.tag.paid { background: var(--warn-bg); color: var(--accent); }
.tag.bad { background: var(--error-bg); color: var(--error); }

.equip { margin: 0; padding: 0; list-style: none; font-size: .9rem; display: grid; gap: 4px; }
.equip li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted var(--line); padding-bottom: 3px; }
.equip li span:last-child { font-family: var(--f-mono); font-size: .78rem; color: var(--ink-2); text-align: right; }

.safety { background: var(--warn-bg); border-radius: var(--r); padding: 14px 16px; font-size: .92rem; }
.safety ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }

/* ---------- календарь ---------- */
.cal { overflow-x: auto; }
.cal table { border-collapse: separate; border-spacing: 5px; font-variant-numeric: tabular-nums; }
.cal th { font-weight: 500; color: var(--ink-2); font-family: var(--f-mono); font-size: .74rem; white-space: nowrap; padding: 0 4px; }
.slot {
  width: 100%; min-width: 64px; height: 36px; border-radius: 4px; border: 1px solid transparent;
  cursor: pointer; font-family: var(--f-mono); font-size: .76rem;
}
.slot.open { background: var(--free-bg); color: var(--free); border-color: var(--free); }
.slot.open:hover, .slot.chosen { background: var(--free); color: var(--sheet); }
.slot.taken { background: var(--busy); color: var(--busy-ink); cursor: not-allowed; }
.slot.mine { background: var(--accent); color: var(--accent-ink); }
.slot.pending { background: var(--warn-bg); color: var(--accent); border: 1px dashed var(--accent); }
.slot:disabled.open { cursor: default; opacity: .7; }
.request { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.request:last-child { border-bottom: 0; }
.request .input.small { padding: 6px 10px; font-size: .86rem; }
@media (max-width: 640px) { .request { grid-template-columns: 1fr; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.two-col > * { min-width: 0; }

/* ---------- формы ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field label, .label { font-size: .86rem; color: var(--ink-2); }
.input, .field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px;
  background: var(--paper); width: 100%;
}
.field textarea { resize: vertical; }
.field input[type=radio], .field input[type=checkbox] { width: auto; padding: 0; }
#themeBtn svg { display: block; }
.hint { font-size: .8rem; color: var(--ink-2); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: 4px; }
.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-row label {
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px;
  cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: .92rem;
}
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--warn-bg); }

.code-input {
  font-family: var(--f-mono); font-size: 1.8rem; letter-spacing: .5em; text-align: center;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); width: 100%;
}

/* шаги регистрации */
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--busy); }
.steps span.on { background: var(--accent); }
.auth-box { margin: 48px auto; }

/* ---------- сообщения ---------- */
.alert { padding: 10px 14px; border-radius: var(--r); font-size: .92rem; }
.alert.error { background: var(--error-bg); color: var(--error); }
.alert.ok { background: var(--free-bg); color: var(--free); }
.alert.info { background: var(--busy); color: var(--ink); }
.alert.dev { background: var(--warn-bg); color: var(--ink); border: 1px dashed var(--accent); }
.alert.dev b { font-family: var(--f-mono); font-size: 1.1rem; color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--r);
  font-size: .92rem; z-index: 50; max-width: calc(100vw - 32px);
}
.empty { padding: 28px; color: var(--ink-2); text-align: center; font-size: .92rem; border: 1px dashed var(--line); border-radius: var(--r); }

/* ---------- главная ---------- */
.hero { padding-block: 56px 32px; }
.hero-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { font-size: 1.1rem; max-width: 58ch; margin-top: 18px; color: var(--ink-2); }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.modules { display: grid; gap: 10px; }
.modules a {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center;
  padding: 14px 16px; background: var(--sheet); border: 1px solid var(--line);
  border-radius: var(--r); text-decoration: none;
}
.modules a:hover { border-color: var(--accent); }
.modules b { font-family: var(--f-display); font-weight: 500; font-size: .98rem; }
.modules small { display: block; color: var(--ink-2); font-size: .86rem; }
.modules .n { font-family: var(--f-mono); font-size: .78rem; color: var(--ink-2); }
.ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--warn-bg); color: var(--accent); }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 34px; padding-top: 18px; border-top: 1px dashed var(--line); }
.stats b { display: block; font-family: var(--f-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stats span { font-size: .85rem; color: var(--ink-2); }
.aud { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); margin-top: 18px; }
.aud div { padding: 20px 18px 4px; border-right: 1px solid var(--line); display: grid; gap: 8px; align-content: start; }
.aud div:last-child { border-right: 0; }
.aud .mono { color: var(--accent); }

/* ---------- наставники ---------- */
.mentor { display: grid; grid-template-columns: 56px 1fr; gap: 14px; }
.ava {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 500; color: #fff; background: var(--ink-2);
}
.status { font-size: .8rem; font-family: var(--f-mono); }
.status.wait { color: var(--accent); }
.status.ok { color: var(--free); }
.status.bad { color: var(--error); }

/* ---------- чаты ---------- */
.chat-list { display: grid; gap: 8px; }
.chat-item {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--sheet); text-decoration: none;
}
.chat-item:hover { border-color: var(--accent); }
.chat-item .ava { width: 44px; height: 44px; font-size: .85rem; }
.chat-item p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; color: var(--ink-2); }
.chat-item > div { min-width: 0; }
.chat-window { display: flex; flex-direction: column; height: min(70vh, 620px); padding: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 10px; font-size: .94rem; background: var(--busy); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--ink); color: var(--paper); }
.msg time { display: block; font-size: .7rem; opacity: .65; margin-top: 2px; font-family: var(--f-mono); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; }

/* ---------- проекты ---------- */
.stage-bar { display: flex; gap: 3px; margin-top: 4px; }
.stage-bar i { flex: 1; height: 5px; border-radius: 2px; background: var(--busy); }
.stage-bar i.on { background: var(--accent); }
.response { border-left: 3px solid var(--free); padding: 6px 12px; display: grid; gap: 4px; }

/* ---------- таблицы ---------- */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--sheet); }
.tbl table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { font-family: var(--f-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); font-weight: 400; }
.tbl tr:last-child td { border-bottom: 0; }

/* ---------- Social Credit ---------- */
.gauge { display: grid; gap: 12px; align-content: start; }
.gauge b { font-family: var(--f-display); font-size: 2.6rem; font-variant-numeric: tabular-nums; line-height: 1; }
.bar { height: 10px; border-radius: 5px; background: var(--busy); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--free); transition: width .4s; }

/* ---------- подвал ---------- */
footer { padding-block: 26px 36px; color: var(--ink-2); font-size: .86rem; border-top: 1px solid var(--line); background: var(--sheet); margin-top: 40px; }
footer .wrap { display: flex; gap: 24px; justify-content: space-between; flex-wrap: wrap; }

/* ---------- адаптив ---------- */
@media (max-width: 900px) {
  .hero-grid, .two-col { grid-template-columns: 1fr; }
  .aud { grid-template-columns: 1fr 1fr; }
  .aud div:nth-child(2n) { border-right: 0; }
  .account { margin-left: 0; }
}
@media (max-width: 560px) {
  .aud { grid-template-columns: 1fr; }
  .aud div { border-right: 0; border-bottom: 1px solid var(--line); }
  .grid { grid-template-columns: 1fr; }
  .stamp { display: none; }
  .radio-row { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- статистика и профиль ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tile { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 2px; background: var(--sheet); }
.tile b { font-family: var(--f-display); font-size: 1.4rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { font-size: .78rem; color: var(--ink-2); }
.tile.good b { color: var(--free); }
.tile.warn b { color: var(--accent); }
.tile.bad { border-color: var(--error); }
.tile.bad b { color: var(--error); }
.ava.big { width: 84px; height: 84px; font-size: 1.6rem; flex: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: .94rem; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.outcome-row { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 2px 0; } .facts dd { margin-bottom: 8px; } }
