:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --text: #1b1c1a;
  --muted: #6a6c66;
  --border: #dcddd7;
  --input-bg: #ffffff;
  --accent: #2d5a4c;
  --accent-hover: #234a3e;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --focus-ring: 0 0 0 3px rgb(45 90 76 / 0.25);
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 12px 32px rgb(0 0 0 / 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131412;
    --surface: #1c1d1b;
    --text: #ebece7;
    --muted: #9fa199;
    --border: #2f312d;
    --input-bg: #161715;
    --accent: #7cbca6;
    --accent-hover: #93cab7;
    --accent-text: #0e1a16;
    --danger: #f8877d;
    --danger-bg: #3b1916;
    --focus-ring: 0 0 0 3px rgb(124 188 166 / 0.3);
    --shadow: none;
    color-scheme: dark;
  }
}

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

html, body { margin: 0; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.brand-name { font-weight: 650; }

/* Buttons */
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }

.btn-primary {
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  transition: background-color 120ms ease;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}
.btn-secondary:hover { border-color: var(--muted); }

.link-btn {
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}
.link-btn:hover { color: var(--text); }

button:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Login */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

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

.login-sub { margin: 6px 0 24px; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.875rem; font-weight: 600; }
.field input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.field input:focus-visible { border-color: var(--accent); }

.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field .link-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.form-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.875rem;
}
.form-error[hidden] { display: none; }

/* App shell */
.auth-pending { visibility: hidden; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }

.user-email {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main { max-width: 960px; margin: 0 auto; padding: 32px 16px; }
.app-main p { margin: 6px 0 0; }

@media (max-width: 480px) {
  .login-card { padding: 28px 20px; }
  .user-email { display: none; }
}
