/* ОБУЧЕНИЕ — цикл усвоения знаний. Светлый, минимальный, в духе Notion. */

:root {
  --bg: #ffffff;
  --surface: #fbfaf7;
  --surface-2: #f4f3ee;
  --border: #ebebe6;
  --border-strong: #d9d8d1;
  --text: #2b2a26;
  --text-2: #6b6963;
  --text-3: #9a988f;
  --accent: #3d5a80;
  --accent-soft: #eaeef5;
  --warn: #b07a3a;
  --warn-soft: #f6efe1;
  --danger: #a04848;
  --danger-soft: #f4e6e2;
  --ok: #4d7a5b;
  --ok-soft: #e7efe6;

  --serif: "EB Garamond", "Source Serif Pro", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  --radius: 4px;
  --radius-lg: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ─── App shell ──────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 6px;
}
.brand-mark {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand-tag {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.side-section-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 6px;
  margin-bottom: 6px;
  font-weight: 500;
}

.back-to-goals {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin: 0 0 4px;
  padding: 6px 10px 6px 6px;
  font-size: 12.5px;
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 0.12s ease;
}
.back-to-goals:hover {
  color: var(--accent);
  background: #fff;
  border-color: var(--border);
}
.back-to-goals .arrow {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
}

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pipeline-step {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius);
  cursor: default;
  color: var(--text-2);
  font-size: 13.5px;
  transition: background 0.12s ease;
}
.pipeline-step.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}
.pipeline-step.done {
  color: var(--text);
}
.pipeline-step.locked {
  color: var(--text-3);
}
.pipeline-num {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-3);
  text-align: center;
}
.pipeline-step.active .pipeline-num,
.pipeline-step.done .pipeline-num {
  color: var(--text);
}
.pipeline-status {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.pipeline-status.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border-strong);
  display: inline-block;
}
.pipeline-status.dot.active { background: var(--accent); }
.pipeline-status.dot.done { background: var(--ok); }

/* Sticky rule-log widget */
.rule-widget {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-top: auto;
}
.rule-widget-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.rule-widget-rule {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}
.rule-widget-rule .when { color: var(--text-2); }
.rule-widget-empty {
  font-size: 12.5px;
  color: var(--text-3);
  font-style: italic;
  padding: 4px 0 8px;
}
.rule-widget button {
  width: 100%;
}
.rule-widget-count {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
}

/* ─── Main ───────────────────────────────────────────────────── */
.main {
  padding: 28px 48px 64px;
  max-width: 880px;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.crumb {
  font-size: 12.5px;
  color: var(--text-2);
  letter-spacing: 0.04em;
}
.crumb b { color: var(--text); font-weight: 500; }
.clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}
.clock .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

/* Page header */
.page-eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.page-title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  line-height: 1.15;
}
.page-lead {
  font-size: 15px;
  color: var(--text-2);
  max-width: 62ch;
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ─── Forms ─────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.field-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
  line-height: 1.45;
}
.field-counter {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}
.field-counter.warn { color: var(--warn); }
.field-counter.danger { color: var(--danger); }

.input, .textarea, .select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}
.textarea.lg { min-height: 110px; }

.notice {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-2);
  margin-top: 8px;
  line-height: 1.5;
  display: flex;
  gap: 10px;
}
.notice.warn { border-color: #e7d8b6; background: var(--warn-soft); color: #6b4a16; }
.notice.danger { border-color: #e6c5be; background: var(--danger-soft); color: #6b2828; }
.notice.ok { border-color: #cfdfcc; background: var(--ok-soft); color: #2f4a35; }
.notice .icon {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1;
  margin-top: 1px;
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.checkbox-row input[type="checkbox"] {
  width: 16px; height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Slider */
.slider-row {
  display: grid;
  grid-template-columns: 1fr 56px;
  align-items: center;
  gap: 14px;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--accent);
}
.slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--accent);
}
.slider-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  text-align: right;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #ffffff;
}
.btn.primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.btn.primary:hover { background: #444339; border-color: #444339; }
.btn.primary:disabled { background: var(--text-3); border-color: var(--text-3); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.lg { padding: 10px 18px; font-size: 14px; }
.btn.sm { padding: 5px 9px; font-size: 12px; }

.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 22px;
  flex-wrap: wrap;
}
.btn-row .spacer { flex: 1; }

/* Three-way choice (yes/no/unsure) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.choice {
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 14px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}
.choice:hover { background: var(--surface-2); }
.choice.yes.selected { background: var(--ok-soft); border-color: #b9cfba; }
.choice.no.selected { background: var(--danger-soft); border-color: #d8b8b2; }
.choice.unsure.selected { background: var(--warn-soft); border-color: #ddc89a; }

/* Difficulty pills */
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
}
.pill:hover { background: var(--surface-2); }
.pill.selected {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ─── Cards & sections ────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: #fff;
  margin-bottom: 14px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.card-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 0;
}
.card-meta {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}
.card-quote {
  border-left: 2px solid var(--border-strong);
  padding: 4px 0 4px 14px;
  margin: 0 0 8px;
  color: var(--text-2);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.45;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Session list (step 3) */
.session-list { display: flex; flex-direction: column; gap: 1px; }
.session-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.session-row + .session-row { margin-top: 6px; }
.session-row .seq {
  font-family: var(--serif);
  color: var(--text-3);
  font-size: 16px;
}
.session-row .when {
  font-size: 13.5px;
  color: var(--text);
}
.session-row .when .sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-3);
  font-family: var(--mono);
  margin-top: 2px;
}
.session-row .status-tag {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.session-row.done .when { color: var(--text-2); }
.session-row.done .status-tag { color: var(--ok); }
.session-row.due { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.session-row.due .status-tag { color: var(--accent); }

/* Prediction check grid */
.check-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 6px 0 0;
}
.check-cell {
  aspect-ratio: 1.4 / 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.12s ease;
}
.check-cell:hover:not(.done):not(.locked) { border-color: var(--accent); background: var(--accent-soft); }
.check-cell.done { background: var(--surface); cursor: default; }
.check-cell.locked { opacity: 0.4; cursor: not-allowed; background: var(--surface); }
.check-cell .idx { font-family: var(--serif); font-size: 14px; color: var(--text-3); }
.check-cell.done .idx { color: var(--text); }
.check-cell .res {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.check-cell.done.yes .res { color: var(--ok); }
.check-cell.done.no .res { color: var(--danger); }
.check-cell.done.unsure .res { color: var(--warn); }
.check-cell.due { border-color: var(--accent); }

/* Dashboard mini */
.dash {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.dash-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: #fff;
}
.dash-tile .label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.dash-tile .value {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.dash-tile .value .sub { font-size: 13px; color: var(--text-3); margin-left: 4px; }

/* Confidence bar */
.conf-bar {
  position: relative;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 8px 0 4px;
}
.conf-bar .tick {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--border-strong);
}
.conf-bar .marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--accent);
}
.conf-bar .marker.before { background: var(--text-3); }
.conf-bar .marker-label {
  position: absolute;
  top: 100%;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--text-3);
  margin-top: 4px;
  white-space: nowrap;
}

/* Log timeline */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13px;
  align-items: center;
}
.log-row .ts {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
}
.log-row .badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.log-row .badge.ok { background: var(--ok-soft); color: #355a3f; }
.log-row .badge.no { background: var(--danger-soft); color: #6b2828; }

/* Comparison block */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 12px 0;
}
.compare-col .lbl {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.compare-col .body {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  min-height: 80px;
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Modal */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(40, 38, 32, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  animation: fadeIn 0.14s ease;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 24px 20px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 18px 48px rgba(40, 38, 32, 0.18);
  animation: modalIn 0.16s ease;
}
.modal h3 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 10px;
  font-weight: 500;
}
.modal p {
  font-size: 14px;
  color: var(--text-2);
  margin: 0 0 16px;
  line-height: 1.55;
}
.modal .btn-row { margin-top: 18px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toastIn 0.18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px) } to { opacity: 1; transform: translate(-50%, 0) } }

/* Final / completed */
.final {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  background: var(--surface);
}
.final .stamp {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--ok);
  color: var(--ok);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.final h1 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 500;
  margin: 0 0 14px;
}
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 32px;
  margin-top: 22px;
}
.summary-grid dt {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 2px;
}
.summary-grid dd {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.3;
}

/* Skip-time pill */
.skip-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 9px;
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--mono);
  transition: all 0.12s ease;
}
.skip-pill:hover { border-color: var(--accent); color: var(--accent); }
.skip-pill .arrow { font-family: var(--mono); font-size: 12px; }

/* Pulse dot for "due now" */
.pulse {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  position: relative;
}
.pulse::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.6); opacity: 1 }
  100% { transform: scale(1.6); opacity: 0 }
}

/* Small label rows */
.kv { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); margin-top: 4px; }
.kv b { color: var(--text); font-weight: 500; }
.kv .sep { color: var(--text-3); }

/* Connection rows on step 2 */
.connection-row {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}
.connection-row .btn { align-self: start; margin-top: 1px; }

/* Context picker for step 4 */
.ctx-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { margin: 0; }
  .sidebar .back-to-goals { margin: 0; }
  .sidebar > div:has(.pipeline) { display: none; }
  .sidebar > div:has(.side-section-label) { display: none; }
  .rule-widget { width: 100%; }
  .main { padding: 20px 16px 40px; }
  .top-bar { padding: 10px 0; }
  .dash { grid-template-columns: 1fr 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: repeat(5, 1fr); }
  .compare { flex-direction: column; }
  .compare-col { width: 100%; }
}

@media (max-width: 480px) {
  .sidebar { padding: 10px 12px; }
  .main { padding: 16px 12px 32px; }
  .page-title { font-size: 24px; }
  .card { padding: 14px; }
  .dash { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(4, 1fr); }
  .btn-row { flex-wrap: wrap; }
  .field { gap: 6px; }
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}
