/* AI Study — дизайн-система.
   Светлая тема по умолчанию, тёмная переключается через [data-theme="dark"]. */

:root {
  --accent: #6C5CE7;
  --accent-2: #4EA8DE;
  --accent-soft: rgba(108, 92, 231, .10);
  --accent-2-soft: rgba(78, 168, 222, .12);

  --bg: #FBFBFD;
  --bg-soft: #F4F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --surface-3: #EEF0F7;
  --line: #E6E8F0;
  --line-strong: #D6DAE6;

  --text: #14161D;
  --text-soft: #3A3F4F;
  --muted: #6C7286;
  --muted-2: #9AA0B2;

  --success: #16A34A;
  --success-soft: rgba(22, 163, 74, .10);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, .09);
  --warning: #B45309;
  --warning-soft: rgba(180, 83, 9, .10);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;

  --shadow-xs: 0 1px 2px rgba(20, 25, 45, .04);
  --shadow-sm: 0 2px 8px rgba(20, 25, 45, .06);
  --shadow: 0 12px 32px rgba(20, 25, 45, .08);
  --shadow-lg: 0 24px 60px rgba(20, 25, 45, .12);

  --font: "Inter", "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: .22s;
}

[data-theme="dark"] {
  --accent: #8B7BF0;
  --accent-2: #5AB6E8;
  --accent-soft: rgba(139, 123, 240, .16);
  --accent-2-soft: rgba(90, 182, 232, .14);

  --bg: #0E1015;
  --bg-soft: #14171F;
  --surface: #171A22;
  --surface-2: #1D212B;
  --surface-3: #232833;
  --line: #262B37;
  --line-strong: #333A49;

  --text: #ECEEF5;
  --text-soft: #C9CEDB;
  --muted: #8B93A7;
  --muted-2: #6B7286;

  --success: #4ADE80;
  --success-soft: rgba(74, 222, 128, .14);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .13);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, .13);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

h1, h2, h3, h4, h5 { margin: 0 0 .5em; line-height: 1.2; letter-spacing: -.022em; font-weight: 700; }
h1 { font-size: clamp(2rem, 4.2vw, 3.15rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.15rem); font-weight: 780; letter-spacing: -.03em; }
h3 { font-size: 1.16rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1rem; color: var(--text-soft); }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--accent-2); }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.container { width: min(1180px, 92vw); margin-inline: auto; }
.container-narrow { width: min(760px, 92vw); margin-inline: auto; }
.muted { color: var(--muted); }
.small { text-align: center; font-size: .875rem; }
.tiny { font-size: .78rem; }
.strong { font-weight: 650; color: var(--text); }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 20px; }
/* Элементы сетки не должны раздуваться под контент (графики, таблицы) */
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 20px; height: 68px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.06rem; color: var(--text); letter-spacing: -.02em; }
.logo:hover { color: var(--text); }
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: .95rem; box-shadow: 0 4px 12px var(--accent-soft);
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  color: var(--muted); font-size: .93rem; font-weight: 520;
  padding: 8px 12px; border-radius: var(--radius-sm); transition: all var(--dur) var(--ease);
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); }
.nav-links a.active { color: var(--text); background: var(--surface-2); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.burger {
  display: none; background: none; border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; cursor: pointer;
}
.mobile-menu { display: none; border-top: 1px solid var(--line); background: var(--surface); }
.mobile-menu.open { display: block; }
.mobile-menu a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); color: var(--text-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius); border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: .94rem; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              filter var(--dur) var(--ease), background var(--dur) var(--ease);
  box-shadow: 0 2px 10px var(--accent-soft);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); color: #fff; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: none; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-soft { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn-soft:hover { background: var(--accent-soft); filter: brightness(.98); color: var(--accent); }
.btn-danger { background: var(--danger); box-shadow: none; }
.btn-sm { padding: 7px 13px; font-size: .85rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-xs);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.card-hover:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.card-soft { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { margin: 0; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: .8rem; color: var(--muted); font-weight: 550;
}
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.pill-ok { background: var(--success-soft); color: var(--success); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--accent-soft); color: var(--accent); }
.pill-warn { background: var(--warning-soft); color: var(--warning); }
.pill-muted { background: var(--surface-3); color: var(--muted); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: .95rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%236C7286' d='M2 4l4 4 4-4z'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.help { font-size: .79rem; color: var(--muted); margin-top: 5px; }
.errorlist { color: var(--danger); font-size: .82rem; list-style: none; padding: 0; margin: 6px 0 0; }
.errorlist li { margin-bottom: 3px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.doc-files-list { display: block; margin-top: 7px; font-weight: 500; line-height: 1.45; }
input[type=file] { padding: 9px 12px; background: var(--surface-2); font-size: .88rem; }
.checkbox { display: flex; align-items: flex-start; gap: 9px; }
.checkbox input { width: auto; margin-top: 4px; accent-color: var(--accent); }
.checkbox label { margin: 0; font-weight: 500; font-size: .92rem; color: var(--text-soft); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 13px 16px; border-radius: var(--radius); font-size: .91rem; margin-bottom: 18px;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert-info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert p { color: inherit; }

/* ---------- Hero ---------- */
.hero { padding: 84px 0 64px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -35% 25% auto -15%; height: 620px;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  filter: blur(30px); pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; inset: 10% -20% auto 45%; height: 520px;
  background: radial-gradient(closest-side, var(--accent-2-soft), transparent);
  filter: blur(40px); pointer-events: none;
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }
.hero h1 { margin-bottom: 20px; letter-spacing: -.035em; }
.hero .lead { font-size: 1.08rem; max-width: 560px; color: var(--muted); }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-note { margin-top: 18px; font-size: .84rem; color: var(--muted-2); }
.gradient-text {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Hero visual */
.hero-visual {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); padding: 18px; position: relative;
}
.hero-visual-bar { display: flex; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.hero-visual-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); display: block; }
.mock-line { height: 10px; border-radius: 6px; background: var(--surface-3); margin-bottom: 10px; }
.mock-chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.mock-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 12px; background: var(--surface-2); }
.mock-answer { font-size: .86rem; color: var(--muted); margin-top: 8px; }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section-tight { padding: 44px 0; }
.section-alt { background: var(--bg-soft); border-block: 1px solid var(--line); }
.section-head { max-width: 640px; margin: 0 auto 44px; text-align: center; }
.section-head p { color: var(--muted); font-size: 1.02rem; }
.eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 12px;
}

/* Feature cards */
.feature { display: flex; gap: 16px; align-items: flex-start; }
.feature-icon {
  width: 44px; height: 44px; flex: none; border-radius: 13px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 1.15rem;
}
.feature:nth-child(2n) .feature-icon { background: var(--accent-2-soft); color: var(--accent-2); }
.feature h3 { margin-bottom: 6px; font-size: 1.05rem; }
.feature p { font-size: .92rem; color: var(--muted); margin: 0; }

/* Steps */
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.step { position: relative; padding-top: 46px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 0; left: 0; width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 4px 14px var(--accent-soft);
}
.step h3 { font-size: 1.02rem; margin-bottom: 6px; }
.step p { font-size: .91rem; color: var(--muted); margin: 0; }

/* Pricing */
.plan {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px; display: flex; flex-direction: column; position: relative;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.plan:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan-tag {
  position: absolute; top: -12px; right: 22px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: .74rem; font-weight: 700; padding: 4px 12px; border-radius: 999px;
}
.plan-name { font-weight: 700; font-size: 1.02rem; }
.plan-price { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; margin: 10px 0 2px; }
.plan-price small { font-size: .9rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan ul { list-style: none; padding: 0; margin: 16px 0 24px; flex: 1; }
.plan li { padding: 7px 0 7px 26px; position: relative; color: var(--muted); font-size: .91rem; }
.plan li::before { content: "✓"; position: absolute; left: 0; color: var(--success); font-weight: 700; }

/* FAQ */
.faq { max-width: 760px; margin-inline: auto; }
.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden;
}
.faq summary {
  cursor: pointer; padding: 16px 20px; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; font-weight: 400; }
.faq details[open] summary::after { content: "−"; }
.faq .faq-body { padding: 0 20px 18px; color: var(--muted); font-size: .93rem; }

/* CTA band */
.cta-band {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-xl); padding: 52px 44px; color: #fff; text-align: center;
  position: relative; overflow: hidden;
}
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.88); max-width: 560px; margin-inline: auto; }
.cta-band .btn { background: #fff; color: var(--accent); }
.cta-band .btn:hover { color: var(--accent); }

/* ---------- App shell (кабинет) ---------- */
.app-shell { display: grid; grid-template-columns: 258px 1fr; min-height: calc(100vh - 68px); }
.side {
  border-right: 1px solid var(--line); background: var(--bg-soft);
  padding: 22px 16px 40px; position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
}
.side-title {
  font-size: .71rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted-2); margin: 20px 10px 8px; font-weight: 700;
}
.side a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius);
  color: var(--muted); font-size: .91rem; font-weight: 520;
  transition: all var(--dur) var(--ease);
}
.side a:hover { background: var(--surface); color: var(--text); }
.side a.active {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-2-soft));
  color: var(--accent); font-weight: 640;
}
.side a .ico { width: 20px; text-align: center; font-size: 1rem; opacity: .9; }
.side-foot { margin-top: 26px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.topbar .search { position: relative; flex: 1; max-width: 420px; }
.topbar .search input { padding-left: 36px; background: var(--surface-2); border-color: transparent; }
.topbar .search input:focus { background: var(--surface); }
.topbar .search::before {
  content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%);
  color: var(--muted-2); font-size: 1.05rem;
}
.credits-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: .84rem; font-weight: 600; border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.bell { position: relative; }
.bell .dot {
  position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--bg);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-weight: 700; font-size: .86rem; flex: none;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }
.app-content { padding: 28px; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 1.65rem; margin: 0 0 4px; }
.page-head p { color: var(--muted); margin: 0; font-size: .93rem; }

/* Stats */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: .83rem; font-weight: 550; }
.stat-value { font-size: 1.75rem; font-weight: 780; letter-spacing: -.03em; margin-top: 4px; }
.stat-foot { font-size: .78rem; color: var(--muted-2); margin-top: 2px; }

/* Upload / ask box */
.ask-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.ask-box textarea {
  border: 0; padding: 8px 4px; min-height: 70px; background: transparent; font-size: 1rem;
}
.ask-box textarea:focus { box-shadow: none; }
.ask-box .ask-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }

/* Quick actions */
.quick { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); transition: all var(--dur) var(--ease); color: var(--text); }
.quick:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-xs); }
.quick b { font-size: .91rem; font-weight: 600; }
.quick span { font-size: .78rem; color: var(--muted); }

/* List rows */
.row-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  transition: all var(--dur) var(--ease);
}
.row-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.row-title { font-weight: 600; font-size: .95rem; color: var(--text); }
.row-sub { font-size: .8rem; color: var(--muted); }
.icon-box {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 1rem;
}

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: .91rem; }
th { color: var(--muted); font-weight: 650; font-size: .77rem; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Empty state */
.empty { text-align: center; padding: 54px 24px; color: var(--muted); }
.empty-icon {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 1.5rem;
}
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 460px; margin: 0 auto 18px; font-size: .93rem; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-card { height: 84px; margin-bottom: 12px; }

/* Chat */
.chat-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 24px; height: calc(100vh - 68px - 57px); }
.chat-list { border-right: 1px solid var(--line); padding-right: 16px; overflow-y: auto; }
.chat-list a { display: block; padding: 10px 12px; border-radius: var(--radius); color: var(--text-soft); font-size: .9rem; }
.chat-list a:hover { background: var(--surface-2); }
.chat-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 8px 4px 20px; }
.msg { display: flex; gap: 12px; margin-bottom: 20px; }
.msg-bubble {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 13px 16px; max-width: 76%; line-height: 1.65; white-space: pre-wrap;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .msg-bubble { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.msg-avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: .82rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.msg.user .msg-avatar { background: var(--accent); color: #fff; border-color: transparent; }
.chat-input { border-top: 1px solid var(--line); padding-top: 14px; display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea { min-height: 52px; max-height: 180px; }

/* Чат в стиле DeepSeek: лента сообщений и поле ввода, закреплённое снизу. */
.chat-page {
  display: flex; flex-direction: column;
  height: calc(100vh - 68px - 57px - 90px);
  min-height: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 22px 8px 12px; }
.chat-messages-inner { max-width: 860px; margin: 0 auto; }
.chat-composer { border-top: 1px solid var(--line); background: var(--surface-2); padding: 14px 16px 12px; }
.chat-composer-inner { max-width: 860px; margin: 0 auto; }
.chat-composer .chat-input {
  border-top: 0; padding-top: 0;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); padding: 10px 12px;
  box-shadow: var(--shadow-xs); align-items: flex-end;
}
.chat-composer .chat-input textarea {
  min-height: 46px; max-height: 200px; border: 0; background: transparent;
  resize: none; line-height: 1.55; padding: 6px 4px;
}
.chat-composer .chat-input textarea:focus { outline: none; }
.chat-doc-select { max-width: 190px; align-self: center; }
.chat-send { flex: none; }
.chat-hint { margin-top: 8px; text-align: center; }
.chat-empty { text-align: center; padding: 40px 12px; max-width: 520px; margin: 0 auto; }
.chat-topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.chat-topbar-title { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-empty-logo { font-size: 3rem; margin-bottom: 10px; display: flex; justify-content: center; }
.chat-empty-logo svg { filter: drop-shadow(0 6px 16px rgba(99,102,241,.35)); }
.chat-empty h2 { font-size: 1.35rem; margin-bottom: 8px; }
.chat-empty p { font-size: .92rem; line-height: 1.6; }
.chat-messages .msg { display: block; margin-bottom: 22px; }
.chat-messages .msg-meta { font-size: .74rem; color: var(--muted-2); margin-bottom: 5px; }
.chat-messages .msg-user .msg-meta { text-align: right; }
.chat-messages .msg-body {
  display: block; max-width: 92%; padding: 12px 16px; line-height: 1.65;
  border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.chat-messages .msg-user .msg-body {
  display: block; margin-left: auto; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent; white-space: pre-wrap;
}
.chat-messages .msg-user .msg-body a { color: #fff; }

/* Flashcards */
.flip { perspective: 1200px; }
.flip-inner { position: relative; transition: transform .5s var(--ease); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  backface-visibility: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); padding: 34px 28px; min-height: 240px;
  display: flex; flex-direction: column; justify-content: center; text-align: center; box-shadow: var(--shadow-sm);
}
.flip-back { position: absolute; inset: 0; transform: rotateY(180deg); background: var(--surface-2); }
.flip-hint { font-size: .8rem; color: var(--muted-2); margin-top: 18px; }

/* Quiz */
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; margin-bottom: 10px;
  transition: all var(--dur) var(--ease);
}
.opt:hover { border-color: var(--accent); }
.opt.correct { border-color: var(--success); background: var(--success-soft); }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt input { width: auto; margin-top: 4px; accent-color: var(--accent); }
.progress-track { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .4s var(--ease); }

/* Heatmap */
.heat { display: flex; flex-wrap: wrap; gap: 3px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-3); display: block; }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 28%, var(--surface-3)); }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 52%, var(--surface-3)); }
.heat i.l3 { background: color-mix(in srgb, var(--accent) 76%, var(--surface-3)); }
.heat i.l4 { background: var(--accent); }

/* Note editor */
.note-editor { min-height: 460px; font-family: var(--mono); font-size: .92rem; line-height: 1.7; }
.note-preview { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--surface); }
.note-preview h1, .note-preview h2, .note-preview h3 { margin-top: 1.1em; }
.note-preview ul, .note-preview ol { padding-left: 22px; color: var(--text-soft); }
.note-preview code { background: var(--surface-3); padding: 2px 6px; border-radius: 5px; font-family: var(--mono); font-size: .88em; }
/* Таблицы и формулы внутри текста ИИ */
.markdown table, .note-preview table, .msg-body table, #tool-out table {
  width: 100%; min-width: 0; border-collapse: collapse; margin: 14px 0; font-size: .95rem;
}
/* Широкая таблица из ответа ИИ живёт в собственном прокручиваемом блоке:
   страница не уезжает вбок, а таблицу можно листать вправо. */
.table-scroll {
  width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; margin: 14px 0;
  border-radius: var(--radius, 10px);
}
.table-scroll > table { min-width: 560px; width: max-content; max-width: none; margin: 0; }
.markdown th, .note-preview th, .msg-body th, #tool-out th,
.markdown td, .note-preview td, .msg-body td, #tool-out td {
  border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top;
}
.markdown th, .note-preview th, .msg-body th, #tool-out th { background: var(--surface-3); font-weight: 700; }
.math-block { overflow-x: auto; overflow-y: hidden; text-align: center; margin: 14px 0; }
.code-block { background: var(--surface-3); padding: 12px 14px; border-radius: var(--radius); overflow-x: auto; font-family: var(--mono); font-size: .88em; }

/* Slides */
.slide-preview {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px;
  background: var(--surface); min-height: 210px;
}
.slide-preview .s-title { font-size: 1.35rem; font-weight: 750; margin-bottom: 12px; letter-spacing: -.02em; }
.slide-preview ul { padding-left: 20px; color: var(--text-soft); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 52px 0 30px; margin-top: 40px; background: var(--bg-soft); }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 30px; }
.footer-grid h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 12px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--muted); font-size: .91rem; }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--line); margin-top: 34px; padding-top: 18px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  color: var(--muted); font-size: .85rem;
}

/* Auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 40px 0 60px; }
.auth-card { width: min(460px, 92vw); }
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head h1 { font-size: 1.7rem; }

/* Toast / misc */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.scroll-x { overflow-x: auto; }
.tag-input { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 220px 1fr; }
}
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; gap: 36px; }
  .hero { padding: 52px 0 40px; }
  .nav-links { display: none; }
  .burger { display: block; }
  .app-shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 58px auto 0 0; width: 262px; height: calc(100vh - 58px);
    background: var(--surface); z-index: 55; transform: translateX(-102%);
    transition: transform .28s var(--ease); box-shadow: var(--shadow-lg);
  }
  .side.open { transform: translateX(0); }
  .side-backdrop { position: fixed; inset: 58px 0 0; background: rgba(10,12,20,.4); z-index: 50; }
  .app-content { padding: 18px; }
  .topbar { padding: 12px 18px; }
  .chat-wrap { grid-template-columns: 1fr; height: auto; }
  .app-content:has(.chat-page) { padding: 0; }
  .app-content:has(.chat-page) > .page-head { display: none; }
  .chat-page {
    height: calc(100dvh - 58px - 74px); border-radius: 0;
    border-left: 0; border-right: 0; margin-top: 0 !important;
  }
  .chat-messages { padding: 14px 10px 8px; }
  .chat-messages .msg-body { max-width: 100%; }
  .chat-composer { padding: 10px 10px 8px; }
  .chat-composer .chat-input { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .chat-doc-select { max-width: 100%; width: 100%; flex: 0 0 100%; }
  .chat-composer .chat-input textarea { flex: 1 1 auto; width: auto; min-width: 0; min-height: 42px; }
  .chat-composer .chat-send {
    flex: 0 0 42px; width: 42px; height: 42px; padding: 0; border-radius: 50%;
    font-size: 0; position: relative;
  }
  .chat-send::after {
    content: "➤"; font-size: 1rem; position: absolute; inset: 0;
    display: grid; place-items: center;
  }
  .chat-hint { display: none; }
  .chat-list { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; max-height: 220px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .section { padding: 48px 0; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; }
  .plan { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Онбординг, чипы выбора, узкая колонка ---------- */
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 32px 18px 64px; }

.check-card {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
  cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease);
}
.check-card:hover { border-color: var(--line-strong); }
.check-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check-card input { accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border: 1px solid var(--line);
  border-radius: 999px; font-size: .84rem; cursor: pointer;
  background: var(--surface); transition: all .2s var(--ease);
}
.chip-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip-check input { accent-color: var(--accent); }

/* ---------- Мобильная доработка: таблицы, онбординг, задачи ---------- */
@media (max-width: 720px) {
  .card { padding: 16px; }
  .card table { min-width: 520px; }
  .card:has(table) { overflow-x: auto; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head .btn { width: 100%; }
  .wrap-narrow { padding: 20px 14px 48px; }
  .check-card { padding: 12px 14px; font-size: .92rem; }
  .grid.g2 { grid-template-columns: 1fr; }
  .grid.g3 { grid-template-columns: 1fr; }
  .chips { gap: 7px; }
  .chip-check { padding: 6px 11px; font-size: .8rem; }
  .btn { width: 100%; }
  .btn-block { width: 100%; }
  .side-foot { position: static; }
}

/* ---------- Фильтры, степпер, мобильная версия ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.filters .field { flex: 1 1 170px; margin: 0; }
.filters .btn { flex: 0 0 auto; }

.psteps { display: flex; gap: 8px; }
.pstep {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 600; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
}
.pstep-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Мобильная версия: нижняя навигация вместо боковой панели */
@media (max-width: 720px) {
  .app-shell { padding-bottom: 74px; }
  .side {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    transform: none; height: auto; width: auto;
    z-index: 60; display: flex; flex-direction: row;
    overflow-x: auto; gap: 4px; padding: 8px 10px;
    border-top: 1px solid var(--line); background: var(--surface);
    box-shadow: 0 -6px 20px rgba(0,0,0,.08);
  }
  .side .side-title, .side .side-foot, .side .theme-switch { display: none; }
  .side-backdrop { display: none; }
  .topbar .burger { display: none; }
  .side nav { display: flex; flex-direction: row; gap: 4px; width: 100%; }
  .side nav a, .side > a {
    flex: 0 0 auto; padding: 9px 12px; font-size: .8rem;
    white-space: nowrap; border-radius: 10px;
  }
  .filters { padding: 12px; gap: 10px; }
  .filters .field { flex: 1 1 100%; }
  .filters .btn { width: 100%; }
  .psteps { gap: 6px; }
  .pstep { width: 26px; height: 26px; font-size: .76rem; }
}

/* --- Презентации: картинки слайдов --- */
.slide-img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(20, 20, 40, .08);
  display: block;
  background: #f6f6fb;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* --- Презентации: несколько картинок на слайде --- */
.slide-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slide-gallery-item {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(20, 20, 40, .08);
  background: #f6f6fb;
}

.slide-gallery-item img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.slide-gallery-item figcaption {
  font-size: .68rem;
  line-height: 1.25;
  color: var(--muted, #6b7280);
  padding: 5px 7px;
  background: #fff;
}

@media (max-width: 720px) {
  .slide-gallery { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .slide-gallery-item figcaption { font-size: .62rem; padding: 4px 6px; }
}

/* ---------- Samsung / Android: удобные файлы, медиатека, камера ---------- */
/* Снимки Samsung в HEIC конвертируются в JPEG на сервере, но на телефоне
   поле выбора всё равно должно выглядеть привычно. */
input[type="file"] {
  font-size: 1rem;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong, #c9ccd6);
  background: var(--surface-2, #f5f6fa);
  width: 100%;
  max-width: 100%;
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  margin-right: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--accent, #4f46e5);
  color: #fff;
  cursor: pointer;
}

/* Отдельное поле камеры: на Samsung сразу открывает камеру. */
.camera-input {
  border-style: solid !important;
  border-color: var(--accent, #4f46e5) !important;
  background: var(--accent-soft, #eef0ff) !important;
}

/* Безопасные зоны: жестовая навигация Android и «безопасный» вырез. */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-shell { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .side {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
  }
  .chat-composer { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}

@media (max-width: 720px) {
  /* На узких экранах Samsung (360 px и меньше) ничего не должно
     вылезать по горизонтали. */
  html, body { overflow-x: hidden; }
  body { -webkit-text-size-adjust: 100%; }

  .side nav a, .side > a { min-height: 44px; display: inline-flex; align-items: center; }

  .btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
  .link-btn { padding: 8px 2px; }
  .chat-send { width: 46px; height: 46px; }
  .card { padding: 14px; }
  .field input, .field textarea, .field select { font-size: 16px; }

  input[type="file"] { font-size: 16px; padding: 8px; }
  input[type="file"]::file-selector-button { padding: 12px 16px; }
}
