:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #555555;
  --border: #d0d4dc;
  --field: #f4f5f8;
  --accent: #00c2a8;
  /* The app's textAccent: the brand teal is too light for text on white. */
  --accent-text: #00806f;
  --on-accent: #0b1a17;
  --error: #c62828;
  --error-bg: #fdecea;
  /* The meter's middle grade: an amber dark enough to read as text on white — 5.0:1, over the
     4.5:1 WCAG AA asks of the 14px label. #b26a00 looked close enough and was 4.2:1. */
  --warn: #a35f00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f2f2f2;
    --muted: #b0b0b0;
    --border: #3a3f48;
    --field: #1e2126;
    --error: #ff8a80;
    --error-bg: #3a1f1f;
    --warn: #ffb74d;
    --accent-text: #00c2a8;
  }
}

/* The pages switch state with the hidden attribute; a display rule below must not undo it. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 32rem;
  margin: 0 auto;
  padding: 3rem 1rem;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.25;
}

p {
  color: var(--muted);
}

strong {
  color: var(--fg);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

form p {
  margin: 0;
}

label {
  font-weight: 600;
}

input[type="password"],
input[type="text"] {
  font: inherit;
  color: var(--fg);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

input.strong {
  border-color: var(--accent);
}

/* The strength meter: four segments, score + 1 of them filled, in a colour that grades with the
   score so Weak never looks like Strong. Advice only; the app's meter follows this one (#281). */
.strength {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.strength-track {
  flex: 1;
  display: flex;
  gap: 6px;
}

.strength-track span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background-color 0.2s;
}

.strength-track[data-score="0"] span:nth-child(-n + 1) {
  background: var(--error);
}

.strength-track[data-score="1"] span:nth-child(-n + 2) {
  background: var(--warn);
}

.strength-track[data-score="2"] span:nth-child(-n + 3),
.strength-track[data-score="3"] span {
  background: var(--accent);
}

.strength-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-text);
}

.strength-label[data-score="0"] {
  color: var(--error);
}

.strength-label[data-score="1"] {
  color: var(--warn);
}

/* The app's rules card (Change password): a circle until the rule is met, then a tick. */
.rules {
  list-style: none;
  margin: 0.25rem 0;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--field);
}

.rules li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
}

/* The glyph is decoration: the hidden ", met" / ", not met" text is what a screen reader reads.
   The `/ ""` form gives it empty alt text; a browser without it keeps the first declaration. */
.rules li::before {
  content: "○";
  content: "○" / "";
  width: 1.1rem;
  text-align: center;
  color: var(--muted);
}

.rules li.met {
  color: var(--fg);
}

.rules li.met::before {
  content: "✓";
  content: "✓" / "";
  font-weight: 700;
  color: var(--accent-text);
}

/* Read by a screen reader, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.footnote {
  font-size: 0.875rem;
}

.field-error {
  font-size: 0.875rem;
  color: var(--error);
}

.banner {
  color: var(--error);
  background: var(--error-bg);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
}

button {
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
  width: 100%;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.reference {
  font-size: 0.75rem;
  word-break: break-all;
}
