/* Base styles for every page. Colours, fonts and effects come from the active theme's CSS variables. */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body), ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3 { margin: 0; line-height: 1.15; }
h1, h2 { font-family: var(--font-display), ui-monospace, monospace; font-weight: 400; text-shadow: var(--glow); }
h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); }
h2 { font-size: 1.9rem; }
p { margin: 0; max-width: 68ch; }

/* The page uses the whole window unless the theme sets a width ("page_width" -> --page-width). */
.page-wrap {
  max-width: var(--page-width, none);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-inline: clamp(0px, 1.6vw, 32px);
}
.page-main { flex: 1; padding-top: 8px; }
/* Space between the sections a page slot stacks. */
.page-main > * + * { margin-top: 40px; }

/* CRT scanlines; strength comes from the theme (0 turns them off). */
.page-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 45;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, var(--scanlines)) 0 1px, transparent 1px 3px);
}

[data-ui="i18n-missing"] { color: var(--warn); }

/* Buttons, shared by forms, links and other components. */
.btn {
  display: inline-block;
  padding: 7px 14px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-small { padding: 3px 9px; font-size: .78rem; }
.btn + .btn { margin-left: 8px; }
.btn-danger { border-color: var(--bad); color: var(--bad); }
/* Buttons only admins see (dev tools), in the theme's admin colour. */
.btn-admin { border: 1px dashed var(--admin, var(--warn)); color: var(--admin, var(--warn)); }

/* Small rounded label (status, tags). */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .72rem;
  white-space: nowrap;
  color: var(--muted);
}
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-good { color: var(--good); border-color: var(--good); }
.pill-bad { color: var(--bad); border-color: var(--bad); }

/* Form controls, shared by every component that has inputs. */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], textarea, select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
textarea { min-height: 90px; resize: vertical; }
[aria-invalid="true"] { border-color: var(--bad); }
.form-group { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; border: 0; }
.form-group legend { padding: 0; margin-bottom: 6px; font-size: .85rem; color: var(--muted); }
.form-check { display: flex; gap: 8px; align-items: center; font-size: .86rem; }
.form-error { color: var(--bad); font-size: .85rem; }


/* Tick boxes and radio buttons in the theme's accent colour. */
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

/* The file picker's button looks like the site's buttons. */
input[type=file] { font-size: .85rem; color: var(--muted); }
input[type=file]::file-selector-button { margin-right: 10px; padding: 6px 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--accent); }
