/* AI Textbook — общий слой: палитра, шрифт Onest, иконки, боковое меню, мобильная навигация */

:root {
  /* Палитра сайта */
  --blue: #4737FF;
  --blue-hover: #3929F2;
  --blue-ink: #2E22C9;
  --blue-50: #F4F3FF;
  --blue-100: #E8E5FF;
  --blue-200: #D1CCFF;
  --blue-300: #ADA5FF;
  --blue-400: #8A80FF;
  --blue-500: #6B5FFF;

  --orange: #F75C03;
  --orange-hover: #E25200;
  --orange-ink: #B53F00;
  --orange-50: #FFF5EE;
  --orange-100: #FFE7D8;
  --orange-300: #FFB585;

  --mint: #DDF5E3;
  --mint-50: #F0FBF3;
  --mint-200: #BFEACC;
  --mint-400: #7FD99A;
  --mint-500: #3FBF6E;
  --mint-ink: #1B7A43;

  --yellow: #F2B705;
  --yellow-soft: #FFF4CC;
  --yellow-ink: #8A6400;
  --red: #FF4D4F;
  --red-soft: #FFECEC;
  --red-ink: #C4282B;

  --black: #1F1F1F;
  --white: #FFFFFF;
  --gray: #F8F8F8;
  --gray-2: #F1F1F4;
  --gray-3: #E8E8EC;

  --ink: #1F1F1F;
  --ink-2: #3F3F48;
  --muted: #6E6E7A;
  --faint: #A3A3AE;
  --line: #ECECF0;
  --line-2: #DCDCE3;

  /* Совместимость со старыми именами */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: var(--gray);
  --green: var(--mint-500);
  --green-soft: var(--mint);
  --green-ink: var(--mint-ink);
  --pink: var(--blue-400);
  --pink-soft: var(--blue-50);
  --pink-ink: var(--blue-ink);
  --peach: var(--orange);
  --peach-soft: var(--orange-100);
  --peach-ink: var(--orange-ink);
  --violet: var(--blue);
  --violet-soft: var(--blue-50);
  --blue-soft: var(--blue-50);
  --blue-pastel: var(--blue-200);
  --navy: var(--black);

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 26px;

  --shadow-xs: 0 1px 2px rgba(31, 31, 31, .05);
  --shadow-sm: 0 1px 2px rgba(31, 31, 31, .04), 0 8px 24px -14px rgba(31, 31, 31, .16);
  --shadow: 0 2px 4px rgba(31, 31, 31, .04), 0 20px 40px -22px rgba(31, 31, 31, .28);
  --shadow-lg: 0 32px 64px -24px rgba(31, 31, 31, .36);
  --shadow-blue: 0 14px 28px -14px rgba(71, 55, 255, .7);

  --f-body: 'Onest', 'Segoe UI', system-ui, sans-serif;
  --f-display: var(--f-body);
  --f-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --f-math: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
}

body.app-bg { background: #FFFFFF; }

.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ───────────── Линейные иконки ───────────── */

.i {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.i * { transform-box: fill-box; transform-origin: center; }
.i .f { fill: currentColor; stroke: none; }

.i, .i-grid rect, .i-plus .p, .i-cards .c1, .i-cards .c2 { transition: transform .25s var(--ease-out); }
:is(.hov:hover, .hov:focus-visible) .i-grid rect:nth-child(4) { transform: scale(.8); }
:is(.hov:hover, .hov:focus-visible) .i-plus .p { transform: rotate(90deg); }
:is(.hov:hover, .hov:focus-visible) .i-x { transform: rotate(90deg); }
.i-book .pg { display: none; }
:is(.hov:hover, .hov:focus-visible) .i-chat .d2 { animation: i-dot .5s ease-in-out; }
.i-cards .c1, .i-cards .c2 { transform-origin: 50% 100%; }
.i-cards .c2 { fill: var(--ibg, #FFFFFF); }
:is(.hov:hover, .hov:focus-visible) .i-cards .c1 { transform: rotate(5deg); }
.i-bars .b { transform-origin: 50% 100%; }
:is(.hov:hover, .hov:focus-visible) .i-bars .b2 { animation: i-grow .45s var(--ease-out); }
.i-bell { transform-origin: 50% 8%; }
:is(.hov:hover, .hov:focus-visible) .i-bell { animation: i-ring .6s ease; }
:is(.hov:hover, .hov:focus-visible) .i-arrow { transform: translateX(2px); }
:is(.hov:hover, .hov:focus-visible) .i-back { transform: translateX(-2px); }
:is(.hov:hover, .hov:focus-visible) :is(.i-send, .i-upload, .i-download, .i-crown, .i-pin, .i-user, .i-cal, .i-list, .i-bulb, .i-flag, .i-pen, .i-bolt, .i-award) { transform: translateY(-1px); }
:is(.hov:hover, .hov:focus-visible) .i-refresh { transform: rotate(-60deg); }
:is(.hov:hover, .hov:focus-visible) .i-play { transform: scale(1.08); }

.i-check path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.done .i-check path, .i-check.on path { animation: i-draw .35s var(--ease-out) .05s forwards; }

@keyframes i-draw { to { stroke-dashoffset: 0; } }
@keyframes i-dot { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-1.5px); } }
@keyframes i-grow { 0% { transform: scaleY(.6); } 100% { transform: scaleY(1); } }
@keyframes i-ring { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(8deg); } 65% { transform: rotate(-6deg); } }
@keyframes i-spin { to { transform: rotate(360deg); } }

.auto-anim :is(a, button) > svg { transition: transform .25s var(--ease-out); }
.auto-anim :is(a, button):hover > svg { transform: translateY(-1px); }

/* Иконка в цветном кружке */
.ic { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--gray-2); color: var(--ink); --ibg: var(--gray-2); }
.ic .i { width: 20px; height: 20px; }
.ic-blue { background: var(--blue-100); color: var(--blue); --ibg: var(--blue-100); }
.ic-mint { background: var(--mint); color: var(--mint-ink); --ibg: var(--mint); }
.ic-orange { background: var(--orange-100); color: var(--orange); --ibg: var(--orange-100); }
.ic-dark { background: var(--black); color: #FFFFFF; --ibg: var(--black); }
.ic-white { background: #FFFFFF; color: var(--ink); --ibg: #FFFFFF; }
.ic-sm { width: 36px; height: 36px; }
.ic-sm .i { width: 17px; height: 17px; }
.ic-lg { width: 56px; height: 56px; }
.ic-lg .i { width: 24px; height: 24px; }

/* ───────────── Боковое меню ───────────── */

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;
  overflow-y: auto;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #FFFFFF;
  border-right: 1px solid var(--line);
  font-family: var(--f-body);
  font-size: 15px;
  color: var(--ink);
  scrollbar-width: none;
}
.side a { color: inherit; text-decoration: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--blue);
  color: #FFFFFF;
  display: grid; place-items: center;
  --ibg: var(--blue);
  transform: rotate(-6deg);
  transition: transform .4s var(--ease-spring);
}
.brand:hover .brand-mark { transform: rotate(0); }
.brand-mark .i { width: 19px; height: 19px; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-txt b { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand-txt small { font-size: 12.5px; color: var(--muted); }

.side-group { display: flex; flex-direction: column; gap: 2px; padding-top: 12px; }
.side-label {
  padding: 0 12px 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--faint);
}
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  transition: background .2s, color .2s;
  --ibg: #FFFFFF;
}
.nav a .i { width: 20px; height: 20px; }
.nav a:hover { background: var(--gray-2); color: var(--ink); --ibg: var(--gray-2); }
.nav a[aria-current="page"] { background: var(--black); color: #FFFFFF; --ibg: var(--black); }
.nav .count {
  margin-left: auto;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--gray-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.nav .count-new { background: var(--orange); color: #FFFFFF; }
.nav a[aria-current="page"] .count { background: rgba(255, 255, 255, .16); color: #FFFFFF; }

.recent { display: flex; flex-direction: column; gap: 2px; }
.recent a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 14.5px;
  color: var(--ink-2);
}
.recent a:hover { background: var(--gray-2); color: var(--ink); }
.recent a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent small { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.recent .dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 4px; transform: rotate(45deg); }

.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.plan-mini {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border-radius: 22px;
  background: var(--blue);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-mini::before { content: ''; position: absolute; right: -36px; top: -36px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.plan-mini > * { position: relative; }
.plan-mini-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.plan-mini-h b { font-size: 14.5px; font-weight: 700; }
.plan-mini-h span { font-size: 12px; color: rgba(255, 255, 255, .7); }
.plan-mini .me-lim { color: rgba(255, 255, 255, .78); }
.plan-mini .me-lim b { color: #FFFFFF; }
.plan-mini .mini-bar { background: rgba(255, 255, 255, .22); }
.plan-mini .mini-bar i { background: #FFFFFF; }
.plan-mini .btn { margin-top: 6px; }

.me-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--orange-100);
  color: var(--orange-ink);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
}
.me-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me-name strong { font-size: 14.5px; font-weight: 600; }
.me-name span { font-size: 12.5px; color: var(--muted); }

.me-lim { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.me-lim b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-bar { display: block; height: 5px; margin-bottom: 4px; border-radius: 999px; background: var(--gray-2); overflow: hidden; }
.mini-bar i { display: block; height: 100%; border-radius: 999px; background: var(--blue); }

/* ───────────── Мобильная шапка и нижнее меню ───────────── */

.mbar, .tabbar { display: none; }

@media (max-width: 760px) {
  .side { display: none !important; }

  .mbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 60px;
    box-sizing: border-box;
    padding: 0 14px;
    background: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    font-family: var(--f-body);
  }
  .mbar .brand { padding: 0; margin-right: auto; }
  .mbar .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
  .mbar .icon-btn { width: 38px; height: 38px; }
  .mbar .avatar { width: 38px; height: 38px; font-size: 13px; }

  /* Нижнее меню — тёмная «таблетка» */
  .tabbar {
    position: fixed;
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    padding: 8px 6px;
    border-radius: 26px;
    background: var(--black);
    box-shadow: 0 18px 36px -16px rgba(31, 31, 31, .6);
    font-family: var(--f-body);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, .55);
    text-decoration: none;
    --ibg: var(--black);
  }
  .tabbar a[aria-current="page"] { color: #FFFFFF; }
  .tabbar .i { width: 21px; height: 21px; }
  .tabbar .tab-plus {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--blue);
    color: #FFFFFF;
    display: grid; place-items: center;
  }
  .tabbar .tab-plus .i { width: 22px; height: 22px; }
}

/* Круглая кнопка-иконка */
.icon-btn {
  position: relative;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--gray-2);
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, transform .3s var(--ease-spring);
  --ibg: var(--gray-2);
}
.icon-btn:hover { background: var(--gray-3); --ibg: var(--gray-3); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .notif-dot {
  position: absolute;
  top: 9px; right: 10px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid var(--gray-2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
.side .btn-white { color: var(--ink); }

/* Логотип «смарт бук» */
/* Логотип — картинка assets/img/logo.png, текст внутри спрятан */
.logo { display: inline-block; width: 150px; height: 34px; background: url(../img/logo.png?v=1) no-repeat left center / contain; font-size: 0; line-height: 0; color: transparent; vertical-align: middle; }
.logo b { color: transparent; }
.side .brand { padding: 8px 12px 16px; }
.brand:hover .logo { opacity: .85; }
@media (max-width: 760px) { .mbar .logo { width: 124px; height: 28px; } }
/* Активный пункт меню — синий, как «бук» в логотипе */
.nav a[aria-current="page"] { background: var(--blue); color: #FFFFFF; --ibg: var(--blue); }
.nav a[aria-current="page"] .count { background: rgba(255, 255, 255, .2); color: #FFFFFF; }
.tabbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Сворачивание боковой панели */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.side-top .brand { min-width: 0; }
.side-toggle { flex: none; width: 34px; height: 34px; margin: 0 2px 8px 0; padding: 0; border: 0; border-radius: 10px; background: none; color: #B4B4BF; display: grid; place-items: center; cursor: pointer; transition: background .2s, color .2s; }
.side-toggle:hover { background: var(--gray-2); color: var(--ink-2); }
.side-toggle .i { width: 20px; height: 20px; }
.side-toggle .st-letter { display: none; font-family: var(--f-body); font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.045em; color: var(--blue); }
.shell { transition: grid-template-columns .25s ease; }
html.side-min .shell { grid-template-columns: 76px minmax(0, 1fr); }
html.side-min .side { padding: 20px 10px 16px; overflow-x: hidden; }
html.side-min .side-top { justify-content: center; }
html.side-min .side .brand,
html.side-min .side .side-label,
html.side-min .side .nav a > span,
html.side-min .side .plan-mini,
html.side-min .side .me-name,
html.side-min .side .me-out { display: none; }
html.side-min .side-toggle { width: 48px; height: 48px; margin: 4px 0 12px; border-radius: 14px; }
html.side-min .side-toggle .i { width: 22px; height: 22px; }
html.side-min .side .nav a { justify-content: center; width: 48px; padding: 0; margin: 0 auto; }
html.side-min .side .side-group { padding-top: 0; }
html.side-min .side .me-row { justify-content: center; padding: 6px 0; }
