* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
}

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

a { color: var(--accent); }

a:hover { color: var(--fg); }

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

/* Site chrome: cryptoys / <name> */
.site-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--chrome-height);
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.site-nav {
  display: flex;
  align-items: baseline;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 14px;
}

.site-brand {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.site-brand:hover {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-sep {
  color: var(--muted);
  margin: 0 0.55em;
  user-select: none;
}

.site-current { color: var(--fg); }

button.chrome-action {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 14px;
}

button.chrome-action:hover {
  background: transparent;
  color: var(--accent);
  filter: none;
}

/* Buttons: secondary default, primary for Play/Start */
button {
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--fg);
}

button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

button.primary:hover {
  filter: brightness(1.08);
  background: var(--accent);
  color: var(--accent-fg);
}

button.inline-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  border-radius: 0;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.inline-link:hover {
  background: none;
  filter: none;
  color: var(--fg);
}

/* Forms */
textarea, input[type="text"] {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.slider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 14px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--line);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--line);
  border: 0;
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.row { display: flex; flex-wrap: wrap; gap: 8px; }

.error {
  margin: 0;
  min-height: 1.2em;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Spec dialog */
dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  border-radius: var(--radius-lg);
  padding: 0;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.62); }

.spec-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 13px;
}

#spec-body {
  padding: 8px 28px 40px;
  overflow: auto;
  max-height: calc(100dvh - 110px);
  font-size: 16px;
  line-height: 1.6;
}

#spec-body > * { max-width: var(--measure); }

#spec-body pre,
#spec-body table,
#spec-body .highlight {
  max-width: 100%;
}

#spec-body h1,
#spec-body h2,
#spec-body h3 {
  font-family: var(--font-display);
  font-weight: 520;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

#spec-body h1 {
  font-size: 2rem;
  margin: 1.15em 0 0.45em;
}

#spec-body h2 {
  font-size: 1.35rem;
  margin: 1.7em 0 0.5em;
  padding-bottom: 0.28em;
  border-bottom: 1px solid var(--line);
}

#spec-body h3 {
  font-size: 1.1rem;
  margin: 1.4em 0 0.4em;
}

#spec-body a { color: var(--accent); }

#spec-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

#spec-body pre {
  overflow: auto;
  background: var(--raised);
  border: 1px solid var(--line);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}

#spec-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  margin: 1em 0;
}

#spec-body th,
#spec-body td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px 12px 8px 0;
  vertical-align: top;
}

#spec-body th { color: var(--muted); font-weight: 600; }

#spec-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}
