/* ---------------------------------------------------------------------------
   Design tokens
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #f5f5f7;
  --border: #d2d2d7;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --accent: #0071e3;
  --accent-contrast: #ffffff;
  --danger: #d70015;
  --success: #1d7a3a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-muted: #2c2c2e;
    --border: #3a3a3c;
    --text: #f5f5f7;
    --text-muted: #98989d;
    --accent: #0a84ff;
    --danger: #ff453a;
    --success: #30d158;
    --shadow: 0 4px 24px rgba(0, 0, 0, .5);
  }
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, p, dl, dd, dt, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--accent); }
code { font-size: .9375em; }

/* Sign-in pages centre one card; account pages use normal document flow. */
body.centered {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.muted { color: var(--text-muted); font-size: .875rem; }
.hint { margin-top: .25rem; color: var(--text-muted); font-size: .8125rem; }

/* ---------------------------------------------------------------------------
   Site chrome
   --------------------------------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: center;
  justify-content: space-between;
  max-width: 48rem;
  margin: 0 auto;
  padding: .75rem 1.5rem;
}
.brand { color: var(--text); font-weight: 600; text-decoration: none; }
.site-nav { display: flex; gap: .25rem; }
.site-nav a {
  padding: .375rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .9375rem;
  text-decoration: none;
}
.site-nav a:hover { background: var(--surface-muted); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--surface-muted); color: var(--text); font-weight: 600; }

.identity { display: flex; align-items: center; gap: .75rem; }
.avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: .8125rem;
  font-weight: 600;
}
.identity-text { display: flex; flex-direction: column; line-height: 1.25; }
.identity-name { font-size: .9375rem; font-weight: 600; }
.identity-email { color: var(--text-muted); font-size: .8125rem; }
.identity-action { margin: 0; }

.site-footer {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  color: var(--text-muted);
  font-size: .8125rem;
}

/* ---------------------------------------------------------------------------
   Sign-in card
   --------------------------------------------------------------------------- */
.card {
  width: 100%;
  max-width: 24rem;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.card .actions .btn { width: 100%; }

.divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: .8125rem;
}
.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------------------------------------------------------------------------
   Account pages
   --------------------------------------------------------------------------- */
.page { max-width: 44rem; margin: 0 auto; padding: 2.5rem 1.5rem; }
.page-heading { margin-bottom: 1.5rem; }
.page-heading h1 { font-size: 1.75rem; }
.page-heading .muted { margin-top: .25rem; }

.panel {
  margin-bottom: 1rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel-title { margin-bottom: .75rem; font-size: 1.125rem; }
.panel-danger { border-color: var(--danger); }
.panel-danger .panel-title { color: var(--danger); }

.profile {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  gap: .5rem 1rem;
  font-size: .9375rem;
}
.profile dt { color: var(--text-muted); }
.profile dd { overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  margin-left: .5rem;
  padding: .0625rem .4375rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  vertical-align: middle;
}

.status { font-size: .9375rem; font-weight: 600; }
.status-on { color: var(--success); }

.qr {
  display: block;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
code.secret {
  display: block;
  margin-bottom: 1rem;
  padding: .5rem .75rem;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  word-break: break-all;
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.form { margin-top: 1rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .25rem; font-size: .875rem; font-weight: 600; }
.field input {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field input:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.field-check label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.field-check input { width: auto; }
.actions { display: flex; gap: .5rem; }

.btn {
  display: inline-block;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-muted); }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-google { display: block; background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-small { padding: .3125rem .625rem; font-size: .8125rem; }

/* ---------------------------------------------------------------------------
   Alerts
   --------------------------------------------------------------------------- */
.alert { margin-bottom: 1rem; padding: .625rem .75rem; border-radius: var(--radius-sm); font-size: .875rem; }
.alert-error { background: rgba(215, 0, 21, .12); color: var(--danger); }
.alert-notice { background: rgba(29, 122, 58, .12); color: var(--success); }

/* ---------------------------------------------------------------------------
   Sessions
   --------------------------------------------------------------------------- */
.sessions { display: flex; flex-direction: column; gap: .75rem; }
.session {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
/* The info side holds a long, unbreakable user agent string, so it must be
   allowed to shrink below its content width before that string can wrap. */
.session-info { min-width: 0; }
.session-title { font-size: .9375rem; font-weight: 600; }
.session-device { overflow-wrap: anywhere; }
.session-action { flex: 0 0 auto; }

/* ---------------------------------------------------------------------------
   Narrow screens
   --------------------------------------------------------------------------- */
@media (max-width: 30rem) {
  .profile { grid-template-columns: 1fr; gap: .125rem; }
  .profile dd { margin-bottom: .5rem; }
  .session { flex-direction: column; }
  .page { padding: 1.5rem 1rem; }
}
