:root {
  --bg: #f4f1ea;
  --bg-accent: #e8e1d2;
  --surface: #ffffff;
  --text: #1d2420;
  --muted: #5f6a63;
  --border: #d9d3c6;
  --brand: #2f4a3a;
  --brand-hover: #253b2e;
  --brand-ink: #f6f2e8;
  --focus: #7a9a6b;
  --error-bg: #fbeceb;
  --error-text: #8a2b22;
  --info-bg: #eef2e8;
  --info-text: #34503b;
  --shadow: 0 1px 2px rgba(29, 36, 32, 0.06), 0 12px 32px rgba(29, 36, 32, 0.08);
  color-scheme: light;
}

/* Light is the default; theme.js sets data-theme="dark" when chosen. */
:root[data-theme="dark"] {
  --bg: #121614;
  --bg-accent: #1a201c;
  --surface: #1b211e;
  --text: #ebe7dd;
  --muted: #a3aca6;
  --border: #2e3631;
  --brand: #a9c49a;
  --brand-hover: #bed6b0;
  --brand-ink: #142019;
  --focus: #a9c49a;
  --error-bg: #3a1f1c;
  --error-text: #f2b8b0;
  --info-bg: #1f2c22;
  --info-text: #c4dbb8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 400 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-accent), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 48px 16px;
  gap: 28px;
}

.brand { text-align: center; }
.brand h1 {
  margin: 12px 0 0;
  font: 500 32px/1.1 Fraunces, Georgia, serif;
  letter-spacing: -0.01em;
}
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.mark {
  display: inline-block;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand);
  position: relative;
}
.mark::after {
  content: "";
  position: absolute;
  left: 11px; right: 11px; top: 14px; height: 20px;
  border: 3px solid var(--brand-ink);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
}

/* Forms ------------------------------------------------------------------ */

.lede { margin: 0 0 20px; color: var(--muted); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }

input {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 120ms, box-shadow 120ms;
}
input[readonly] { color: var(--muted); background: var(--bg); }
input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

button { font-family: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.primary, .secondary {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 120ms, transform 80ms;
}
.primary { margin-top: 4px; color: var(--brand-ink); background: var(--brand); border: 0; }
.primary:hover { background: var(--brand-hover); }
.primary:active, .secondary:active { transform: scale(0.99); }
.primary:disabled { opacity: 0.7; cursor: progress; }
.secondary { color: var(--text); background: transparent; border: 1px solid var(--border); }
.secondary:hover { background: var(--bg); }

.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--error-text);
  background: var(--error-bg);
}
.notice[data-tone="info"] { color: var(--info-text); background: var(--info-bg); }

.switch { margin: 20px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.link {
  padding: 0;
  background: none;
  border: 0;
  font-size: inherit;
  font-weight: 500;
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Success / portal ------------------------------------------------------- */

.success { text-align: center; }
.success h2, .welcome { margin: 12px 0 8px; font: 500 22px/1.25 Fraunces, Georgia, serif; }
.success p { margin: 0 0 20px; color: var(--muted); }
.check {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--info-bg);
}
.check::after {
  content: "";
  width: 12px;
  height: 20px;
  margin-top: -4px;
  border: solid var(--info-text);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.welcome { margin-top: 0; }

.button-link { display: block; box-sizing: border-box; text-align: center; text-decoration: none; }
.notice.setup { margin-bottom: 20px; }

/* Theme toggle ----------------------------------------------------------- */

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background-color 120ms, transform 80ms;
}
.theme-toggle:hover { background: var(--bg); }
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
.theme-toggle.in-header { position: static; box-shadow: none; width: 36px; height: 36px; }
