/* Общая основа всех утилит: токены, сброс, типографика, кнопки, тост. */

[hidden] { display: none !important; }

:root {
  /* нативные контролы (чекбоксы, range, скроллбары) должны следовать теме страницы */
  color-scheme: light dark;
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f5f2ed;
  --ink: #1c1917;
  --muted: #78716c;
  --border: #e7e2da;
  --accent: #16a34a;
  --accent-ink: #14532d;
  --accent-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 4px 16px rgba(28, 25, 23, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --surface: #221f19;
    --surface-2: #2b2721;
    --ink: #f5f2ed;
    --muted: #a8a29e;
    --border: #3a352d;
    --accent: #22c55e;
    --accent-ink: #bbf7d0;
    --accent-soft: #14361f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0c;
    --danger: #f87171;
    --danger-soft: #3b1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.app-wide { max-width: 720px; }

/* ---------- Кнопки ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 18px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-ink); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:active { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-tiny { padding: 8px 12px; min-height: 36px; font-size: .875rem; border-radius: 8px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(520px, calc(100vw - 32px));
  padding: 13px 18px;
  border-radius: 10px;
  font-size: .9375rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
  animation: rise .22s ease;
}
.toast-error { background: var(--danger); }
.toast-ok { background: var(--accent); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Запасное окно копирования ---------- */

.copy-fallback {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, .5);
  padding: 16px;
}
.copy-sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  margin-bottom: var(--safe-b);
}
.copy-sheet p { font-size: .875rem; color: var(--muted); }
.copy-sheet textarea {
  width: 100%;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
}
@media (min-width: 560px) { .copy-fallback { align-items: center; } }
