@font-face { font-family: "Lora"; src: url("/fonts/Lora.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/fonts/Manrope.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }

:root {
  --cream: #F5EFE4;
  --card: #FFFCF6;
  --beige: #E9DDC7;
  --line: #E4DACA;
  --sage: #A3B593;
  --sage-soft: #DCE4D2;
  --sage-deep: #566B50;
  --terra: #C46B48;
  --terra-soft: #F3DDD2;
  --ink: #2C362A;
  --muted: #6E7668;
  --danger: #B5483A;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(44, 54, 42, .05), 0 6px 20px rgba(44, 54, 42, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--ink); }
body {
  font-family: "Manrope", system-ui, sans-serif; font-size: 15.5px; line-height: 1.5;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }

h1, h2, h3 { font-family: "Lora", Georgia, serif; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: var(--terra); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--sage-soft); border-top-color: var(--sage-deep); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Шапка */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 22px 20px 20px;
  background: radial-gradient(120% 140% at 100% 0%, var(--sage-soft) 0%, rgba(220,228,210,0) 55%),
              radial-gradient(90% 120% at 0% 100%, var(--beige) 0%, rgba(233,221,199,0) 60%), var(--card);
  box-shadow: var(--shadow);
}
.hero .kicker { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--sage-deep); }
.hero h1 { margin-top: 6px; }
.hero .dot { position: absolute; right: 22px; top: 22px; width: 12px; height: 12px; border-radius: 50%; background: var(--terra); }

.progress { height: 8px; background: var(--sage-soft); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress > i { display: block; height: 100%; background: var(--sage-deep); border-radius: 99px; transition: width .4s; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--sage-soft); color: var(--sage-deep); white-space: nowrap; }
.pill.terra { background: var(--terra-soft); color: var(--terra); }
.pill.gray { background: #ECE6DA; color: var(--muted); }
.pill.red { background: #F4D9D4; color: var(--danger); }

/* Карточки */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 8px; }

.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.item:first-child { border-top: 0; }
.item:active { background: #F7F1E6; }
.item.locked { opacity: .5; cursor: default; }
.item .num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--sage-soft); color: var(--sage-deep); }
.item .num.cur { background: var(--terra); color: #fff; }
.item .num.done { background: var(--sage-deep); color: #fff; }
.item .chev { color: var(--muted); flex: none; }
.item .title { font-weight: 600; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 14px 16px; font: inherit; font-weight: 700; font-size: 15px;
  background: var(--terra); color: #fff; cursor: pointer; text-decoration: none; transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn.sage { background: var(--sage-deep); }
.btn.ghost { background: var(--sage-soft); color: var(--sage-deep); }
.btn.line { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #EBC9C2; }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 12px; }
.btns { display: grid; gap: 8px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.btns.three { grid-template-columns: 1fr 1fr 1fr; }

/* Шаги урока */
.step { display: flex; gap: 14px; }
.step .bullet { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--sage-soft); color: var(--sage-deep); }
.step.done .bullet { background: var(--sage-deep); color: #fff; }
.step.active .bullet { background: var(--terra); color: #fff; }
.step.lock { opacity: .6; }
.step .body { flex: 1; min-width: 0; }
.step .body > * + * { margin-top: 10px; }

/* Формы */
textarea, input[type=text], input[type=search], input[type=date], select {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font: inherit; color: var(--ink);
  background: #fff; outline: none; resize: vertical;
}
textarea:focus, input:focus, select:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
textarea { min-height: 96px; }
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 2px 6px; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--sage-soft); display: grid; place-items: center; font-size: 12px; color: var(--sage-deep); text-align: center; padding: 4px; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(44,54,42,.7); color: #fff; font-size: 14px; line-height: 24px; cursor: pointer; padding: 0; }
.addfile { border: 1.5px dashed var(--sage); background: transparent; cursor: pointer; font-weight: 700; font-size: 13px; }

.gallery img { display: block; width: 100%; border-radius: 12px; margin-top: 8px; background: var(--sage-soft); }
.doc { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--sage-soft); color: var(--sage-deep); font-weight: 600; text-decoration: none; margin-top: 8px; }
.answer { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }

/* Преподаватель */
.tabs { display: flex; gap: 6px; background: var(--card); padding: 5px; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 14px; position: sticky; top: 8px; z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 9px 4px; border-radius: 12px; font-weight: 700; font-size: 13.5px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a.on { background: var(--sage-deep); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: "Lora", serif; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.linkbox { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; word-break: break-all; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 36px; margin-bottom: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 50; max-width: calc(100% - 32px); text-align: center; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; text-decoration: none; margin-bottom: 10px; font-size: 14px; }

.topline { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--sage-deep); margin: 2px 4px 10px; }
.topline .dot-s { width: 8px; height: 8px; border-radius: 50%; background: var(--terra); }
