/* Общая основа для мини-проектов: токены, типографика, кнопки, поля, фокус */
:root {
  color-scheme: light dark;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #eeece6;
  --ink: #16181a;
  --muted: #565b61;
  --line: #dcd9d0;
  --accent: #1f7a4d;
  --accent-ink: #165c3a;
  --on-accent: #ffffff;
  --danger: #b83a2d;
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;
  --ease: cubic-bezier(.22, .8, .26, 1);
  --shadow: 0 1px 2px rgba(20, 22, 24, .06), 0 8px 24px rgba(20, 22, 24, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101211;
    --surface: #181b19;
    --surface-2: #202421;
    --ink: #eceee9;
    --muted: #9aa19b;
    --line: #2a2f2b;
    --accent: #5fd08f;
    --accent-ink: #7fe0a7;
    --on-accent: #08140d;
    --danger: #ff7b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  }
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
p { text-wrap: pretty; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.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;
}
.i { width: 1.25em; height: 1.25em; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Верхняя панель: одна строка, до 64px */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px; padding: 0 clamp(16px, 3vw, 32px);
  position: relative; z-index: 20;
}
.topbar .back {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding-right: 12px; text-decoration: none; font-weight: 500; color: var(--muted);
  transition: color .2s var(--ease);
}
.topbar .back:hover { color: var(--ink); }
.topbar .back .i { transition: transform .25s var(--ease); }
.topbar .back:hover .i { transform: translateX(-3px); }
.topbar .name { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
@media (max-width: 480px) { .topbar .write span { display: none; } .topbar .back { padding-right: 0; } }
.topbar .write {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  text-decoration: none; font-weight: 500; color: var(--muted);
  transition: color .2s var(--ease);
}
.topbar .write:hover { color: var(--ink); }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 20px; border-radius: 12px;
  font-weight: 600; text-decoration: none; border: 1px solid transparent;
  transition: transform .18s var(--ease), background-color .2s, border-color .2s, color .2s, opacity .2s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line); background: transparent; color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); background: var(--surface-2); }
.btn-quiet { color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn-sm { min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: .9rem; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; }
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Поля */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: .84rem; font-weight: 600; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--muted) 60%, var(--line)); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.error { color: var(--danger); font-size: .84rem; min-height: 1.2em; }
.help { color: var(--muted); font-size: .84rem; }

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

/* О проекте: кнопка в верхней панели и диалог */
.topbar .actions { display: inline-flex; align-items: center; gap: 4px; }
.topbar .about {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  background: none; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 500; color: var(--muted);
  transition: color .2s var(--ease), background-color .2s;
}
.topbar .about:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
@media (max-width: 480px) { .topbar .about span { display: none; } .topbar .about { padding: 0; width: 44px; justify-content: center; } }
.case {
  width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 720px); overflow: auto;
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px -16px rgba(0,0,0,.35);
}
.case::backdrop { background: rgba(10,12,11,.55); }
.case[open] { animation: case-in .22s var(--ease); }
@keyframes case-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .case[open] { animation: none; } }
.case-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 0; }
.case-head h2 { font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
.case-close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: -8px -8px 0 0; border: 0; border-radius: 10px;
  background: none; color: var(--muted); cursor: pointer;
}
.case-close:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.case-body { padding: 8px 24px 24px; display: grid; gap: 20px; }
.case-body h3 { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.case-body p, .case-body li { line-height: 1.6; }
.case-body ul { padding-left: 1.1em; display: grid; gap: 6px; }
.case-body li::marker { color: var(--accent); }
.case-stack { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.case-stack li { font-family: var(--mono); font-size: .8125rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.case-note { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.topbar .back, .topbar .actions { flex: none; }
.topbar .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .topbar .back span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .topbar .back { width: 44px; justify-content: center; padding: 0; }
}
.case { margin: auto; }
.case-body ul.case-stack { display: flex; flex-wrap: wrap; padding: 0; gap: 8px; }
.case-body ul.case-stack li { width: auto; }
.case-close { background: transparent; }

/* Движение: нажатия, волна, появление строк */
@keyframes fx-ripple { from { transform: scale(0); opacity: .26; } to { transform: scale(1); opacity: 0; } }
@keyframes row-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes row-out { to { opacity: 0; transform: translateX(18px) scale(.98); } }
@keyframes sel-pop { 0% { transform: scale(.98); } 45% { transform: scale(1.025); } 100% { transform: none; } }
@keyframes draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
.fx-ripple {
  position: absolute; border-radius: 50%; background: currentColor; pointer-events: none;
  transform: scale(0); opacity: 0; animation: fx-ripple .65s cubic-bezier(.2, .7, .2, 1) forwards;
}
.enter { animation: row-in .38s var(--ease) both; }
.leaving { animation: row-out .2s var(--ease) forwards; pointer-events: none; }

.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent 32%, rgba(255,255,255,.3) 50%, transparent 68%);
  transform: translateX(-125%); transition: transform .75s var(--ease);
}
.btn .i { transition: transform .25s var(--ease); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .btn:not([disabled]):not([aria-disabled="true"]):hover { transform: translateY(-1px); }
  .btn-primary:hover { box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--accent) 80%, transparent); }
  .btn-primary:hover::before { transform: translateX(125%); }
  .btn:hover > .i:last-child:not(:first-child) { transform: translateX(3px); }
}
.btn:not([disabled]):not([aria-disabled="true"]):active { transform: translateY(1px) scale(.96); transition-duration: .08s; }
.topbar .about:active, .case-close:active { transform: scale(.93); }
.topbar .about, .case-close { position: relative; overflow: hidden; transition: color .2s var(--ease), background-color .2s, transform .15s var(--ease); }
