/* Reset, typography, form controls and focus. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body) / 1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

h1 {
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: 0.01em;
}

h2 {
  font-size: var(--fs-body);
  font-weight: 600;
}

h3 {
  font-size: var(--fs-min);
  font-weight: 600;
  color: var(--muted);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

code,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-min);
}

code {
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

kbd {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  white-space: nowrap;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

table {
  border-collapse: collapse;
  width: 100%;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

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

::selection {
  background: rgba(56, 189, 248, 0.35);
}

/* Thin scrollbars that match the dark surfaces */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
}

.skip-link:focus {
  top: 6px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--fs-min);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--card-hover);
}

.btn[aria-pressed='true'],
.btn.is-on {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06202d;
}

.btn--primary:hover:not(:disabled) {
  background: #6dcff9;
  border-color: #6dcff9;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn--icon {
  width: 30px;
  padding: 0;
}

.btn--small {
  height: 26px;
  padding: 0 8px;
}

.btn svg,
.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* Selects and inputs */
.select,
.input {
  height: 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: var(--fs-min);
  max-width: 100%;
}

.select:hover,
.input:hover {
  border-color: var(--accent-line);
}

.select option {
  background: var(--card);
  color: var(--text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.field__label {
  font-size: var(--fs-min);
  color: var(--muted);
}

input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
  flex: none;
}

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