:root {
  color-scheme: light dark;
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #1f1a14;
  --muted: #6b6258;
  --line: #e4dccf;
  --accent: #8a4b12;
  --accent-text: #ffffff;
  --danger: #a3261c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f;
    --card: #221c16;
    --text: #f3ece1;
    --muted: #b3a695;
    --line: #3a3128;
    --accent: #e0a35a;
    --accent-text: #1b130a;
    --danger: #ff8d80;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 3rem 1rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  width: 100%;
  max-width: 26rem;
  padding: 1.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

h1 { margin: 0 0 0.5rem; font-size: 1.35rem; line-height: 1.25; }
h2 { margin: 1.5rem 0 0.5rem; font-size: 1rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.notice { padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }
.error { color: var(--danger); }
[hidden] { display: none !important; }

button, input[type="email"], input[type="password"] {
  font: inherit;
  color: inherit;
}

button {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: 0.55; cursor: default; }
button + button, form button, .stack > * + * { margin-top: 0.6rem; }
button.link { display: inline; width: auto; padding: 0; background: none; border: 0; color: var(--accent); text-decoration: underline; }

input[type="email"], input[type="password"] {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.tabs { display: flex; gap: 0.5rem; margin: 1rem 0; }
.tabs button { margin: 0; }
.tabs button[aria-selected="true"] { border-color: var(--accent); font-weight: 600; }
.divider { margin: 1rem 0; text-align: center; color: var(--muted); font-size: 0.85rem; }

ul.scopes { margin: 0 0 1rem; padding: 0; list-style: none; }
ul.scopes li + li { margin-top: 0.5rem; }
label.scope { display: flex; gap: 0.6rem; align-items: flex-start; }
label.scope input { margin-top: 0.3rem; }

table.grants { width: 100%; border-collapse: collapse; }
table.grants td { padding: 0.6rem 0; border-top: 1px solid var(--line); vertical-align: top; }
table.grants button { width: auto; padding: 0.35rem 0.8rem; }
