:root {
  --ral-7022: #4a4744;   /* тёмный фон */
  --ral-7006: #6b5e54;   /* тёплый средний */
  --ral-7030: #8d8a85;   /* светло-серый */
  --ral-7032: #b8b4ad;   /* светло-серый тёплый */
  --ral-7047: #d4d2cd;   /* почти белый */
  --bg: #2b2725;
  --surface: #3a3633;
  --surface-hover: #45413d;
  --text: #e8e3dc;
  --text-dim: #a8a39c;
  --accent: #d4af8c;     /* тёплый акцент */
  --border: #4d4844;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.back {
  width: 36px; height: 36px;
  border: none; background: transparent;
  color: var(--text); font-size: 28px; font-weight: 300;
  cursor: pointer; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.back:hover, .back:active { background: var(--surface-hover); }
.brand { flex: 1; text-align: center; }
.logo {
  font-size: 18px; font-weight: 300; letter-spacing: 4px;
  color: var(--text);
}
.logo-sub {
  font-size: 10px; font-weight: 400; letter-spacing: 3px;
  color: var(--text-dim);
  margin-top: 2px;
}
.spacer { width: 36px; }
#main {
  flex: 1; padding: 24px 16px calc(24px + var(--safe-bottom));
}
.screen { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen-title {
  font-size: 22px; font-weight: 300;
  letter-spacing: 1px;
  margin-bottom: 20px;
  color: var(--text);
}
.subtitle { color: var(--text-dim); margin-bottom: 16px; font-size: 14px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit; font-size: 15px; font-weight: 400;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.menu-item:hover { background: var(--surface-hover); }
.menu-item:active { transform: scale(.98); }
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
  line-height: 1.65;
}
.article b, .article strong { font-weight: 600; color: var(--text); }
.article i, .article em { font-style: italic; color: var(--text-dim); }
.loader { text-align: center; color: var(--text-dim); padding: 80px 0; letter-spacing: 2px; }
.history-block { margin-top: 28px; }
.block-title {
  font-size: 14px; font-weight: 500; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 12px;
}
.history-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 14px;
}
.history-box.muted { color: var(--text-dim); }
.history-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: none; }
.history-row .cat { color: var(--text); }
.history-row .score { color: var(--accent); font-weight: 600; }
.history-salon {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; gap: 16px; flex-wrap: wrap;
}
.history-salon div { color: var(--text-dim); font-size: 13px; }
.history-salon b { color: var(--text); font-weight: 600; }
/* Quiz */
.quiz-progress {
  display: flex; justify-content: center; margin-bottom: 16px;
  color: var(--text-dim); font-size: 14px; letter-spacing: 2px;
}
.quiz-question {
  font-size: 18px; font-weight: 500;
  margin-bottom: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  line-height: 1.4;
}
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit; font-size: 15px;
  border-radius: 12px; cursor: pointer; text-align: left;
  transition: background .15s;
}
.quiz-option:hover { background: var(--surface-hover); }
.quiz-option.correct { background: #2d4a2d; border-color: #4a7a4a; }
.quiz-option.wrong { background: #4a2d2d; border-color: #7a4a4a; }
.quiz-option:disabled { cursor: default; }
.quiz-option .letter { font-weight: 600; margin-right: 8px; color: var(--accent); }
/* Result */
.result-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  margin-bottom: 20px;
}
.result-score { font-size: 32px; font-weight: 300; letter-spacing: 2px; }
.result-pct { font-size: 18px; color: var(--accent); margin-top: 8px; font-weight: 500; }
.result-detailed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  font-size: 14px;
  max-height: 280px; overflow-y: auto;
}
.detail-q { padding: 10px 0; border-bottom: 1px solid var(--border); }
.detail-q:last-child { border-bottom: none; }
.detail-q .ok { color: #6fa86f; }
.detail-q .ng { color: #c87a7a; }
.detail-q .exp { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.result-actions { display: flex; gap: 8px; }
.btn {
  flex: 1; padding: 14px;
  border: 1px solid var(--border);
  font-family: inherit; font-size: 15px; font-weight: 500;
  border-radius: 12px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--text); }
.btn:active { transform: scale(.98); }

/* Admin */
.menu-item.admin { border-color: #6b5e54; }
.menu-item.admin.super { background: #5a4d44; color: var(--ral-7047); }
.tests-admin-block { margin-top: 24px; }
.tests-admin-block .block-title { margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.stat-cell { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; }
.stat-cell .num { font-size: 28px; font-weight: 300; color: var(--accent); }
.stat-cell .lbl { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }
.user-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-name { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.user-cats { font-size: 12px; color: var(--text-dim); }
