/* Shared look for every page on the site: tokens, base type, buttons, top bar, sign-in screen.
   Light is the base. Dark follows the device unless a person picks Light or Dark (data-theme on <html>).
   site.js sets --accent and --accent-ink from each person's chosen colour. */
/* iOS look: grouped backgrounds, white or dark-gray cards, system fonts, system colours. */
:root {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --ink: #000000;
  --muted: #6C6C70;
  --line: #C6C6C8;
  --accent: #007AFF;
  --accent-ink: #FFFFFF;
  --focus: #007AFF;
  --ok: #248A3D;
  --danger: #D70015;
  --hatch: #E5E5EA;
  --fill: rgba(118, 118, 128, .12);
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1C1C1E; --ink: #FFFFFF; --muted: #98989F; --line: #38383A;
    --focus: #0A84FF; --ok: #30D158; --danger: #FF453A; --hatch: #2C2C2E; --fill: rgba(118, 118, 128, .24);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1C1C1E; --ink: #FFFFFF; --muted: #98989F; --line: #38383A;
  --focus: #0A84FF; --ok: #30D158; --danger: #FF453A; --hatch: #2C2C2E; --fill: rgba(118, 118, 128, .24);
  color-scheme: dark;
}
/* Higher contrast: stronger text and borders in whichever mode is showing. */
:root[data-contrast="high"] { --muted: #3A3A3C; --line: #6C6C70; --ink: #000000; --hatch: #D1D1D6; }
@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"]:not([data-theme="light"]) { --muted: #D1D1D6; --line: #8E8E93; --ink: #FFFFFF; --hatch: #3A3A3C; }
}
:root[data-contrast="high"][data-theme="dark"] { --muted: #D1D1D6; --line: #8E8E93; --ink: #FFFFFF; --hatch: #3A3A3C; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 7vw, 3.4rem); line-height: 1; letter-spacing: .01em; text-transform: uppercase; text-wrap: balance; overflow-wrap: anywhere; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: .06em; text-transform: uppercase; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.wrap { max-width: 1040px; margin: 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border: 1.5px solid var(--ink); background: transparent; border-radius: 4px; cursor: pointer; text-decoration: none; color: var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: .06em; text-transform: uppercase;
}
.btn:hover { background: var(--hatch); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.ghost { border-color: transparent; padding-inline: 8px; }
.btn.small { min-height: 36px; font-size: 1rem; padding: 4px 12px; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: var(--surface); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  max-width: calc(100% - 32px); padding: 10px 16px; background: var(--ink); color: var(--bg); border-radius: 4px; font-size: .95rem;
}

/* The logo is a transparent mask, so it takes the page's ink color in light and dark. */
.logo {
  display: block; aspect-ratio: 756 / 1200; background-color: var(--ink);
  -webkit-mask: url(logo.png) center / contain no-repeat; mask: url(logo.png) center / contain no-repeat;
}

#sitebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1040px; margin: 0 auto 18px; min-height: 48px; }
#sitebar .brand { display: block; height: 48px; padding: 2px 8px 2px 0; flex: none; }
#sitebar .brand .logo { height: 100%; }
#sitebar .who { display: flex; align-items: center; gap: 2px; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
#sitebar .who a.name {
  min-width: 0; max-width: 11ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 8px; border-radius: 4px;
  font-family: var(--font-mono); font-size: .78rem; color: var(--muted); text-decoration: none;
}
#sitebar .who a.name:hover { background: var(--hatch); color: var(--ink); }

/* Locked: only the sign-in screen is visible. */
html.locked body > *:not(#gate) { display: none !important; }
#gate { min-height: 100vh; min-height: 100dvh; display: grid; align-items: start; padding-top: min(10vh, 72px); }
#gate .panel { width: min(400px, 100%); display: grid; gap: 18px; }
#gate .logo { height: 120px; }
#gate #gatebody { display: grid; gap: 14px; }
#gate form { display: grid; gap: 14px; }
#gate label.field { display: grid; gap: 6px; font-family: var(--font-mono); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
#gate input[type="text"], #gate input[type="password"], #gate input[type="email"] {
  min-height: 48px; padding: 8px 12px; width: 100%; background: var(--surface); border: 1.5px solid var(--line); border-radius: 4px;
  font-family: var(--font-body); font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--ink);
}
#gate input:focus { border-color: var(--ink); }
#gate .pwrow { display: flex; gap: 8px; }
#gate .pwrow input { flex: 1; min-width: 0; }
#gate .check { display: flex; gap: 10px; align-items: center; font-size: .95rem; color: var(--ink); cursor: pointer; }
#gate .check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
#gate .err { min-height: 1.4em; color: var(--danger); font-size: .95rem; }
#gate .fine { color: var(--muted); font-size: .9rem; }
#gate .linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .9rem; justify-self: start; }
