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

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-text);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  /* перфопанель мастерской */
  background-image: radial-gradient(circle at center, var(--bg-dot) 1.7px, transparent 1.9px);
  background-size: 22px 22px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.15;
  font-weight: 650;
}

h1,
h2,
.display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(var(--fs-2xl), 4.2vw, var(--fs-4xl));
  font-weight: 650;
}

h2 {
  font-size: clamp(var(--fs-xl), 2.6vw, var(--fs-2xl));
  font-weight: 600;
}

h3 {
  font-size: var(--fs-lg);
}

p {
  margin: 0;
}

a {
  color: var(--brand);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--ink-3);
}

.small {
  font-size: var(--fs-sm);
}

.xsmall {
  font-size: var(--fs-xs);
}

@media (max-width: 640px) {
  .hide-sm {
    display: none;
  }
}

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

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.4rem;
  border: 1.5px solid var(--btn-line);
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 600;
  font-size: var(--fs-md);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.08s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--ink-3);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Главная кнопка — «клавиша»: нижняя грань темнее, нажимается физически. */
.btn--primary {
  --btn-bg: var(--brand);
  --btn-ink: var(--brand-ink);
  --btn-line: transparent;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  padding-bottom: 3px;
}

.btn--primary:hover {
  --btn-bg: var(--brand-strong);
  border-color: transparent;
}

.btn--primary:active {
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  padding-bottom: 1px;
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-line: transparent;
  --btn-ink: var(--ink-2);
}

.btn--ghost:hover {
  --btn-bg: var(--surface-3);
  border-color: transparent;
}

.btn--danger {
  --btn-ink: var(--bad);
  --btn-line: color-mix(in srgb, var(--bad) 45%, transparent);
}

.btn--sm {
  min-height: 38px;
  padding: 0 1rem;
  font-size: var(--fs-sm);
}

.btn--lg {
  min-height: 56px;
  padding: 0 1.8rem;
  font-size: var(--fs-lg);
}

.btn--block {
  width: 100%;
}

.icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.icon-btn[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* ---------------------------------------------------------------- поля */

.field {
  display: grid;
  gap: 0.4rem;
}

.field__label {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-md);
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rgb) 35%, transparent);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--bad-fill);
}

input[type="checkbox"][aria-invalid="true"] {
  outline: 2px solid var(--bad-fill);
  outline-offset: 2px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- чипы */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 550;
  font-size: var(--fs-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--ink);
}

.chip__count {
  min-width: 1.5em;
  padding: 0 0.4em;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  text-align: center;
}

/* ---------------------------------------------------------------- метки */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}

.tag--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.tag--bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.tag--brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.tag--muted {
  background: var(--surface-3);
  color: var(--ink-3);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  padding: clamp(1rem, 2.2vw, 1.5rem);
}

.stack {
  display: grid;
  gap: var(--gap);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

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