/* Element defaults, form controls and buttons shared by every screen. */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, h5, p, ul, figure, fieldset { margin: 0; }
h1, h2, h3, h4, h5 { text-wrap: balance; }
fieldset { border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }

kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0 5px;
  background: var(--shelf);
  white-space: nowrap;
}

.icon { display: block; flex: none; }

/* Quiet scrollbars that follow the theme. */
* { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }

.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-message { color: var(--ink-3); font-size: var(--t-sm); padding: 24px; }

.brand { display: flex; flex-direction: column; gap: 7px; }
.wordmark { font-family: "Literata", Georgia, serif; font-weight: 600; letter-spacing: -0.02em; line-height: 1; font-size: 1.9rem; }
.wordmark span { color: var(--thread); font-style: italic; }
.tagline { font-weight: 300; font-size: 1.03rem; letter-spacing: 0.015em; line-height: 1.3; color: var(--ink-2); }

/* form controls */
.input {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 7px 11px;
  font: inherit;
  font-size: var(--t-ui);
  background: var(--paper);
  color: var(--ink);
  min-height: 36px;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--thread); box-shadow: 0 0 0 3px var(--thread-wash); }
.mono, .input.mono { font-family: var(--font-mono); font-size: .88rem; }

.btn {
  display: inline-block;
  text-align: center;
  font-weight: 600;
  font-size: var(--t-ui);
  border-radius: var(--radius);
  padding: 8px 14px;
  background: var(--thread);
  color: var(--on-thread);
  border: 1px solid var(--thread);
}
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--rule); }
.btn.secondary:hover { background: var(--shelf); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--paper); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.text-btn { color: var(--thread); font-size: var(--t-sm); font-weight: 600; text-align: left; }
.text-btn:hover { text-decoration: underline; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--ink-3);
  flex: none;
}
.icon-btn:hover { color: var(--ink-2); background: var(--shelf); }
.icon-btn.on { color: var(--thread); background: var(--thread-wash); }
.icon-btn.small { width: 22px; height: 22px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-group { display: flex; flex-direction: column; gap: 14px; }
.field-label { font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.hint { font-size: var(--t-xs); color: var(--ink-3); line-height: 1.45; }
.hint.block { display: block; }
.strength[data-level="too-short"], .strength[data-level="weak"] { color: var(--caution); }
.strength[data-level="strong"] { color: var(--thread); }
.form-error { color: var(--danger); font-size: var(--t-sm); }
.warning { font-size: var(--t-sm); color: var(--caution); background: var(--caution-wash); border-radius: var(--radius); padding: 8px 10px; }
.checkline { display: flex; gap: 8px; align-items: center; font-size: var(--t-sm); color: var(--ink-2); }
.checkline input { accent-color: var(--thread); width: 15px; height: 15px; margin: 0; }
.muted { color: var(--ink-3); font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.empty-hint { font-size: var(--t-xs); color: var(--ink-3); }

/* switches: a visually hidden checkbox followed by .switch */
.toggle-label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: var(--t-sm); cursor: pointer; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { width: 28px; height: 16px; border-radius: 8px; background: var(--rule); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: left .15s; }
.switch-input:checked + .switch { background: var(--thread); }
.switch-input:checked + .switch::after { left: 14px; }
.switch-input:focus-visible + .switch { outline: 2px solid var(--thread); outline-offset: 2px; }

.caret-mirror { white-space: pre-wrap; overflow-wrap: break-word; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
