/* Gaide — модуль «Социология управления» (sm.golos-istoki.ru)
   Дизайн-токены фреймворка Gaide (как у en.golos-istoki.ru) */
:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #efeae0;
  --ink: #1d2230;
  --ink-2: #4a5163;
  --ink-3: #7b8192;
  --line: #e2dccf;
  --accent: #1f5c7a;
  --accent-ink: #ffffff;
  --accent-soft: #dde9ee;
  --good: #2f7a4f;
  --good-soft: #e1f0e6;
  --warn: #a8661b;
  --warn-soft: #f7ead6;
  --bad: #a83a32;
  --bad-soft: #f6e0dd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 34, 48, .06), 0 4px 16px rgba(29, 34, 48, .05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --surface: #1c2028; --surface-2: #252a34; --ink: #e9e6df; --ink-2: #b9bcc6; --ink-3: #868b98;
    --line: #2e3440; --accent: #6fb1d1; --accent-ink: #0f1a20; --accent-soft: #1e3340;
    --good: #6cc08f; --good-soft: #1d3326; --warn: #e0a85c; --warn-soft: #3a2d1b; --bad: #e88a80; --bad-soft: #3d2220;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-2); }

#app { max-width: 720px; margin: 0 auto; padding: 16px 16px 0; }
.topbar { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.topbar .back { font-size: 1.4rem; line-height: 1; padding: 6px 8px 6px 0; color: var(--ink-2); }
.topbar h1 { margin: 0; flex: 1; font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.soft { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 11px 16px; border-radius: 12px; cursor: pointer; min-height: 44px; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; text-align: center;
}
button:hover, .btn:hover { border-color: var(--ink-3); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.07); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn-small { min-height: 44px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--bad); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > button, .btn-row > .btn { flex: 1 1 auto; }

/* таб-бар */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); font-size: .72rem; }
.tabbar a .ico { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--accent); font-weight: 600; }
.tabbar .badge { position: absolute; margin-left: 22px; margin-top: -26px; background: var(--bad); color: #fff;
  font-size: .65rem; border-radius: 10px; padding: 1px 5px; }

/* чипы и метки */
.chip { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }

/* прогресс */
.bar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .25s ease-out; }
.bar.good > i { background: var(--good); }
.score { font-weight: 700; font-size: 1.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.score.good { color: var(--good); } .score.warn { color: var(--warn); } .score.bad { color: var(--bad); }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.statgrid .stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.statgrid .stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.statgrid .stat span { font-size: .75rem; color: var(--ink-3); }

/* загрузка */
.loading-block { display: flex; justify-content: center; padding: 60px 0; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .bar > i { transition: none; } }

/* ===== Билеты ===== */
.blk-head { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; }
.blk-head .code { font-weight: 700; color: var(--accent); border: 1px solid currentColor; border-radius: 6px; padding: 1px 7px; font-size: .8rem; }
.blk-head h2 { margin: 0; font-size: 1rem; }
.blk-head .cnt { font-size: .78rem; color: var(--ink-3); }
.bcard { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); color: inherit; }
.bcard:hover { border-color: var(--accent); }
.bcard .num { font: 700 1.3rem/1 var(--serif); color: var(--accent); min-width: 34px; font-variant-numeric: tabular-nums; }
.bcard.draft { opacity: .55; box-shadow: none; }
.bcard.draft .num { color: var(--ink-3); }
.bcard .t { font-size: .95rem; line-height: 1.4; }
.bcard .sub { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* страница билета */
.qform { font: italic 1rem/1.5 var(--serif); color: var(--ink-2); }
details.plan-item { border: 1px solid var(--line); border-radius: 12px; padding: 0; margin-bottom: 8px; background: var(--surface); }
details.plan-item > summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; min-height: 44px; }
details.plan-item > summary::-webkit-details-marker { display: none; }
details.plan-item > summary .chk { flex: none; width: 22px; height: 22px; margin-top: 1px; border: 1.5px solid var(--ink-3); border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: .85rem; }
details.plan-item.done > summary .chk { background: var(--good); border-color: var(--good); }
details.plan-item.done > summary .chk::after { content: "✓"; }
details.plan-item > summary b { font-weight: 600; font-size: .98rem; }
details.plan-item .body { padding: 0 14px 12px 46px; font-size: .92rem; color: var(--ink-2); }
details.plan-item .body .acts { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

table.books { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.books th, table.books td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.books th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
table.books td.pages { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.books tr.done td { color: var(--ink-3); }
table.books tr.done td:first-child { text-decoration: line-through; }

/* задания на литературу */
details.lit-task { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); }
details.lit-task > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; min-height: 44px; }
details.lit-task > summary::-webkit-details-marker { display: none; }
details.lit-task > summary .chk { flex: none; width: 22px; height: 22px; margin-top: 1px; border: 1.5px solid var(--ink-3); border-radius: 7px; display: grid; place-items: center; color: #fff; }
details.lit-task.done > summary .chk { background: var(--good); border-color: var(--good); }
details.lit-task.done > summary .chk::after { content: "✓"; }
details.lit-task .body { padding: 0 14px 12px 46px; font-size: .92rem; color: var(--ink-2); }
details.lit-task .body p { margin: 0 0 8px; }
details.lit-task .body b.lbl { color: var(--ink); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.qline { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: .88rem; }
.qline span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qline button { min-height: 34px; padding: 3px 10px; font-size: .8rem; border-radius: 8px; flex: none; }
.rec { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec .who { color: var(--accent); font-weight: 600; }
.ai-note { font-size: .78rem; color: var(--ink-3); }

/* флеш-карточка */
.flash { perspective: 900px; cursor: pointer; margin-bottom: 12px; }
.flash-inner { position: relative; min-height: 240px; transition: transform .28s ease-out; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash .face { position: absolute; inset: 0; backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.flash .face.back { transform: rotateY(180deg); overflow-y: auto; }
.flash .face .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.flash .face .term { font: 600 1.25rem/1.4 var(--serif); }
.flash .face .defn { font-size: .98rem; line-height: 1.55; }
.flash .face .src { margin-top: auto; font-size: .78rem; color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) { .flash-inner { transition: none; } }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade-row button { padding: 10px 4px; font-size: .88rem; flex-direction: column; gap: 2px; }
.grade-row button small { font-size: .7rem; color: var(--ink-3); font-weight: 400; }
.grade-row .g0 { border-color: var(--bad); color: var(--bad); }
.grade-row .g1 { border-color: var(--warn); color: var(--warn); }
.grade-row .g2 { border-color: var(--good); color: var(--good); }
.grade-row .g3 { border-color: var(--accent); color: var(--accent); }

/* тест */
.qt { font-weight: 600; margin-bottom: 10px; line-height: 1.45; }
.opts { display: grid; gap: 8px; margin-bottom: 10px; }
.opts button { justify-content: flex-start; text-align: left; font-size: .95rem; }
.opts button.right { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.opts button.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.why { font-size: .88rem; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }

/* экзамен */
.exam-timer { font: 700 2.2rem/1 var(--serif); font-variant-numeric: tabular-nums; text-align: center; }
.exam-timer.over { color: var(--bad); }
.checkline { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.checkline:last-child { border-bottom: 0; }
.checkline .chk { flex: none; width: 22px; height: 22px; margin-top: 1px; border: 1.5px solid var(--ink-3); border-radius: 7px; display: grid; place-items: center; color: #fff; }
.checkline.done .chk { background: var(--good); border-color: var(--good); }
.checkline.done .chk::after { content: "✓"; }
.checkline.done span { color: var(--ink-3); text-decoration: line-through; }

/* персоналии */
table.ppl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.ppl td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ppl td.who { font-weight: 600; white-space: nowrap; }
table.ppl tr:last-child td { border-bottom: 0; }

/* формы */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: 4px; }
.field input { font: inherit; color: var(--ink); background: var(--surface); width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.mono { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; }

/* разное */
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: 4px; }
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px; margin-bottom: 12px; }
.hero h1 { font-family: var(--serif); font-size: 1.5rem; }
.hero .serif { font-family: var(--serif); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: .9rem; z-index: 30; box-shadow: var(--shadow); }
