:root {
  --ink: #16302a; --muted: #5f7570; --line: #e3efe9;
  --green: #3b8a76; --green-dark: #2f7463; --green-soft: #e6f4ed; --green-text: #2f6f5f; --green-light: #74c8a5;
  --mark: #c6e6a8; --yellow: #f2b544; --red: #cf5346; --red-soft: #fdeded; --amber: #a4690f; --amber-soft: #fff5e2;
  --card: #ffffff;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(22, 48, 42, .04), 0 12px 28px -14px rgba(22, 48, 42, .22);
  --shadow-lift: 0 2px 4px rgba(22, 48, 42, .05), 0 18px 36px -16px rgba(22, 48, 42, .28);
  --border: 1px solid rgba(47, 111, 95, .09);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(780px 520px at 88% -6%, rgba(116, 200, 165, .34), rgba(116, 200, 165, 0) 62%),
    radial-gradient(620px 460px at -10% 6%, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 60%),
    radial-gradient(760px 620px at 50% 108%, rgba(94, 168, 140, .26), rgba(94, 168, 140, 0) 68%),
    linear-gradient(180deg, #f8fcfa 0%, #edf6f1 55%, #e5f1ea 100%);
  background-attachment: fixed;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(rgba(47, 111, 95, .13) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .5;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 75%);
  mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 75%);
}
#app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: 14px 16px 44px; min-height: 100vh; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.015em; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 16px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brandmark { width: 34px; height: 32px; flex: none; filter: drop-shadow(0 4px 10px rgba(31, 100, 78, .22)); }
.brandtext { display: flex; flex-direction: column; line-height: 1.12; }
.brandtext b { font-weight: 800; font-size: 18px; letter-spacing: -.025em; }
.brandtext small { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.iconbtn { width: 38px; height: 38px; border-radius: 50%; border: var(--border); background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--ink); transition: .15s; }
.iconbtn:hover { box-shadow: var(--shadow-lift); }
.iconbtn svg { width: 18px; height: 18px; }
.back { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); font-weight: 600; padding: 4px 0; }
.back:hover { color: var(--ink); }

/* герой */
.hero { position: relative; padding: 4px 0 2px; }
.hero h1 { font-size: 31px; font-weight: 800; line-height: 1.16; }
.hero h1 .mark { background: linear-gradient(transparent 26%, var(--mark) 26%, var(--mark) 93%, transparent 93%); padding: 0 5px; border-radius: 5px; }
.hero .spark { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; color: var(--yellow); }
.lead { color: var(--muted); font-size: 15px; line-height: 1.45; margin: 14px 0 20px; }

/* карточки загрузки */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ucard { position: relative; background: var(--card); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 12px 16px; text-align: center; transition: transform .16s, box-shadow .16s, border-color .16s; overflow: hidden; }
.ucard::after { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--green-light), var(--green)); opacity: 0; transition: .16s; }
.ucard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.ucard:hover::after, .ucard.drag::after { opacity: 1; }
.ucard.drag { border-color: var(--green); }
.ucard .ic { width: 62px; height: 62px; border-radius: 19px; background: linear-gradient(160deg, #f0faf5, #dcefe5); color: var(--green); display: grid; place-items: center; margin: 0 auto 12px; box-shadow: inset 0 1px 0 #fff; }
.ucard .ic svg { width: 31px; height: 31px; }
.ucard .ttl { font-weight: 600; font-size: 13.5px; min-height: 36px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.pill { display: inline-block; border: 0; background: var(--green-soft); color: var(--green-text); font-weight: 600; font-size: 13px; padding: 8px 18px; border-radius: 999px; transition: .15s; }
.pill:hover { background: #d6ecdf; }
.files { margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 10px; background: var(--card); border: var(--border); border-radius: 15px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 14px; }
.file .k { width: 30px; height: 30px; border-radius: 10px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; flex: none; }
.file .k svg { width: 16px; height: 16px; }
.file .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .s { color: var(--muted); font-size: 12px; flex: none; }
.file .x { border: 0; background: none; color: var(--muted); padding: 4px; }
.file .x:hover { color: var(--red); }

/* выбор */
.section-title { font-weight: 700; font-size: 17px; margin: 26px 0 12px; }
.check { display: flex; align-items: center; gap: 12px; background: var(--card); border: var(--border); border-radius: 15px; padding: 13px 14px; box-shadow: var(--shadow); margin-bottom: 8px; cursor: pointer; font-size: 15px; user-select: none; transition: .15s; }
.check:hover { box-shadow: var(--shadow-lift); }
.check .box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid #c2dbd0; display: grid; place-items: center; flex: none; background: #fff; transition: .12s; }
.check .box svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.check.on { border-color: rgba(59, 138, 118, .35); }
.check.on .box { background: linear-gradient(160deg, var(--green-light), var(--green)); border-color: transparent; }
.check.on .box svg { opacity: 1; }
.settings { background: var(--card); border: var(--border); border-radius: 15px; padding: 12px 14px; box-shadow: var(--shadow); margin: 4px 0 8px; }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 14px; }
.seg { display: inline-flex; background: var(--green-soft); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--green-text); }
.seg button.on { background: linear-gradient(160deg, #4aa085, var(--green-dark)); color: #fff; box-shadow: 0 4px 10px -4px rgba(47, 116, 99, .6); }
.seg input { width: 56px; border: 0; background: transparent; text-align: center; font-weight: 600; color: var(--green-text); }

/* кнопки */
.cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; background: linear-gradient(160deg, #46a186 0%, #2d7261 100%); color: #fff; font-weight: 700; font-size: 16px; padding: 17px 20px; border-radius: 999px; margin-top: 22px; box-shadow: 0 10px 26px -10px rgba(47, 116, 99, .75); transition: .16s; }
.cta:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -10px rgba(47, 116, 99, .8); }
.cta:disabled { opacity: .45; box-shadow: none; transform: none; cursor: default; }
.cta.secondary { background: var(--card); color: var(--green-text); border: var(--border); box-shadow: var(--shadow); }
.cta.secondary:hover { box-shadow: var(--shadow-lift); }
.cta.sm { padding: 12px 16px; font-size: 14px; margin-top: 10px; }
.btnrow { display: flex; gap: 10px; }
.btnrow .cta { margin-top: 10px; }

/* список уроков */
.recent { margin-top: 30px; }
.ritem { display: flex; align-items: center; gap: 12px; background: var(--card); border: var(--border); border-radius: 15px; padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 8px; text-decoration: none; color: inherit; transition: .15s; }
.ritem:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.ritem .file { border: 0; box-shadow: none; padding: 0; background: none; }
.ritem .t { flex: 1; min-width: 0; }
.ritem .t b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ritem .t span { color: var(--muted); font-size: 12px; }
.ritem .st { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green-text); flex: none; }
.ritem .st.err { background: var(--red-soft); color: var(--red); }
.ritem .st.busy { background: var(--amber-soft); color: var(--amber); }

/* обработка */
.proc { text-align: center; padding: 26px 0 10px; }
.proc .ring { width: 92px; height: 92px; margin: 0 auto 20px; border-radius: 50%; border: 6px solid rgba(59, 138, 118, .16); border-top-color: var(--green); animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.proc h2 { font-size: 22px; margin-bottom: 8px; }
.proc .stage { color: var(--green-text); font-weight: 600; margin-bottom: 18px; }
.log { text-align: left; background: var(--card); border: var(--border); border-radius: 15px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; color: var(--muted); }
.log div { padding: 3px 0; }
.log div:last-child { color: var(--ink); font-weight: 500; }
.errbox { background: var(--card); border: var(--border); border-left: 4px solid var(--red); color: var(--red); border-radius: 15px; padding: 14px; font-size: 14px; margin-top: 12px; box-shadow: var(--shadow); }

/* конспект */
.chip { display: inline-block; background: var(--card); border: var(--border); color: var(--green-text); font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px; margin-bottom: 10px; box-shadow: var(--shadow); }
.ntitle { font-size: 27px; font-weight: 800; margin-bottom: 16px; }
.card { position: relative; background: var(--card); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 17px; margin-bottom: 12px; }
.card h3 { display: flex; align-items: center; gap: 9px; font-size: 16px; margin-bottom: 10px; }
.card h3::before { content: ''; width: 5px; height: 17px; border-radius: 3px; background: linear-gradient(180deg, var(--green-light), var(--green-dark)); flex: none; }
.card ul, .card ol { margin: 0; padding-left: 20px; }
.card li { margin: 5px 0; font-size: 14.5px; line-height: 1.45; }
.card li::marker { color: var(--green); }
.card p { margin: 6px 0; font-size: 14.5px; line-height: 1.5; }
.card b { color: #103028; }
.sec-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--line); }
.sec-actions button { border: 0; background: var(--green-soft); color: var(--green-text); font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 999px; transition: .15s; }
.sec-actions button:hover:not(:disabled) { background: #d6ecdf; }
.sec-actions button:disabled { opacity: .5; }
.card textarea { width: 100%; min-height: 160px; border: 1px solid var(--line); border-radius: 13px; padding: 11px; resize: vertical; line-height: 1.45; font-size: 14px; background: #fbfdfc; }
.card textarea:focus { outline: none; border-color: var(--green); }
.kv b { color: var(--green-text); }
.formula { font-family: "SF Mono", Menlo, monospace; background: #f2f8f5; padding: 2px 6px; border-radius: 6px; }
.sticky { position: sticky; bottom: 0; padding: 14px 0 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  background: linear-gradient(to top, rgba(238, 247, 242, .96) 55%, rgba(238, 247, 242, 0));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* модалка */
.menu { position: fixed; inset: 0; background: rgba(16, 40, 33, .4); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.menu .sheet { background: var(--card); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 18px 16px 28px; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(24px); } }
.sheet h3 { margin-bottom: 12px; font-size: 17px; }
.sheet .opt { display: block; width: 100%; text-align: left; border: var(--border); background: #fbfdfc; color: var(--ink); padding: 14px; border-radius: 15px; margin-bottom: 8px; font-weight: 600; transition: .15s; }
.sheet .opt:hover { background: var(--green-soft); }
.sheet .opt small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.sheet .cancel { display: block; width: 100%; border: 0; background: none; color: var(--muted); padding: 10px; font-weight: 600; }

/* тест */
.progress { height: 6px; background: rgba(59, 138, 118, .14); border-radius: 999px; overflow: hidden; margin: 6px 0 16px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-light), var(--green)); border-radius: 999px; transition: width .3s; }
.qmeta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.qmeta span:first-child { white-space: nowrap; flex: none; margin-right: 10px; }
.qmeta span:last-child { text-align: right; }
.qtext { font-size: 18px; font-weight: 700; line-height: 1.35; margin-bottom: 14px; }
.opt-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: var(--border); border-radius: 15px; padding: 13px 14px; margin-bottom: 8px; box-shadow: var(--shadow); font-size: 15px; line-height: 1.35; transition: .14s; }
.opt-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.opt-btn .l { width: 26px; height: 26px; border-radius: 50%; background: var(--green-soft); color: var(--green-text); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; transition: .14s; }
.opt-btn.sel { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), var(--shadow); }
.opt-btn.sel .l { background: var(--green); color: #fff; }
.opt-btn.ok { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), var(--shadow); }
.opt-btn.ok .l { background: var(--green); color: #fff; }
.opt-btn.bad { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), var(--shadow); }
.opt-btn.bad .l { background: var(--red); color: #fff; }
.opt-btn:disabled { cursor: default; color: var(--ink); }
.opt-btn:disabled:not(.ok):not(.bad) { opacity: .5; }
.ans-input { width: 100%; border: var(--border); background: var(--card); border-radius: 15px; padding: 13px 14px; font-size: 15px; box-shadow: var(--shadow); }
.ans-input:focus { outline: none; border-color: var(--green); }
textarea.ans-input { min-height: 120px; resize: vertical; }
.match-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.match-row .l { background: var(--card); border: var(--border); border-radius: 13px; padding: 10px 12px; font-size: 14px; box-shadow: var(--shadow); }
.match-row select { width: 100%; border: var(--border); background: var(--card); border-radius: 13px; padding: 10px; font-size: 14px; box-shadow: var(--shadow); }
.order-item { display: flex; align-items: center; gap: 10px; background: var(--card); border: var(--border); border-radius: 13px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); font-size: 14px; transition: .14s; }
.order-item .num { width: 26px; height: 26px; border-radius: 50%; background: var(--green-soft); color: var(--green-text); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.order-item.sel { border-color: var(--green); }
.order-item .num.on { background: var(--green); color: #fff; }

/* проверка ответа */
.feedback { background: var(--card); border: var(--border); border-left: 4px solid var(--green); border-radius: 15px; padding: 14px 15px; margin-top: 14px; font-size: 14.5px; line-height: 1.45; box-shadow: var(--shadow); }
.feedback.partial { border-left-color: var(--yellow); }
.feedback.bad { border-left-color: var(--red); }
.feedback .v { font-weight: 800; font-size: 16px; margin-bottom: 6px; color: var(--green-text); }
.feedback.partial .v { color: var(--amber); }
.feedback.bad .v { color: var(--red); }
.feedback p { margin: 5px 0; }
.feedback b { color: #103028; }

/* результат */
.score { text-align: center; padding: 18px 0 10px; }
.score .big { font-size: 54px; font-weight: 800; line-height: 1; background: linear-gradient(160deg, #4fb090, #256354); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score .pct { color: var(--muted); font-weight: 600; margin-top: 8px; }
.rev { font-size: 14px; padding: 9px 0; border-top: 1px solid var(--line); }
.rev:first-of-type { border-top: 0; }
.rev .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 6px; }
.tag.ok { background: var(--green-soft); color: var(--green-text); }
.tag.partial { background: var(--amber-soft); color: var(--amber); }
.tag.bad { background: var(--red-soft); color: var(--red); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #16302a; color: #fff; padding: 11px 17px; border-radius: 999px; font-size: 14px; z-index: 50; max-width: 90vw; box-shadow: 0 12px 30px -10px rgba(22, 48, 42, .6); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.cta.secondary .spinner, .sec-actions .spinner { border-color: rgba(47, 111, 95, .3); border-top-color: var(--green-text); }

@media (min-width: 600px) { #app { padding-top: 28px; } .hero h1 { font-size: 34px; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition: none !important; } }
