*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.5;
  font-feature-settings: 'tnum' 0;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
h1 {
  font-size: 1.375rem;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.015em;
}
h2 {
  font-size: 0.9375rem;
  line-height: 1.35;
  font-weight: 600;
}
h3 {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}
p {
  line-height: 1.55;
}
small {
  font-size: 0.75rem;
  color: var(--text-3);
  line-height: 1.45;
}
a {
  color: var(--cobalt-text);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover {
  text-decoration-thickness: 2px;
}
code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
}
.num {
  font-variant-numeric: tabular-nums;
}
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
::selection {
  background: var(--cobalt-soft-2);
}
::placeholder {
  color: var(--text-3);
  opacity: 1;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.muted {
  color: var(--text-3);
}

/* Buttons: one shape (6px radius) for every action; colour carries the weight. */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--btn-border);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.btn:hover {
  --btn-bg: var(--surface-2);
  --btn-border: var(--text-3);
  text-decoration: none;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn svg {
  flex: none;
}
.btn-primary {
  --btn-bg: var(--cobalt);
  --btn-fg: #fff;
  --btn-border: var(--cobalt);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.14) inset,
    0 1px 2px rgb(16 24 40 / 0.18);
}
.btn-primary:hover {
  --btn-bg: var(--cobalt-strong);
  --btn-border: var(--cobalt-strong);
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-fg: var(--text-2);
}
.btn-ghost:hover {
  --btn-bg: var(--surface-3);
  --btn-border: transparent;
  --btn-fg: var(--text);
}
.btn-danger {
  --btn-fg: var(--red-text);
  --btn-border: var(--red-line);
}
.btn-danger:hover {
  --btn-bg: var(--red-soft);
  --btn-border: var(--red);
}
.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}
.btn-lg {
  min-height: 44px;
  padding: 0 18px;
  font-size: 0.875rem;
}
.icon-btn {
  min-width: 36px;
  padding: 0;
}
.icon-btn.btn-sm {
  min-width: 30px;
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cobalt-text);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Form controls */
.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
  transition:
    border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease),
    background-color var(--dur-1) var(--ease);
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--text-3);
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cobalt) 26%, transparent);
}
.input[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--red);
}
.input:disabled,
.select:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}
.select {
  appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) 52%,
    calc(100% - 10px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.select option {
  background: var(--surface);
  color: var(--text);
}
.textarea {
  resize: vertical;
  line-height: 1.55;
}
input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--cobalt);
  cursor: pointer;
}
input[type='date'] {
  color-scheme: inherit;
}
.check-line {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  font-size: 0.8125rem;
  cursor: pointer;
}

/* Switch (checkbox with role=switch) */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.8125rem;
  min-height: 32px;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 34px;
  height: 20px;
  margin: 0;
}
.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--control-off);
  transition: background-color var(--dur-2) var(--ease);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform var(--dur-2) var(--ease);
}
.switch input:checked + .switch-track {
  background: var(--teal);
}
.switch-cobalt input:checked + .switch-track {
  background: var(--cobalt);
}
.switch-amber input:checked + .switch-track {
  background: var(--amber-line);
}
.switch-row {
  display: grid;
  gap: 2px;
}
.switch-label {
  font-weight: 500;
}
.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}
.switch input:focus-visible + .switch-track {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

kbd {
  display: inline-flex;
  align-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.6875rem;
  justify-content: center;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 300;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
  transform: translateY(-160%);
  transition: transform var(--dur-2) var(--ease);
}
.skip-link:focus {
  transform: translateY(0);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

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