/* AI LMS — общий стиль. Светлая спокойная тема, без внешних шрифтов. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --line: #e3e6ea;
  --line-strong: #cfd4da;
  --text: #1d232b;
  --muted: #646e7a;
  --faint: #8b949f;
  --accent: #116a6a;
  --accent-hover: #0d5757;
  --accent-soft: #e3f1f0;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6200;
  --warn-soft: #fdf3dc;
  --ok: #1f7a3d;
  --ok-soft: #e5f4ea;
  --client: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }

/* ---------- кнопки и поля */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 550; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 14px; min-height: 36px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--panel-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--danger); border-color: #f1c4bf; }
button.danger:hover { background: var(--danger-soft); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: #eceef1; color: var(--text); }
button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button.icon { min-height: 30px; width: 30px; padding: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

label.field { display: flex; flex-direction: column; gap: 5px; }
label.field > span.label { font-size: 13px; font-weight: 600; color: #39424d; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; font-size: 14.5px; color: var(--text); background: #fff; border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px;
}
select.auto { width: auto; }
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
textarea.tall { min-height: 170px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; font-size: 14px; }
label.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- каркас */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15.5px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; letter-spacing: .5px;
}
.brand-sub { font-weight: 500; color: var(--muted); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 56px); }
.sidenav { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #3a434e; font-weight: 550; font-size: 14.5px;
}
.sidenav a:hover { background: var(--panel-2); text-decoration: none; }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.sidenav .nav-ico { width: 18px; height: 18px; flex: none; }
.main { padding: 24px 28px 60px; min-width: 0; }
.main-narrow { max-width: 1060px; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { display: flex; flex-direction: column; gap: 4px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.stack > .card, .cards > .card, .editor-side > .card, .tiles > .card { margin-top: 0; }
.main > .notice, .main > .tabs + .notice { margin-bottom: 14px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-title .hint { margin-left: auto; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- таблицы */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f6f8f9; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- метки */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: #4a5561; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.good { color: var(--ok); }
.score.mid { color: var(--warn); }
.score.bad { color: var(--danger); }

/* ---------- вкладки */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: none; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 0; }
.tabs button:hover { background: none; color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- окна и уведомления */
.overlay { position: fixed; inset: 0; background: rgba(17, 24, 33, .42); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.22); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 10px 20px 4px; overflow-y: auto; }
.modal-foot { padding: 14px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: #1f2933; color: #fff; padding: 11px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
.notice { padding: 10px 14px; border-radius: 9px; font-size: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.notice.warn { background: var(--warn-soft); border-color: #f2dca8; color: #6b4600; }
.notice.danger { background: var(--danger-soft); border-color: #f4c7c1; color: #8a1c12; }
.notice.ok { background: var(--ok-soft); border-color: #bfe3cb; color: #17592d; }
.secret-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; background: var(--panel-2); border: 1px dashed var(--line-strong); padding: 10px 12px; border-radius: 8px; word-break: break-all; }

/* ---------- вход */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); padding: 30px 28px 26px; }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth-card button.primary { width: 100%; min-height: 42px; font-size: 15px; }
.code-input { font-size: 24px !important; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 0; }

/* ---------- список курсов и заданий */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.course-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color .12s; }
.course-card:hover { border-color: var(--line-strong); }
.course-card .meta { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: auto; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: none; }
.task-num { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--muted); flex: none; }

/* ---------- редактор задания */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.editor-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 14px; }
.crit-row { display: grid; grid-template-columns: 1fr 90px 30px; gap: 8px; align-items: center; }
.crit-total { font-size: 13px; color: var(--muted); }
.savebar { display: flex; gap: 10px; align-items: center; }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }

/* ---------- чат */
.chat-page { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 56px); padding: 16px 20px 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.chat-brief { margin-bottom: 10px; }
.chat-brief summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); padding: 2px 0; }
.chat-log { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 4px 14px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.5; }
.msg .who { display: block; font-size: 12px; font-weight: 650; margin-bottom: 2px; opacity: .7; }
.msg.client { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.student { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.typing { color: var(--muted); font-style: italic; }
.typing-dots::after { content: "…"; animation: dots 1.2s steps(3) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: .3em; } 100% { width: 1.2em; } }
.composer { border-top: 1px solid var(--line); background: var(--bg); padding: 12px 0 16px; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 200px; resize: none; }
.composer button.primary { min-height: 46px; padding: 0 20px; }
.turns { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.feedback { padding: 18px 20px; margin: 6px 0 20px; }
.crit-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.crit-item:last-child { border-bottom: none; }
.crit-item .c-comment { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.big-score { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; }

/* ---------- попытка у тренера */
.attempt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.transcript { display: flex; flex-direction: column; gap: 10px; padding: 16px; max-height: calc(100vh - 190px); overflow-y: auto; background: var(--panel-2); border-radius: var(--radius); }
.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details.snap { font-size: 14px; }
details.snap summary { cursor: pointer; font-weight: 600; }
details.snap .pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 6px; font-size: 13.5px; max-height: 260px; overflow: auto; }

/* ---------- результаты */
table.matrix td.cell { text-align: center; cursor: pointer; min-width: 90px; }
table.matrix td.cell:hover { background: #f3f6f7; }
table.matrix th.task-col { max-width: 170px; white-space: normal; text-align: center; }
.cell-sub { font-size: 12px; color: var(--faint); display: block; }

/* ---------- расходы */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { padding: 14px 16px; }
.tile .t-label { font-size: 13px; color: var(--muted); }
.tile .t-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1 1 0; max-width: 34px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 6px; }
.model-card { padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.model-card + .model-card { margin-top: 12px; }
input.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

@media (max-width: 1100px) {
  .editor, .attempt-layout { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .transcript { max-height: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 6px; }
  .sidenav a { white-space: nowrap; padding: 8px 10px; }
  .main { padding: 18px 14px 50px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .brand-sub { display: none; }
  .brand { white-space: nowrap; font-size: 14.5px; }
  .who .who-name { display: none; }
  .msg { max-width: 90%; }
  .chat-page { padding: 10px 12px 0; }
}
