@import url("fonts.css");

:root {
  --paper: #f7f3ea; --card: #fffdf8; --ink: #1d1b16; --muted: #716b5f; --line: #e8e0cf; --line-2: #f0eadc;
  --accent: #1f4d42; --accent-ink: #ffffff; --accent-soft: #e4eee8;
  --marker: #ffe066; --coral: #e2563b;
  --ok: #2f8a57; --bad: #c8412b; --doubt: #e39b2b;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 6px 18px rgba(60, 45, 20, .06);
  --shadow-lift: 0 2px 4px rgba(60, 45, 20, .08), 0 12px 28px rgba(60, 45, 20, .10);
  --display: "Lora", Georgia, "Times New Roman", serif;
  --text: "Manrope", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #13120f; --card: #1c1a16; --ink: #f1ece0; --muted: #a39c8d; --line: #2e2a23; --line-2: #25221c;
    --accent: #7cc4ad; --accent-ink: #0f1f1a; --accent-soft: #1f2d28;
    --marker: #8a7419; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lift: 0 6px 20px rgba(0,0,0,.45);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.hl { background: linear-gradient(transparent 58%, var(--marker) 58%, var(--marker) 90%, transparent 90%); padding: 0 .08em; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.narrow { max-width: 760px; margin: 0 auto; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.top .in { max-width: 1120px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 8px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 21px; text-decoration: none; color: var(--ink); flex: 1; }
.brand svg { width: 30px; height: 30px; }
.top .title { font-family: var(--display); font-weight: 600; font-size: 18px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink); flex: none; }
.iconbtn:hover { background: var(--line-2); }
.iconbtn svg { width: 22px; height: 22px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--line-2); font-size: 13px; color: var(--muted); white-space: nowrap; }
.pill.live { background: var(--accent-soft); color: var(--accent); }
.pill.mark { background: color-mix(in srgb, var(--marker) 55%, transparent); color: var(--ink); }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 18px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 700; text-decoration: none; transition: transform .12s; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--coral); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.field { width: 100%; padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); outline: none; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.field { resize: vertical; }

/* вход */
.login { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 380px; display: grid; gap: 12px; }
.login h1 { font-size: 42px; margin: 10px 0 0; }
.login p { margin: 0 0 14px; }
.login .logo svg { width: 56px; height: 56px; }

/* главная */
.hello { padding: 26px 0 4px; }
.hello h1 { font-size: clamp(30px, 6vw, 44px); margin: 0; }
.hello p { margin: 8px 0 0; font-size: 17px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0 6px; }
.action { display: grid; gap: 10px; justify-items: start; align-content: start; padding: 16px; border-radius: var(--r); background: var(--card);
  box-shadow: var(--shadow); cursor: pointer; border: 0; text-align: left; transition: box-shadow .15s, transform .15s; }
.action:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.action input { display: none; }
.bubble { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.bubble svg { width: 23px; height: 23px; }
.action b { font-size: 15px; line-height: 1.25; }
.action small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.b-green { background: #dcefe6; color: #1f4d42; } .b-yellow { background: #fff1b3; color: #7a5a00; }
.b-coral { background: #fde0d8; color: #a33a22; } .b-sky { background: #dfeafc; color: #2459a8; } .b-lilac { background: #ebe3fb; color: #5b3fa3; }
.b-sand { background: #f1e7d3; color: #6e5426; }
@media (prefers-color-scheme: dark) {
  .b-green { background: #1f3a31; color: #9dd6c3; } .b-yellow { background: #3a3214; color: #f1d567; } .b-sand { background: #33291a; color: #e0c592; }
  .b-coral { background: #3b221b; color: #f39a85; } .b-sky { background: #1b2a40; color: #93b8f0; } .b-lilac { background: #2a2140; color: #c2aef0; }
}
.section-h { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 12px; }
.section-h h2 { margin: 0; font-size: 23px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chip { border: 0; border-radius: 999px; padding: 8px 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; white-space: nowrap; font-weight: 700; font-size: 14px; color: var(--muted); }
.chip.on { background: var(--ink); color: var(--paper); box-shadow: none; }
.search { position: relative; margin: 12px 0 14px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search input { padding-left: 42px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.note { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.note:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.tile { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; flex: none; }
.note .t { font-family: var(--display); font-weight: 600; font-size: 17px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.continue { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; cursor: pointer; background: var(--accent); color: var(--accent-ink); margin-top: 18px; }
.continue .muted { color: color-mix(in srgb, var(--accent-ink) 72%, transparent); }
.continue .tile { background: rgba(255,255,255,.15); }
.continue h3 { margin: 2px 0 0; font-size: 19px; }
.continue svg { width: 24px; height: 24px; }
.empty { text-align: center; padding: 34px 20px; }
.empty h3 { margin: 12px 0 6px; font-size: 22px; }
.empty p { max-width: 420px; margin: 0 auto; }
.pending { margin: 14px 0; display: grid; gap: 10px; }
.pending .files { display: flex; gap: 6px; flex-wrap: wrap; }
.pending .files span { padding: 5px 10px; border-radius: 10px; background: var(--line-2); font-size: 13px; }
.seg { display: flex; gap: 4px; background: var(--line-2); padding: 4px; border-radius: 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 11px; cursor: pointer; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.labf { display: grid; gap: 8px; }
.recbox { display: grid; gap: 12px; margin: 14px 0; box-shadow: inset 0 0 0 2px var(--coral), var(--shadow); }
.recdot { width: 12px; height: 12px; border-radius: 50%; background: var(--coral); animation: pulse 1.2s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .3; } }
.rectime { font-family: var(--display); font-size: 38px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }

/* заметка */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 22px 0 4px; }
.hero .tile { width: 66px; height: 66px; font-size: 34px; border-radius: 20px; }
.hero h1 { margin: 0; font-size: clamp(23px, 4.6vw, 34px); }
.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.tool { display: flex; gap: 12px; align-items: center; padding: 13px; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow);
  cursor: pointer; border: 0; text-align: left; text-decoration: none; color: var(--ink); transition: box-shadow .15s, transform .15s; min-width: 0; }
.tool:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.tool.on { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow); }
.tool .bubble { width: 40px; height: 40px; border-radius: 12px; }
.tool b { display: block; font-size: 15px; }
.tool small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout { display: grid; gap: 22px; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .aside { position: sticky; top: 74px; }
  .aside .tools { grid-template-columns: 1fr; margin-top: 0; }
  .main-tools { display: none; }
}
@media (max-width: 999px) { .aside { display: none; } }
.status { display: grid; gap: 8px; margin: 14px 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.toc { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 10px; padding: 8px 16px; position: sticky; top: 58px; z-index: 5;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); }
.toc a { white-space: nowrap; text-decoration: none; font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; margin: 16px 0 4px; cursor: pointer; border: 0; background: none; padding: 0; }
.back svg { width: 16px; height: 16px; }
.view-h { font-size: 26px; margin: 6px 0 14px; }

/* конспект */
.md { font-size: 17px; line-height: 1.72; }
.md > *:first-child { margin-top: 0; }
.md h1 { display: none; }
.md h2 { font-size: 24px; margin: 36px 0 12px; scroll-margin-top: 120px; }
.md h3 { font-size: 19px; margin: 24px 0 8px; }
.md p, .md li { max-width: 70ch; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 5px 0; }
.md li::marker { color: var(--accent); font-weight: 700; }
.md strong { font-weight: 700; }
.md table { border-collapse: separate; border-spacing: 0; width: 100%; display: block; overflow-x: auto; margin: 14px 0; font-size: 15px;
  border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); background: var(--card); }
.md th, .md td { padding: 10px 12px; vertical-align: top; text-align: left; border-bottom: 1px solid var(--line); }
.md th { background: var(--line-2); font-weight: 700; }
.md tr:last-child td { border-bottom: 0; }
.md mark { background: linear-gradient(transparent 10%, var(--marker) 10%, var(--marker) 92%, transparent 92%); color: inherit; padding: 0 2px; border-radius: 3px; }
.md blockquote { margin: 8px 0 14px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; }
.md details.answer { margin: 4px 0 14px; }
.md details.answer > summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: 14px; list-style: none; }
.md details.answer > summary::-webkit-details-marker { display: none; }
.md details.answer > summary::before { content: "Показать ответ ↓"; }
.md details.answer[open] > summary::before { content: "Скрыть ответ ↑"; }
.md code { background: var(--line-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.check { color: var(--doubt); font-weight: 700; }
.chart { margin: 14px 0; color: var(--ink); background: var(--card); border-radius: 14px; padding: 8px; box-shadow: inset 0 0 0 1px var(--line); }

/* тест */
.quiz h3 { font-size: 21px; margin: 16px 0 6px; }
.opt { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; margin: 10px 0; padding: 14px; border-radius: 14px;
  border: 0; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--card); cursor: pointer; line-height: 1.45; }
.opt:hover:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.opt .k { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--line-2); font-weight: 800; font-size: 13px; flex: none; }
.opt.right { box-shadow: inset 0 0 0 2px var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--card)); }
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong { box-shadow: inset 0 0 0 2px var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--card)); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.why { padding: 14px; border-radius: 14px; background: var(--line-2); margin: 12px 0; line-height: 1.55; }
.score { text-align: center; padding: 28px 18px; }
.score .big { font-family: var(--display); font-size: 60px; font-weight: 700; line-height: 1; }
.score ul { text-align: left; }

/* карточки */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 14px; }
.counters div { text-align: center; padding: 10px 6px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.counters b { display: block; font-family: var(--display); font-size: 24px; }
.counters small { color: var(--muted); font-size: 12.5px; }
.flip { perspective: 1200px; cursor: pointer; user-select: none; }
.flip .in { position: relative; min-height: 300px; transition: transform .45s cubic-bezier(.2,.7,.2,1); transform-style: preserve-3d; }
.flip.back .in { transform: rotateY(180deg); }
.flip .face { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 28px 24px 40px; border-radius: 22px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: var(--shadow-lift); }
.flip .front { background: var(--card); font-family: var(--display); font-size: 23px; font-weight: 600; line-height: 1.35; }
.flip .rear { background: var(--accent); color: var(--accent-ink); transform: rotateY(180deg); font-size: 18px; line-height: 1.55; }
.flip .hint { position: absolute; bottom: 14px; left: 0; right: 0; font-family: var(--text); font-size: 13px; font-weight: 600; opacity: .6; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* чат */
.chat { display: grid; gap: 12px; }
.msg { max-width: 88%; padding: 12px 16px; border-radius: 18px; line-height: 1.55; }
.msg.user { justify-self: end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant { background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
.msg.assistant .md { font-size: 16px; line-height: 1.6; }
.msg.assistant .md h3 { font-size: 17px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest .chip { white-space: normal; text-align: left; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 9; }
.composer form { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer .btn { padding: 13px 15px; }

/* исходник */
.page { display: grid; gap: 10px; margin-bottom: 14px; }
.page img { width: 100%; border-radius: 12px; margin-top: 8px; }
.page pre { white-space: pre-wrap; font: inherit; margin: 0; line-height: 1.65; }
.page .doubt, .legend .doubt { text-decoration: underline wavy var(--doubt); text-underline-offset: 4px; background: color-mix(in srgb, var(--doubt) 16%, transparent); border-radius: 3px; }
.page mark, .legend mark { background: var(--marker); color: inherit; border-radius: 3px; }

/* подкаст */
.player { display: grid; gap: 14px; }
.player audio { width: 100%; }
.speed { display: flex; gap: 6px; }
.speed button { flex: 1; }
.speed button.on { background: var(--ink); color: var(--paper); box-shadow: none; }
.line { display: grid; grid-template-columns: 74px 1fr; gap: 10px; margin: 10px 0; align-items: start; }
.who { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 4px 8px; border-radius: 8px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 11px 18px; border-radius: 14px; z-index: 50; box-shadow: var(--shadow-lift); max-width: calc(100% - 32px); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 1s linear infinite; vertical-align: -3px; flex: none; }
@keyframes s { to { transform: rotate(360deg); } }
.sheet { position: fixed; inset: 0; background: rgba(20,15,5,.35); display: grid; align-items: end; z-index: 40; }
.sheet .in { background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 8px; max-width: 560px; width: 100%; margin: 0 auto; }
.sheet .in .btn { justify-content: flex-start; }

@media (max-width: 440px) {
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .action:last-child { grid-column: 1 / -1; grid-template-columns: auto 1fr; align-items: center; }
  .actions .action:last-child small { grid-column: 2; margin-top: -8px; }
}
@media print {
  .top, .tools, .aside, .toolbar, .toc, .noprint, .composer, .toast, .back { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { max-width: none; padding: 0; } .layout { display: block; }
  .md h1 { display: block; }
  .md details.answer > summary { display: none; }
  .md mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .md h2 { break-after: avoid; } .md table, .md blockquote, .chart { break-inside: avoid; }
}

/* исправления после просмотра */
.layout > * { min-width: 0; }
.continue h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (prefers-color-scheme: dark) {
  .continue { background: #1f3a31; color: #f1ece0; }
  .continue .muted { color: #a9c9bd; }
}
#mm { font: 15px/1.35 var(--text); color: var(--ink); }
#mm mark { background: var(--marker); color: inherit; }
