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

/* Theme tokens change in one paint. Hover transitions stay for every other frame. */
html[data-theme-switching],
html[data-theme-switching] *,
html[data-theme-switching] *::before,
html[data-theme-switching] *::after {
  transition: none !important;
}

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

html {
  background-color: var(--bg);
}

body {
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

button { cursor: pointer; }

code, .mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  flex: none;
  vertical-align: middle;
}

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); }

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}
input[type="search"]:focus,
input[type="search"]:focus-visible {
  outline: none;
  box-shadow: none;
}
input[type="search"].input:focus,
input[type="search"].input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

::selection { background: var(--primary-soft); }

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

.muted { color: var(--text-muted); }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* iOS Safari zooms into any field under 16px on focus; Android does not */
@supports (-webkit-touch-callout: none) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}
