/* CaleanTech standard (same palette as lib/branding.ts CALEANTECH and the
   caleantech email family). Light theme only: the mark (mark-light.svg) is drawn
   for light backgrounds. Contrast on white: ink 10.3:1, muted 7.6:1, accent
   text and primary buttons 5.3:1, danger 6.6:1, field borders 4.8:1, focus ring
   5.3:1 (WCAG AA). */
:root {
  --brand: #30374e;
  --accent: #20c997;
  --accent-text: #0f7a5c;
  --accent-hover: #0b5c45;
  --light: #f8f9fa;
  --ink: #374151;
  --muted: #4b5563;
  --card: #ffffff;
  --line: #e5e7eb;
  --field-line: #6b7280;
  --danger: #b42318;
  --danger-hover: #8f1c13;
  --ok-bg: #ecfdf5;
  --warn-text: #92400e;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --error-bg: #fef2f2;
  --radius: 10px;
  --font: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

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

html { background: var(--light); }
body {
  margin: 0;
  background: var(--light);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 16px; top: -48px; padding: 8px 12px; background: var(--card); color: var(--accent-text); border-radius: 6px; z-index: 10; }
.skip:focus { top: 8px; }

/* ------------------------------------------------------------- header */
.top { background: var(--card); border-top: 4px solid var(--accent); border-bottom: 1px solid var(--line); }
.top-inner {
  max-width: 1040px; margin: 0 auto; padding: 12px 16px;
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { display: block; height: 33px; width: auto; }
.brand-name { font-size: 1.125rem; font-weight: 700; color: var(--brand); letter-spacing: -0.01em; }
.who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: var(--muted); font-size: 0.9375rem; min-width: 0; }
.who-email { overflow-wrap: anywhere; }

/* --------------------------------------------------------------- page */
.page { max-width: 1040px; margin: 0 auto; padding: 16px 16px 48px; }
main:focus { outline: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 16px; align-items: start; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin: 16px 0; box-shadow: 0 1px 2px rgba(48, 55, 78, 0.06);
}
.card h2 { font-size: 1.125rem; line-height: 1.3; margin: 0 0 16px; color: var(--brand); }
h3 { font-size: 1rem; margin: 20px 0 8px; color: var(--brand); }
h3:first-child { margin-top: 0; }
p { margin: 0 0 12px; }

.row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.row.end { justify-content: flex-end; }
.row > label { flex: 1 1 220px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9375rem; color: var(--ink); }
input, select {
  font: inherit; font-weight: 400; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--field-line); border-radius: 8px; background: var(--card); color: var(--ink);
}
input:focus-visible, select:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 1px; border-color: var(--accent-text); }

fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 16px 0; padding: 8px 16px 12px; min-width: 0; }
legend { font-weight: 600; padding: 0 4px; color: var(--brand); }
fieldset label { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; min-height: 40px; }
input[type='checkbox'] { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent-text); flex: none; }

/* ------------------------------------------------------------ buttons */
button, .button, .link-button {
  font: inherit; font-weight: 600; font-size: 0.9375rem; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 16px; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--accent-text); background: var(--accent-text); color: #ffffff;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.secondary { background: var(--card); color: var(--accent-text); }
button.secondary:hover { background: var(--ok-bg); color: var(--accent-hover); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
button:disabled, button:disabled:hover { opacity: 0.55; cursor: not-allowed; background: var(--accent-text); border-color: var(--accent-text); }
button.secondary:disabled { background: var(--card); color: var(--accent-text); }
.link-button { background: transparent; border-color: transparent; color: var(--accent-text); padding: 10px 4px; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--accent-hover); }

/* ------------------------------------------------------------ people */
ul.people { list-style: none; padding: 0; margin: 0; }
ul.people li {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.person-id { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.person-head { margin-bottom: 8px; }
.person-head strong { font-size: 1.0625rem; color: var(--brand); }
.muted { color: var(--muted); font-size: 0.9375rem; }
.hint { color: var(--muted); font-size: 0.9375rem; }
.badge { font-size: 0.8125rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.off { color: var(--danger); border-color: var(--danger); background: var(--error-bg); }
.effect { color: var(--muted); font-size: 0.9375rem; min-height: 1.5em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

/* ---------------------------------------------- status and passkey offer */
.status { margin: 0; overflow-wrap: anywhere; }
.status:not(:empty) { margin: 16px 0 0; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--line); border-left-width: 4px; background: var(--card); }
.status.ok:not(:empty) { border-color: var(--accent-text); background: var(--ok-bg); color: var(--ink); }
.status.warn:not(:empty) { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-text); }
.status.error:not(:empty) { border-color: var(--danger); background: var(--error-bg); color: var(--danger); }

.notice {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  margin: 16px 0 0; padding: 16px 20px; background: var(--card);
  border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius);
}
.notice h2 { font-size: 1rem; margin: 0 0 4px; color: var(--brand); }
.notice p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.notice-text { flex: 1 1 280px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  max-width: min(520px, calc(100vw - 32px)); padding: 24px;
}
dialog h2 { font-size: 1.125rem; margin: 0 0 12px; color: var(--brand); overflow-wrap: anywhere; }
dialog::backdrop { background: rgba(48, 55, 78, 0.5); }

@media (max-width: 480px) {
  .card { padding: 16px; }
  .brand-name { font-size: 1rem; }
  .who { width: 100%; justify-content: space-between; }
  .who-email { order: -1; flex-basis: 100%; }
  .row > button, form > button, .notice-actions > * { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
