/* Базовые стили и общие компоненты: кнопки, поля, карточки, бейджи, модальные окна, тосты. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
/* Курсив в проекте не используется: акцентные слова выделяются только цветом */
em, i, cite, var, dfn, address { font-style: normal; }
.accent-word { color: var(--lavender); }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: 14px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 22px; border: 1px solid transparent; border-radius: var(--r-pill);
  font-weight: 700; font-size: 14px; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast);
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-dark { background: var(--accent-deep); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-soft { background: var(--accent-soft); color: var(--text); }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { min-height: 54px; padding: 0 30px; font-size: 16px; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: transparent; color: var(--text-2); }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
  .btn-dark:hover:not(:disabled) { background: #4C1293; }
  .btn-ghost:hover:not(:disabled) { border-color: var(--accent); }
  .btn-soft:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 26%, transparent); }
  .btn-icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
}
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Поля ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12px; }
.input, .textarea, .select {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  font-size: 16px; transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); background-color: var(--surface); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

/* ---------- Карточки, бейджи ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 24px; }
.card-gradient { background: var(--gradient-card); border-color: transparent; color: #fff; }
.card-gradient .muted { color: rgba(255, 255, 255, .78); }
.card-interactive { cursor: pointer; transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), border-color var(--t-fast); }
@media (hover: hover) { .card-interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); } }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.badge-dir { --dir: var(--accent); background: color-mix(in srgb, var(--dir) 18%, transparent); color: color-mix(in srgb, var(--dir) 70%, var(--text)); }
.mono {
  --dir: var(--accent);
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: color-mix(in srgb, var(--dir) 20%, transparent); color: color-mix(in srgb, var(--dir) 75%, var(--text));
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-high { background: var(--bad); } .dot-medium { background: var(--ok); } .dot-low { background: var(--text-3); }

/* ---------- Сегментированный переключатель ---------- */
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border-radius: var(--r-pill); }
.segmented button { min-height: 32px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }

/* ---------- Модальное окно ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--scrim); backdrop-filter: blur(6px); animation: fade-in var(--t-base) var(--ease); }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); animation: pop-in var(--t-base) var(--ease); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 0; }
.modal-head h2 { font-size: 20px; }
.modal-body { display: grid; gap: 16px; padding: 20px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 24px; flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }

/* ---------- Тосты ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); font-size: 14px; pointer-events: auto; animation: toast-in var(--t-base) var(--ease); }
.toast-error { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.toast-success { border-color: color-mix(in srgb, var(--good) 60%, transparent); }
.toast span { flex: 1; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 4px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
