/* Layout: рабочее приложение в фирменном стиле «Артикула» — графитовая боковая панель,
   как навигация на их сайте, светлая рабочая область; жёлтый из логотипа («И») — только
   на главных действиях и отметках, ИИ отмечен своим холодным цветом. */
:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eaedf1;
  --line: #e0e4ea;
  --line-strong: #cbd2db;
  --ink: #18202b;
  --ink-2: #4d5866;
  --ink-3: #85909d;
  --brand: #2b3646;
  --glow: rgba(255, 210, 26, .22);
  --accent: #ffd21a;
  --accent-hover: #f5c400;
  --accent-soft: #fff6cf;
  --accent-text: #8d6a00;
  --on-accent: #18202b;
  --side-bg: #232d3b;
  --side-ink: #eef1f5;
  --side-ink-2: #aab5c3;
  --side-ink-3: #75828f;
  --side-hover: rgba(255, 255, 255, .06);
  --side-on: rgba(255, 255, 255, .1);
  --side-line: rgba(255, 255, 255, .09);
  --ai: #4655d4;
  --ai-soft: #eceefd;
  --ok: #1d8a59;
  --ok-soft: #e2f3ea;
  --warn: #a8700f;
  --warn-soft: #fbf0d9;
  --bad: #c03a3a;
  --bad-soft: #fbe6e6;
  --shadow-sm: 0 1px 2px rgba(17, 19, 24, .05);
  --shadow: 0 1px 2px rgba(17, 19, 24, .04), 0 10px 30px -12px rgba(17, 19, 24, .14);
  --shadow-lg: 0 24px 60px -20px rgba(17, 19, 24, .35);
  --overlay: rgba(17, 19, 24, .42);
  --font: "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Onest", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e11; --surface: #14171c; --surface-2: #191d23; --surface-3: #20252c;
    --line: #252a32; --line-strong: #353b45;
    --ink: #eceef2; --ink-2: #a6acb7; --ink-3: #6f7682;
    --accent: #ffd84a; --accent-hover: #ffe27a; --accent-soft: #2c2810; --accent-text: #ffd84a; --on-accent: #161b22;
    --side-bg: #10151c; --side-line: rgba(255, 255, 255, .07); --glow: rgba(96, 120, 160, .30);
    --ai: #8f9bff; --ai-soft: #1c2041;
    --ok: #4cc58e; --ok-soft: #10261b; --warn: #e5ad4f; --warn-soft: #2c2210; --bad: #f37171; --bad-soft: #321516;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    --overlay: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e11; --surface: #14171c; --surface-2: #191d23; --surface-3: #20252c;
  --line: #252a32; --line-strong: #353b45;
  --ink: #eceef2; --ink-2: #a6acb7; --ink-3: #6f7682;
  --accent: #ffd84a; --accent-hover: #ffe27a; --accent-soft: #2c2810; --accent-text: #ffd84a; --on-accent: #161b22;
  --side-bg: #10151c; --side-line: rgba(255, 255, 255, .07); --glow: rgba(96, 120, 160, .30);
  --ai: #8f9bff; --ai-soft: #1c2041;
  --ok: #4cc58e; --ok-soft: #10261b; --warn: #e5ad4f; --warn-soft: #2c2210; --bad: #f37171; --bad-soft: #321516;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  transition: background .2s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Иконки ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 500; font-size: 14px;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ai { background: var(--ai-soft); border-color: transparent; color: var(--ai); }
.btn-ai:hover { background: var(--ai-soft); border-color: var(--ai); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

/* ---------- Значки ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; letter-spacing: .01em;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-mute { background: var(--surface-3); color: var(--ink-2); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-ai { background: var(--ai-soft); color: var(--ai); }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 500;
}
.kbd { font-size: 11px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* ---------- Вход: карточка по центру экрана ---------- */
.login {
  position: relative; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; overflow: hidden;
  padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background:
    radial-gradient(900px 520px at 50% -12%, var(--glow), transparent 70%),
    radial-gradient(700px 500px at 100% 110%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%),
    var(--bg);
}
.login::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse 60% 55% at 50% 40%, #000, transparent 75%);
}
.login-card {
  position: relative; width: 100%; max-width: 440px; display: grid; gap: 22px; padding: 36px 32px 30px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
}
.login-head { display: grid; justify-items: center; gap: 14px; text-align: center; }
.login-head .logo { font-size: 30px; }
.login-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.login-head p { margin: -6px 0 0; font-size: 14px; color: var(--ink-2); max-width: 34ch; }
.login-form { display: grid; gap: 16px; }
.role-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.role-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); }
.role-seg label { position: relative; cursor: pointer; }
.role-seg input { position: absolute; opacity: 0; pointer-events: none; }
.role-seg span {
  display: grid; place-items: center; height: 36px; border-radius: 9px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); transition: background .15s, color .15s, box-shadow .15s; text-align: center; padding: 0 4px;
}
.role-seg label:hover span { color: var(--ink); }
.role-seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.role-seg input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.role-hint { font-size: 13px; color: var(--ink-3); min-height: 20px; margin-top: -6px; }
.role-hint span { display: none; }
.login-form:has(input[value="admin"]:checked) .role-hint .h-admin,
.login-form:has(input[value="editor"]:checked) .role-hint .h-editor,
.login-form:has(input[value="reader"]:checked) .role-hint .h-reader { display: inline; }
.login-submit { height: 46px; font-size: 15px; font-weight: 600; border-radius: 12px; }
.login-facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 18px; border-top: 1px solid var(--line); text-align: center;
}
.login-facts div { display: grid; gap: 2px; }
.login-facts b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.login-facts span { font-size: 12px; color: var(--ink-3); }
.demo-note { position: relative; margin-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; }
.login-wrap { width: 100%; max-width: 440px; }

/* Логотип: тяжёлый гротеск, как на вывеске компании; «И» выделена жёлтым */
.logo {
  font-family: "Montserrat", "Onest", sans-serif; font-weight: 900; letter-spacing: .02em; line-height: 1;
  color: var(--ink); white-space: nowrap; text-transform: uppercase;
}
.logo .y { color: #ffd21a; }
:root:not([data-theme="dark"]) .login .logo .y { color: #f2c100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login .logo .y { color: #ffd21a; } }
.brand { display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
.brand .logo { font-size: 24px; }
.brand-sub { font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--side-ink-3); }

/* ---------- Поля ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 200px; padding: 12px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-hover); box-shadow: 0 0 0 3px var(--accent-soft); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Оболочка приложения ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--side-line);
  background: var(--side-bg); color: var(--side-ink); padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 20px;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); color-scheme: dark;
}
.side .brand { padding: 2px 10px 4px; }
.side .logo { color: #ffffff; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-ink-3); padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; line-height: 1.3; border-radius: 10px;
  text-decoration: none; color: var(--side-ink-2); font-weight: 500; font-size: 14px; transition: background .15s, color .15s;
  position: relative;
}
.nav a:hover { background: var(--side-hover); color: var(--side-ink); }
.nav a.on { background: var(--side-on); color: #ffffff; }
.nav a.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #ffd21a; }
.nav a.on .i { color: #ffd21a; }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--side-ink-3); font-variant-numeric: tabular-nums; }
.nav a .badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #ffd21a; color: #18202b; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.nav a .soon { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .04em; color: #c3c9ff; background: rgba(143, 155, 255, .16); padding: 2px 6px; border-radius: 5px; }
.nav a .dot { width: 8px; height: 8px; border-radius: 3px; flex: none; margin: 0 5px; }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--side-line); border-radius: 12px; background: rgba(255, 255, 255, .03); }
.me .who { min-width: 0; flex: 1; }
.me b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--side-ink); }
.me select { border: 0; background: transparent; padding: 0; font-size: 12px; color: var(--side-ink-2); cursor: pointer; max-width: 100%; }
.me select option { color: #18202b; background: #ffffff; }
.side .btn-ghost { color: var(--side-ink-2); }
.side .btn-ghost:hover { background: var(--side-hover); color: var(--side-ink); }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: #fff;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 12px;
  height: 64px; padding-right: max(24px, env(safe-area-inset-right, 0px)); padding-left: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top .menu-btn { display: none; }
.search-box { position: relative; flex: 1; max-width: 560px; }
.search-box .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search-box input { padding-left: 38px; padding-right: 54px; background: var(--surface); }
.search-box .kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.demo-chip { font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }

.page {
  width: 100%; max-width: 1180px; margin: 0 auto; padding-block: 28px 64px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: grid; gap: 24px; animation: rise .28s ease both;
}
@keyframes rise { from { transform: translateY(6px); } to { transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-weight: 800;
  font-family: var(--display); font-weight: 700; letter-spacing: -.02em; font-size: clamp(22px, 2.4vw, 28px); line-height: 1.2;
  margin: 0; letter-spacing: -.01em; text-wrap: balance;
}
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; margin-bottom: 10px; }
.crumbs a { text-decoration: none; color: var(--ink-2); }
.crumbs a:hover { color: var(--accent-text); }

/* ---------- Блоки ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.stack { display: grid; gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 18px 20px; display: grid; gap: 4px; }
.stat .label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.stat .value { font-family: var(--display); font-weight: 700; letter-spacing: -.02em; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--ink-3); }

.welcome {
  position: relative; overflow: hidden; padding: 28px 30px; border-radius: var(--radius);
  background: #232d3b; color: #f1f3f6; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center;
}
.welcome::after {
  content: ""; position: absolute; width: 420px; height: 420px; right: -120px; top: -220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 146, 186, .35), transparent 65%);
}

.welcome > * { position: relative; z-index: 1; }
.welcome h2 { margin: 0 0 6px; font-family: var(--display); font-weight: 700; letter-spacing: -.02em; font-size: 23px; letter-spacing: -.01em; }
.welcome p { margin: 0; color: rgba(241, 243, 246, .72); max-width: 60ch; }
.welcome .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #fff; }
.welcome .btn:hover { background: rgba(255, 255, 255, .14); }
.welcome .btn-primary { background: #ffd21a; border-color: #ffd21a; color: #18202b; }
.welcome .btn-primary:hover { background: #ffdc4a; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.sections { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1240px) { .sections { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .sections { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sections > :last-child:nth-child(odd) { grid-column: span 2; } }
@media (max-width: 420px) { .sections { grid-template-columns: minmax(0, 1fr); } .sections > :last-child:nth-child(odd) { grid-column: auto; } }
.sec-card {
  display: grid; gap: 14px; padding: 18px; text-decoration: none; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.sec-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.sec-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; }
.sec-card b { font-size: 15px; display: block; }
.sec-card .meta { font-size: 13px; color: var(--ink-3); }

.list { display: grid; }
.list-item {
  display: flex; gap: 14px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line);
  text-decoration: none; transition: background .15s; min-width: 0;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .body { min-width: 0; flex: 1; }
.list-item .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .end { display: flex; gap: 8px; align-items: center; flex: none; }
.file-ico {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none;
  font-size: 10px; font-weight: 800; letter-spacing: .03em; color: #fff;
}

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.k-card {
  display: grid; gap: 10px; padding: 18px; text-decoration: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .15s;
  align-content: start;
}
.k-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.k-card h4 { margin: 0; font-size: 15px; line-height: 1.35; }
.k-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.k-card .foot { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--ink-3); }
.k-id { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; font-weight: 500; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 11px; width: max-content; max-width: 100%; overflow-x: auto; }
.tabs button { height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Карточка знания ---------- */
.article { padding: 28px 32px; }
.article h1 { font-family: var(--display); font-weight: 700; letter-spacing: -.02em; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.22; margin: 10px 0 14px; letter-spacing: -.01em; text-wrap: balance; }
.meta-row { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--ink-3); }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.content { font-size: 16px; line-height: 1.7; color: var(--ink); max-width: 68ch; }
.content p { margin: 0 0 12px; }
.content ul { margin: 0 0 12px; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.content li { position: relative; padding-left: 22px; }
.content li::before { content: ""; position: absolute; left: 4px; top: .7em; width: 7px; height: 7px; border-radius: 2px; background: var(--accent-hover); }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.side-block { padding: 18px; display: grid; gap: 12px; }
.side-block h4 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.mini { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; background: var(--surface); cursor: pointer; text-align: left; width: 100%; transition: border-color .15s, background .15s; }
.mini:hover { border-color: var(--line-strong); background: var(--surface-2); }
.mini .body { min-width: 0; flex: 1; }
.mini b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini span { font-size: 12px; color: var(--ink-3); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; font-size: 14px; }
.notice .i { margin-top: 2px; }
.notice-warn { background: var(--warn-soft); color: var(--ink); }
.notice-warn .i { color: var(--warn); }
.notice-ai { background: var(--ai-soft); color: var(--ink); }
.notice-ai .i { color: var(--ai); }
.notice-mute { background: var(--surface-2); color: var(--ink-2); border: 1px dashed var(--line-strong); }

/* ---------- Таблица ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.person { display: flex; gap: 10px; align-items: center; min-width: 200px; }
.person b { display: block; font-size: 14px; }
.person span { font-size: 12px; color: var(--ink-3); }
td .select { height: 34px; width: auto; min-width: 150px; }

/* ---------- Поиск ---------- */
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.result { display: grid; gap: 6px; padding: 16px 20px; border-bottom: 1px solid var(--line); text-decoration: none; transition: background .15s; }
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--surface-2); }
.result .t { font-weight: 600; font-size: 15px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.result .s { font-size: 14px; color: var(--ink-2); }
.result .m { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; cursor: pointer; color: var(--ink-2); transition: border-color .15s, color .15s;
}
.chip-btn:hover { border-color: var(--accent-hover); color: var(--ink); }

/* ---------- ИИ ---------- */
.ai-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ai); }
.chat { display: grid; gap: 16px; padding: 22px; min-height: 360px; align-content: start; }
.msg { display: flex; gap: 12px; max-width: 760px; }
.msg.me { margin-left: auto; flex-direction: row-reverse; }
.bubble { padding: 12px 16px; border-radius: 14px; font-size: 15px; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.msg.me .bubble { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin: 0; }
.bubble ul { margin: 0 0 8px; padding-left: 18px; }
.cite {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; margin: 0 2px; border-radius: 6px;
  background: var(--ai-soft); color: var(--ai); font-size: 12px; font-weight: 600; text-decoration: none; vertical-align: 1px;
}
.cite:hover { background: var(--ai); color: #fff; }
.ai-avatar { width: 32px; height: 32px; border-radius: 10px; background: var(--ai-soft); color: var(--ai); display: grid; place-items: center; flex: none; }
.composer { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.composer .input { height: 44px; }
.thinking { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-3); font-size: 14px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--ai); animation: blink 1.2s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Загрузка ---------- */
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 28px; text-align: center;
  display: grid; gap: 8px; place-items: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent-hover); background: var(--accent-soft); }
.steps { display: grid; gap: 10px; }
.step { display: flex; gap: 12px; align-items: center; font-size: 14px; color: var(--ink-3); }
.step .mark { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; }
.step.done { color: var(--ink); }
.step.done .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.run { color: var(--ink); }
.step.run .mark { border-color: var(--ai); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.proposal { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; background: var(--surface); }
.proposal.off { opacity: .5; }
.proposal-head { display: flex; gap: 10px; align-items: flex-start; }
.proposal-head input { margin-top: 4px; accent-color: var(--brand); width: 16px; height: 16px; }
.proposal-head .t { font-weight: 600; flex: 1; }
.proposal .content { font-size: 14px; line-height: 1.6; }
.proposal .content li::before { background: var(--ai); }

/* ---------- Обучение ---------- */
.course { display: grid; gap: 10px; }
.lesson { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.lesson .n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-3); flex: none; }
.lesson.done .n { background: var(--ok-soft); color: var(--ok); }
.lesson.now .n { background: var(--accent); color: var(--on-accent); }
.lesson .body { flex: 1; min-width: 0; }
.lesson b { display: block; font-size: 14px; }
.lesson span { font-size: 13px; color: var(--ink-3); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress div { height: 100%; background: var(--accent); border-radius: 999px; }
.q { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.q b { font-size: 15px; }
.q button { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.q button:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.q button.right { border-color: var(--ok); background: var(--ok-soft); }
.q button.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q .explain { font-size: 13px; color: var(--ink-2); }

/* ---------- Модальные окна и уведомления ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: grid; place-items: center; padding: 20px; animation: fade .15s ease; backdrop-filter: blur(2px); }
@keyframes fade { from { background: transparent; } }
.modal {
  width: 100%; max-width: 640px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface);
  border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .2s ease;
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-body { padding: 18px 22px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; flex-wrap: wrap; }
.doc-preview { padding: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; line-height: 1.65; color: var(--ink-2); max-height: 220px; overflow-y: auto; white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

#toasts { position: fixed; z-index: 80; right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s ease; max-width: 360px; }
.toast .i { color: var(--ok); }

.empty { text-align: center; padding: 40px 20px; display: grid; gap: 8px; place-items: center; color: var(--ink-3); }
.footnote { font-size: 12px; color: var(--ink-3); text-align: center; padding-top: 8px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1080px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: 280px; height: auto;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
    padding-top: max(18px, env(safe-area-inset-top, 0px));
  }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 45; background: var(--overlay); }
  .top { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .top .menu-btn { display: inline-flex; }
  .page { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-top: 20px; }
  .article { padding: 20px; }
  .welcome { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .login-card { padding: 28px 20px 24px; border-radius: 18px; }
  .login-head .logo { font-size: 26px; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 22px; }
  .row-2 { grid-template-columns: minmax(0, 1fr); }
  .demo-chip, .search-box .kbd, .hide-sm { display: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .modal-foot .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Фирменный язык «печатного цеха»: острые углы, метки обреза, шкала CMYK,
   технические подписи моноширинным шрифтом, сдвинутая тень как смещение краски.
   Этот блок идёт последним и переопределяет скругления выше.
   ===================================================================== */
:root { --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace; --offset: #18202b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --offset: #000000; } }
:root[data-theme="dark"] { --offset: #000000; }

/* Полосы прокрутки скрыты, прокрутка работает */
html, body, * { scrollbar-width: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Острые углы везде */
.btn, .input, .select, .textarea, .panel, .k-card, .sec-card, .list-item, .tabs, .tabs button, .pill, .tag, .modal,
.toast, .avatar, .mini, .notice, .file-ico, .sec-icon, .chip-btn, .bubble, .cite, .drop, .proposal, .lesson, .lesson .n,
.q, .q button, .role-seg, .role-seg span, .login-card, .me, .welcome, .doc-preview, .kbd, .demo-chip, .nav a,
.nav a .badge, .nav a .soon, .progress, .progress div, .ai-avatar, .step .mark, .result, :focus-visible { border-radius: 0; }

/* Технические подписи */
.eyebrow, .nav-label, .k-id, .tag, .pill, .kbd, .demo-chip, .brand-sub, .stat .label, .meta-row, .kv dt, .role-label,
.nav a .count, .nav a .soon, .nav a .badge, .login-facts span, .result .m, .file-ico, .side-block h4, .cite, .ai-badge {
  font-family: var(--mono); letter-spacing: .02em;
}
.pill, .tag { font-size: 11px; text-transform: uppercase; font-weight: 600; height: 22px; padding: 0 8px; }
.pill::before { border-radius: 0; width: 5px; height: 5px; }
.stat .label { font-size: 11.5px; text-transform: uppercase; color: var(--ink-3); }
.stat .value { font-size: 34px; }
.k-id { font-size: 11.5px; }
.meta-row { font-size: 12px; }

/* Метки обреза по углам: .crop рисует их снаружи элемента */
.crop { position: relative; }
.crop::after {
  content: ""; position: absolute; inset: -14px; pointer-events: none; z-index: 0; --m: var(--ink-3);
  background:
    linear-gradient(var(--m), var(--m)) left 0 top 14px / 9px 1px no-repeat,
    linear-gradient(var(--m), var(--m)) left 14px top 0 / 1px 9px no-repeat,
    linear-gradient(var(--m), var(--m)) right 0 top 14px / 9px 1px no-repeat,
    linear-gradient(var(--m), var(--m)) right 14px top 0 / 1px 9px no-repeat,
    linear-gradient(var(--m), var(--m)) left 0 bottom 14px / 9px 1px no-repeat,
    linear-gradient(var(--m), var(--m)) left 14px bottom 0 / 1px 9px no-repeat,
    linear-gradient(var(--m), var(--m)) right 0 bottom 14px / 9px 1px no-repeat,
    linear-gradient(var(--m), var(--m)) right 14px bottom 0 / 1px 9px no-repeat;
}
.k-card, .sec-card { position: relative; }
.k-card::after, .sec-card::after {
  content: ""; position: absolute; inset: -8px; pointer-events: none; opacity: 0; transition: opacity .15s; --m: var(--accent-hover);
  background:
    linear-gradient(var(--m), var(--m)) left 0 top 8px / 6px 1.5px no-repeat,
    linear-gradient(var(--m), var(--m)) left 8px top 0 / 1.5px 6px no-repeat,
    linear-gradient(var(--m), var(--m)) right 0 top 8px / 6px 1.5px no-repeat,
    linear-gradient(var(--m), var(--m)) right 8px top 0 / 1.5px 6px no-repeat,
    linear-gradient(var(--m), var(--m)) left 0 bottom 8px / 6px 1.5px no-repeat,
    linear-gradient(var(--m), var(--m)) left 8px bottom 0 / 1.5px 6px no-repeat,
    linear-gradient(var(--m), var(--m)) right 0 bottom 8px / 6px 1.5px no-repeat,
    linear-gradient(var(--m), var(--m)) right 8px bottom 0 / 1.5px 6px no-repeat;
}
.k-card:hover::after, .sec-card:hover::after { opacity: 1; }
.k-card:hover, .sec-card:hover { transform: none; box-shadow: none; border-color: var(--line-strong); }

/* Шкала CMYK */
.cmyk { display: inline-flex; gap: 0; height: 8px; }
.cmyk i { width: 18px; height: 8px; display: block; }
.cmyk i:nth-child(1) { background: #00aeef; }
.cmyk i:nth-child(2) { background: #ec008c; }
.cmyk i:nth-child(3) { background: #ffd21a; }
.cmyk i:nth-child(4) { background: #18202b; outline: 1px solid rgba(255, 255, 255, .12); outline-offset: -1px; }

/* Кнопки: сдвинутая тень, как смещение краски при печати */
.btn-primary { box-shadow: 3px 3px 0 var(--offset); transition: transform .08s, box-shadow .08s, background .15s; }
.btn-primary:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--offset); }
.btn-primary:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--offset); }
.welcome .btn-primary { box-shadow: 3px 3px 0 #000000; }

/* Вход: лист на режущем коврике */
.login::before { opacity: .7; background-size: 40px 40px; mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000, transparent 80%); }
.login-card { box-shadow: 10px 10px 0 color-mix(in srgb, var(--offset) 14%, transparent); backdrop-filter: none; background: var(--surface); }
.login-card > * { position: relative; z-index: 1; }
.login-top { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
.role-seg { background: var(--surface-3); }
.role-seg input:checked + span { background: var(--ink); color: var(--bg); box-shadow: none; }

/* Разделы: цветная полоса сверху вместо скруглённой плашки */
.sec-card { box-shadow: inset 0 3px 0 var(--c, var(--accent)); padding-top: 20px; }
.sec-card .sec-icon { background: transparent !important; width: auto; height: auto; justify-content: start; place-items: start; }
.sec-card b { font-size: 15.5px; letter-spacing: -.01em; }
.sec-card .meta { font-family: var(--mono); font-size: 11.5px; }

/* Приветствие: графитовый лист со шкалой CMYK, без размытых пятен */
.welcome { overflow: visible; }
.welcome::after { display: none; }
.welcome .cmyk { position: absolute; top: 0; right: 28px; }
.welcome h2 { font-size: 26px; }

/* Боковая панель */
.nav a.on::before { border-radius: 0; left: -14px; width: 3px; }
.avatar { font-family: var(--mono); font-size: 11px; }

/* Списки и карточки знаний */
.k-card { border-top: 2px solid var(--line-strong); }
.k-card:hover { border-top-color: var(--accent-hover); }
.content li::before { border-radius: 0; width: 6px; height: 6px; }
.bubble { border-left: 3px solid var(--ai); }
.msg.me .bubble { border-left: 0; border-right: 3px solid var(--accent); }
.notice { border-left: 3px solid currentColor; }
.notice-warn { border-left-color: var(--warn); }
.notice-ai { border-left-color: var(--ai); }
.notice-mute { border-left: 3px solid var(--line-strong); }
.toast { box-shadow: 4px 4px 0 color-mix(in srgb, var(--offset) 25%, transparent); }
.modal { box-shadow: 12px 12px 0 color-mix(in srgb, #000 22%, transparent); }
.tabs button.on { background: var(--ink); color: var(--bg); box-shadow: none; }

.file-ico { font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0; color: #ffffff; }
.mini .file-ico { font-size: 8.5px; }
.sec-card .meta { display: block; margin-top: 4px; }

/* =====================================================================
   Срез и скругление: контейнеры мягко скруглены, выбранное и главное
   получают срезанный угол, как деталь после плоттерной резки.
   ===================================================================== */
:root { --r: 10px; --r-sm: 8px; --cut: 9px; --cut-sm: 6px; }
.cut { clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); }

/* Скругления контейнеров и полей */
.panel, .k-card, .sec-card, .modal, .notice, .doc-preview, .proposal, .lesson, .q, .drop, .toast, .me, .mini, .bubble,
.welcome, .result { border-radius: var(--r); }
.input, .select, .textarea, .btn, .chip-btn, .q button, .tabs, .role-seg, .kbd, .progress, .progress div { border-radius: var(--r-sm); }
.login-card { border-radius: 14px; }
.list-item { border-radius: 0; }
.sec-card { box-shadow: inset 0 3px 0 var(--c, var(--accent)); }

/* Срезанный угол у выбранного и главного */
.btn-primary, .role-seg input:checked + span, .tabs button.on, .nav a.on, .avatar, .file-ico, .nav a .badge,
.lesson.now .n, .lesson.done .n, .ai-avatar, .msg.me .bubble {
  border-radius: 0;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.pill, .tag, .cite, .nav a .soon, .demo-chip, .btn-sm.btn-primary {
  border-radius: 0;
  clip-path: polygon(var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)), calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm));
}
.nav a.on::before { display: none; }
.nav a.on { background: rgba(255, 255, 255, .1); color: #ffffff; }
.nav a.on .i { color: #ffd21a; }

/* Без жёстких теней: срез и так выделяет главное */
.btn-primary, .btn-primary:hover, .btn-primary:active, .welcome .btn-primary { box-shadow: none; }
.btn-primary:hover { transform: none; }
.btn-primary:active { transform: translateY(1px); }
.login-card { box-shadow: var(--shadow-lg); }
.toast { box-shadow: var(--shadow-lg); }
.modal { box-shadow: var(--shadow-lg); }

/* Сообщения чата: у своего сообщения срез, у ответа ИИ мягкая плашка с линией */
.msg.me .bubble { border-right: 0; }
.bubble { border-left: 3px solid var(--ai); border-radius: 4px var(--r) var(--r) 4px; }
.msg.me .bubble { border-left: 0; }
.notice { border-radius: 4px var(--r) var(--r) 4px; }

/* Сегменты и вкладки: плашка прямая и спокойная, выбранная кнопка срезанная и тёмная */
.role-seg, .tabs { padding: 4px; }
.role-seg span, .tabs button { border-radius: 6px; }
.k-card { border-top: 1px solid var(--line); }
.k-card:hover { border-color: var(--line-strong); }

/* =====================================================================
   Версия 3. Прямые блоки без скруглений. Срез только на внешнем углу
   композиции, в ту сторону, где она заканчивается. Информация лежит на
   странице строками, без карточек-коробок.
   ===================================================================== */
:root { --cut: 14px; --cut-sm: 8px; --tl: 0px; --tr: 0px; --br: 0px; --bl: 0px; }

/* Все углы прямые */
.panel, .k-card, .sec-card, .modal, .notice, .doc-preview, .proposal, .lesson, .q, .drop, .toast, .me, .mini, .bubble,
.welcome, .result, .input, .select, .textarea, .btn, .chip-btn, .q button, .tabs, .tabs button, .role-seg, .role-seg span,
.kbd, .progress, .progress div, .login-card, .pill, .tag, .cite, .avatar, .file-ico, .sec-icon, .ai-avatar, .demo-chip,
.nav a, .nav a .badge, .nav a .soon, .lesson .n, .step .mark, .list-item { border-radius: 0; clip-path: none; }

/* Механизм среза: углы задаются переменными --tl --tr --br --bl */
.panel, .login-card, .modal, .btn-primary, .role-seg input:checked + span, .tabs button.on, .nav a.on, .avatar,
.role-panel, .chat-panel, .notice, .proposal, .bubble, .q, .lesson.now, .hero-form {
  clip-path: polygon(var(--tl) 0, calc(100% - var(--tr)) 0, 100% var(--tr), 100% calc(100% - var(--br)), calc(100% - var(--br)) 100%, var(--bl) 100%, 0 calc(100% - var(--bl)), 0 var(--tl));
}
/* Одиночные элементы: срез справа сверху */
.btn-primary, .role-seg input:checked + span, .tabs button.on, .nav a.on, .avatar { --tr: var(--cut-sm); }
.login-card, .modal { --tr: var(--cut); --bl: var(--cut); }
.notice, .proposal, .bubble, .q, .lesson.now { --tr: var(--cut-sm); }
.msg.me .bubble { --tr: 0px; --tl: var(--cut-sm); }

/* Панели без рамок: их видно по фону, а срез не обрывает линию рамки */
.panel { border: 0; box-shadow: none; }
.page > .panel { --tr: var(--cut); }
.grid-main > .panel:first-child, .grid-main > form > .panel:first-child { --tl: var(--cut); }
.grid-main > :last-child > .panel:first-child { --tr: var(--cut); }
.grid-main > :last-child > .panel:last-child:not(:first-child) { --br: var(--cut); }
.grid-main > :last-child > .panel:only-child { --tr: var(--cut); --br: var(--cut); }
:root { --bg: #eef0f3; }
.login-card { border: 0; }
.notice { border: 0; }
.bubble { border: 0; background: var(--surface-2); }
.msg.me .bubble { background: var(--ink); color: var(--bg); }
.toast { border-radius: 0; }

/* Метки обреза у карточек и разделов больше не нужны: карточек-коробок нет */
.k-card::after, .sec-card::after { display: none; }

/* ---------- Главная: поиск, оглавление, блок под роль ---------- */
.home { gap: 40px; padding-top: 40px; }
.hero-search { display: grid; gap: 14px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-form {
  display: flex; align-items: center; gap: 14px; padding: 6px 6px 6px 22px; background: var(--surface);
  border-bottom: 3px solid var(--ink); --tr: var(--cut);
}
.hero-form .i { color: var(--ink-3); }
.hero-form input {
  flex: 1; min-width: 0; border: 0; background: transparent; height: 58px; font-size: clamp(18px, 2vw, 24px);
  font-weight: 500; letter-spacing: -.01em; color: var(--ink); outline: none;
}
.hero-form input::placeholder { color: var(--ink-3); }
.hero-form .btn { height: 48px; padding: 0 22px; font-size: 15px; }
.hero-tips { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 14px; color: var(--ink-3); }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink-2); cursor: pointer; font-size: 14px; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; }
.link-btn:hover { color: var(--ink); text-decoration-color: var(--accent-hover); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.block-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.block-head a, .block-head button { font-size: 14px; color: var(--ink-2); text-decoration: none; background: none; border: 0; cursor: pointer; }
.block-head a:hover { color: var(--ink); }

.toc-row {
  display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 18px 0;
  border-bottom: 1px solid var(--line); text-decoration: none; transition: padding .15s;
}
.toc-mark { width: 6px; align-self: stretch; background: var(--c); }
.toc-name { display: block; font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.toc-subs { display: block; margin-top: 4px; font-size: 13.5px; color: var(--ink-3); }
.toc-go { color: var(--ink-3); transition: transform .15s, color .15s; }
.toc-row:hover .toc-name { text-decoration: underline; text-decoration-color: var(--accent-hover); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.toc-row:hover .toc-go { color: var(--ink); transform: translateX(3px); }

.line-row { display: flex; gap: 16px; align-items: baseline; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.line-row .t { font-weight: 600; font-size: 15px; }
.line-row .s { display: block; font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.line-row .p { display: block; font-size: 14px; color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.line-row:hover .t { text-decoration: underline; text-decoration-color: var(--accent-hover); text-underline-offset: 4px; }
.line-row .when { font-size: 13px; color: var(--ink-3); white-space: nowrap; }

.role-panel { padding: 22px; display: grid; gap: 18px; background: var(--surface); --tr: var(--cut); --bl: var(--cut); }
.role-panel h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.role-panel .hint { font-size: 13px; color: var(--ink-3); margin-top: -10px; }
.gap-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.gap-row:last-child { border-bottom: 0; }
.gap-row b { font-weight: 600; }
.gap-row .times { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; font-family: var(--mono); }
.fill-row { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.fill-row .bar { height: 4px; background: var(--surface-3); }
.fill-row .bar i { display: block; height: 100%; background: var(--accent); }
.fill-row .lbl { display: flex; justify-content: space-between; }

/* Раздел: строки вместо плиток */
.sub-tabs { margin-top: 4px; }

@media (max-width: 1080px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .home { padding-top: 20px; gap: 28px; }
  .hero-form { padding-left: 14px; gap: 10px; }
  .hero-form input { height: 50px; font-size: 17px; }
  .hero-form .btn { padding: 0 14px; height: 42px; }
  .hero-form .btn span { display: none; }
  .toc-name { font-size: 17px; }
  .line-row { flex-direction: column; gap: 4px; }
}

.cite { font-family: var(--font); letter-spacing: 0; height: auto; padding: 1px 8px; font-size: 13px; }

/* =====================================================================
   Версия 4. Плитки прямые. Группа плиток читается как один лист,
   у которого срезаны два внешних угла: правый верхний и левый нижний.
   Срез получает только плитка, которая стоит в этом углу группы.
   ===================================================================== */
.panel, .stat, .sec-card, .k-card, .welcome, .login-card, .modal, .role-panel, .hero-form, .notice, .proposal,
.bubble, .q, .lesson.now, .btn-primary, .role-seg input:checked + span, .tabs button.on, .nav a.on, .avatar {
  --tl: 0px; --tr: 0px; --br: 0px; --bl: 0px;
  clip-path: polygon(var(--tl) 0, calc(100% - var(--tr)) 0, 100% var(--tr), 100% calc(100% - var(--br)), calc(100% - var(--br)) 100%, var(--bl) 100%, 0 calc(100% - var(--bl)), 0 var(--tl));
}
/* Плитки без рамок: срез не должен обрывать линию */
.sec-card, .k-card { border: 0; background: var(--surface); }
.welcome { overflow: visible; }

/* Одиночные блоки и кнопки: срез по той же диагонали */
.welcome, .login-card, .modal { --tr: var(--cut); --bl: var(--cut); }
.btn-primary, .role-seg input:checked + span, .tabs button.on, .nav a.on, .avatar { --tr: var(--cut-sm); --bl: var(--cut-sm); }
.notice, .proposal, .bubble, .q, .lesson.now { --tr: var(--cut-sm); }
.msg.me .bubble { --tr: 0px; --tl: var(--cut-sm); }

/* Цифры: 4 колонки, на узких экранах 2 */
.stats > :nth-child(4) { --tr: var(--cut); }
.stats > :nth-child(1) { --bl: var(--cut); }
@media (max-width: 1080px) {
  .stats > :nth-child(4) { --tr: 0px; }
  .stats > :nth-child(1) { --bl: 0px; }
  .stats > :nth-child(2) { --tr: var(--cut); }
  .stats > :nth-child(3) { --bl: var(--cut); }
}

/* Разделы: 5 колонок, затем 3, 2 и 1 */
.sections > :nth-child(5) { --tr: var(--cut); }
.sections > :nth-child(1) { --bl: var(--cut); }
@media (max-width: 1240px) {
  .sections > :nth-child(5) { --tr: 0px; }
  .sections > :nth-child(1) { --bl: 0px; }
  .sections > :nth-child(3) { --tr: var(--cut); }
  .sections > :nth-child(4) { --bl: var(--cut); }
}
@media (max-width: 760px) {
  .sections > :nth-child(3) { --tr: 0px; }
  .sections > :nth-child(4) { --bl: 0px; }
  .sections > :nth-child(2) { --tr: var(--cut); }
  .sections > :nth-child(5) { --bl: var(--cut); }
}
@media (max-width: 420px) {
  .sections > :nth-child(2) { --tr: 0px; }
  .sections > :nth-child(1) { --tr: var(--cut); }
}

/* Карточки знаний в разделе: 3 колонки, затем 2 и 1 */
.cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-grid > :nth-child(3), .cards-grid > :last-child:nth-child(-n+2) { --tr: var(--cut); }
.cards-grid > :nth-child(3n+1):nth-last-child(-n+3) { --bl: var(--cut); }
@media (max-width: 1240px) {
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-grid > :nth-child(3), .cards-grid > :last-child:nth-child(-n+2) { --tr: 0px; }
  .cards-grid > :nth-child(3n+1):nth-last-child(-n+3) { --bl: 0px; }
  .cards-grid > :nth-child(2), .cards-grid > :only-child { --tr: var(--cut); }
  .cards-grid > :nth-child(2n+1):nth-last-child(-n+2) { --bl: var(--cut); }
}
@media (max-width: 600px) {
  .cards-grid { grid-template-columns: minmax(0, 1fr); }
  .cards-grid > :nth-child(2), .cards-grid > :nth-child(2n+1):nth-last-child(-n+2) { --tr: 0px; --bl: 0px; }
  .cards-grid > :first-child { --tr: var(--cut); }
  .cards-grid > :last-child { --bl: var(--cut); }
}

/* Двухколоночные экраны: левая колонка как один лист, правая как стопка */
.grid-main > .panel:first-child, .grid-main > form > .panel:first-child { --tl: 0px; --bl: var(--cut); }
.grid-main > :last-child > .panel:first-child { --tr: var(--cut); }
.grid-main > :last-child > .panel:last-child:not(:first-child) { --br: 0px; }
.grid-main > :last-child > .panel:only-child { --tr: var(--cut); --br: 0px; }
.page > .panel { --tr: var(--cut); --bl: var(--cut); }
@media (max-width: 1080px) {
  .grid-main > .panel:first-child { --bl: 0px; --tr: var(--cut); }
  .grid-main > :last-child > .panel:first-child { --tr: 0px; }
  .grid-main > :last-child > .panel:last-child { --bl: var(--cut); }
}

/* Плитки разделов: цветная полоса сверху, иконка без подложки */
.sec-card { box-shadow: inset 0 3px 0 var(--c, var(--accent)); }
.sec-card .sec-icon { background: transparent !important; }
.k-card { box-shadow: inset 0 2px 0 var(--line-strong); }
.k-card:hover { box-shadow: inset 0 2px 0 var(--accent-hover); }

/* Переключатель темы внизу боковой панели */
.theme-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--side-line); background: rgba(255, 255, 255, .03); }
.theme-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; border: 0; background: transparent;
  color: var(--side-ink-2); font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.theme-seg button:hover { color: var(--side-ink); background: var(--side-hover); }
.theme-seg button.on {
  background: #ffd21a; color: #18202b;
  clip-path: polygon(0 0, calc(100% - var(--cut-sm)) 0, 100% var(--cut-sm), 100% 100%, var(--cut-sm) 100%, 0 calc(100% - var(--cut-sm)));
}
.theme-seg button:focus-visible { outline: 2px solid #ffd21a; outline-offset: 1px; }

/* Кликабельные плитки с цифрами */
.stat-link { position: relative; text-decoration: none; transition: background .15s; }
.stat-link:hover { background: var(--surface-2); }
.stat-link .stat-go { position: absolute; right: 18px; bottom: 16px; color: var(--ink-3); transition: transform .15s, color .15s; }
.stat-link:hover .stat-go { color: var(--ink); transform: translateX(3px); }
.stat-link:hover .value { color: var(--ink); }

/* Настройки: строка = название и пояснение слева, управление справа */
.settings { padding: 0; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 20px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.set-info { display: grid; gap: 4px; min-width: 0; flex: 1 1 280px; }
.set-info > b { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.set-info > span { font-size: 13.5px; color: var(--ink-3); }
.set-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.set-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.set-head span { display: block; margin-top: 4px; font-size: 13.5px; color: var(--ink-3); }
.set-dot { width: 10px; height: 10px; flex: none; }
.set-subs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; padding-left: 20px; }
.set-subs span { font-size: 13px; color: var(--ink-2); background: var(--surface-3); padding: 3px 9px; }
.set-person { display: flex; align-items: center; gap: 12px; }
.set-person b { display: block; font-size: 14px; }
.set-person span { font-size: 13px; color: var(--ink-3); }
@media (max-width: 600px) { .set-row { padding: 16px; } .set-head { padding: 16px; } }

/* Пункт «Разделы» с вложенным списком */
.nav-group {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; width: 100%; border: 0; background: transparent;
  color: var(--side-ink-2); font: inherit; font-weight: 500; font-size: 14px; cursor: pointer; text-align: left; transition: background .15s, color .15s;
}
.nav-group:hover { background: var(--side-hover); color: var(--side-ink); }
.nav-group.has-on { color: #ffffff; }
.nav-group.has-on > .i:first-child { color: #ffd21a; }
.nav-group .chev { margin-left: auto; display: inline-flex; color: var(--side-ink-3); transition: transform .18s; }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-sub { display: grid; gap: 1px; margin: 2px 0 6px 19px; padding-left: 12px; border-left: 1px solid var(--side-line); }
.nav-sub a { min-height: 32px; padding: 6px 10px; font-size: 13.5px; }
.nav-sub a .dot { width: 7px; height: 7px; margin: 0 2px 0 0; }
.nav-sub a.on { background: var(--side-on); }

/* Низ боковой панели: разделитель, профиль без рамки, понятный выход */
.side-foot {
  margin: 16px -14px 0; padding: 16px 14px 0; border-top: 1px solid var(--side-line); gap: 14px;
  margin-left: calc(-1 * max(14px, env(safe-area-inset-left, 0px)));
  padding-left: max(14px, env(safe-area-inset-left, 0px));
}
.me { border: 0; background: transparent; padding: 0 4px; gap: 12px; }
.me b { font-size: 14px; }
.me select { font-size: 12.5px; color: var(--side-ink-2); margin-top: 2px; }
.logout-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 8px 10px; border: 0;
  background: transparent; color: var(--side-ink-2); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(240, 107, 107, .12); color: #ff9a9a; }
.logout-btn:focus-visible { outline: 2px solid #ffd21a; outline-offset: 1px; }

.side-bottom { margin-top: auto; display: grid; }

/* Низ боковой панели закреплён: всегда виден целиком, меню прокручивается над ним */
.side { padding-bottom: 0; }
.side-bottom {
  position: sticky; bottom: 0; z-index: 2; background: var(--side-bg);
  margin: auto -14px 0; padding: 12px 14px max(16px, env(safe-area-inset-bottom, 0px));
  margin-left: calc(-1 * max(14px, env(safe-area-inset-left, 0px))); padding-left: max(14px, env(safe-area-inset-left, 0px));
}
.side-bottom .side-foot { margin: 14px -14px 0; margin-left: calc(-1 * max(14px, env(safe-area-inset-left, 0px))); }

/* Низ панели: аватар и иконка выхода по одной линии с иконками меню, больше воздуха снизу */
.side-bottom .me { padding: 0 10px; }
.side-bottom .logout-btn { padding-left: 10px; margin-top: -4px; }
.side-bottom { padding-bottom: max(22px, env(safe-area-inset-bottom, 0px)); }

/* Профиль на всю ширину панели, выбор роли тянется до правого края */
.side-bottom .me { display: flex; width: 100%; padding: 8px 10px; transition: background .15s; }
.side-bottom .me:hover { background: var(--side-hover); }
.side-bottom .me .who { flex: 1; min-width: 0; display: grid; }
.side-bottom .me select { width: 100%; padding-right: 0; }
