/* Louie Personal (me.asklouie.ai). Product-UI tokens from the Louie Sentry
   brand guide (§5.1): EchoSync canvas and surfaces, neutral text, status
   colours for status only. The warm orb is the page's one colour; buttons
   stay neutral so nothing competes with it (§4.2, §5.2). Dark only: the orb
   is never shown on white (§4.4). System fonts: the CSP has no font-src. */
:root {
  --bg: #06080c;
  --surface: #0b0f16;
  --elevated: #121826;
  --overlay: #1a2233;
  --line-subtle: #1a1f26;
  --line: #2a2e37;
  --line-strong: #3d4147;
  --text: #fafafa;
  --text-2: #e6e4df;
  --text-3: #a8a6a1;
  --quiet: #7a8699;
  --ok: #2ee6a8;
  --fail: #ff5c7a;
  --on-light: #06080c;
  --sans: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --r-card: 16px;
  --r-ctl: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
[hidden] { display: none !important; }
a { color: var(--text); }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip {
  position: absolute; left: 16px; top: -100px; z-index: 10;
  padding: 10px 14px; border-radius: var(--r-ctl);
  background: var(--text); color: var(--on-light); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---- The orb: the warm ember on its dark circle, as in the Mac app ---- */
.orb {
  display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line-subtle);
}
.orb picture, .orb img { display: block; }
.orb img { object-fit: contain; }
.orb-mark { width: 40px; height: 40px; }
.orb-mark img { width: 28px; height: 28px; }
.orb-hero { width: 152px; height: 152px; box-shadow: 0 0 0 10px rgb(255 255 255 / 0.015); }
.orb-hero img { width: 104px; height: 104px; }
.orb-note { width: 104px; height: 104px; }
.orb-note img { width: 72px; height: 72px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--elevated); color: var(--text);
  font: 600 15px/1.2 var(--sans); letter-spacing: -0.005em;
  text-decoration: none; cursor: pointer;
  white-space: nowrap; overflow-wrap: normal;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease),
    transform 0.15s var(--ease);
}
.btn:hover { background: var(--overlay); border-color: #4b5160; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--on-light); }
.btn.primary:hover { background: var(--text-2); border-color: var(--text-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--elevated); border-color: var(--line-strong); }
.btn.danger { color: var(--fail); }
.btn.danger:hover { border-color: rgb(255 92 122 / 0.45); background: rgb(255 92 122 / 0.08); }
.btn.small { padding: 0 14px; font-size: 14px; }
.btn.wide { min-width: 260px; min-height: 50px; font-size: 16px; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.85; }
.btn[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; flex: 0 0 14px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn:disabled { cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }
form.inline { margin: 0; display: inline-flex; }

/* ---- Results after an action, shown where it happened ---- */
.result {
  margin: 4px 0 12px;
  padding: 10px 14px;
  border-radius: var(--r-ctl);
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 14px;
}

/* ---- Sign-in and message pages: one calm column ---- */
body.signin, body.message { display: grid; place-items: center; }
main.center {
  width: 100%; max-width: 30rem;
  padding: 48px 16px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  animation: rise 0.9s var(--ease) both;
}
main.center .orb { margin-bottom: 28px; }
main.center h1 { font-size: 2.5rem; line-height: 1.05; font-weight: 700; letter-spacing: -0.035em; }
body.message main.center h1 { font-size: 1.75rem; letter-spacing: -0.025em; line-height: 1.15; }
main.center .lede { margin-top: 10px; color: var(--text-3); font-size: 1.0625rem; max-width: 26rem; }
main.center .actions { margin-top: 32px; }
main.center .result { margin-top: 24px; }

/* ---- Signed-in page ---- */
.top { border-bottom: 1px solid var(--line-subtle); background: var(--bg); }
.bar {
  max-width: 1120px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none; border-radius: 999px;
}
.brand .word { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.brand:hover .orb { border-color: var(--line-strong); }
.who { display: flex; align-items: center; gap: 16px; min-width: 0; }
.signed { color: var(--text-3); font-size: 14px; text-align: right; }

main.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 24px 72px; }
.grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-subtle);
  border-radius: var(--r-card);
  padding: 24px;
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 0;
  animation: rise 0.8s var(--ease) both;
}
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:nth-child(4) { animation-delay: 0.18s; }
.card > * { width: 100%; }
.card > form.inline { width: auto; margin-top: 16px; }
.card h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 6px; }
.muted, .empty { color: var(--text-3); font-size: 15px; }
.card > .muted { margin-bottom: 18px; }
.card > .muted + form.inline { margin-top: 0; }
.empty { padding: 6px 0 2px; }

.rows { margin-top: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line-subtle);
}
.row:first-child { border-top: 0; padding-top: 8px; }
.row .what { min-width: 0; }
.row form.inline { flex: 0 0 auto; }
.row .name { color: var(--text-2); font-weight: 600; }
.row .meta { color: var(--text-3); font-size: 14px; margin-top: 2px; }
.row.gone .name, .row.gone .meta { color: var(--quiet); font-weight: 400; }

.note {
  margin-top: 18px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--line-strong);
  color: var(--text-3); font-size: 14px;
}

/* Pairing code */
.code {
  margin: 0 0 18px;
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.code-label {
  font: 500 12px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
}
.code-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 4px; }
.big {
  font: 600 2.5rem/1.15 var(--mono); letter-spacing: 0.12em;
  color: var(--text);
  user-select: all; -webkit-user-select: all;
  font-variant-numeric: tabular-nums;
}
.expiry { color: var(--text-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.expiry .left { color: var(--text-2); font-weight: 600; }
.code-status:empty { display: none; }
.code-status { margin-top: 8px; color: var(--text-2); font-size: 14px; }
.code.is-expired .big { color: var(--quiet); text-decoration: line-through; text-decoration-thickness: 2px; }

/* Sources */
.sources { margin-top: 8px; }
.source {
  display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: baseline;
  column-gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line-subtle);
  font-size: 15px;
}
.source:first-child { border-top: 0; padding-top: 6px; }
.source .name { color: var(--text-2); }
.source .state { color: var(--text-3); text-align: right; max-width: 22rem; font-size: 14px; }
.source .state.fail { color: var(--fail); }
.dot { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.dot.ok { background: var(--ok); }
.dot.fail { background: var(--fail); }
.dot.off { border: 1.5px solid var(--quiet); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---- Phones ---- */
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; padding: 12px 16px; row-gap: 10px; }
  .who { display: contents; }
  .who form.inline { order: 2; }
  .signed { order: 3; flex: 1 0 100%; text-align: left; }
  main.wrap { padding: 20px 16px 56px; }
  .grid { gap: 14px; }
  .card { padding: 20px 18px; }
  .big { font-size: 2rem; letter-spacing: 0.1em; }
  .code { padding: 16px; }
  .source { grid-template-columns: 8px minmax(0, 1fr); row-gap: 2px; }
  .source .state { grid-column: 2; text-align: left; max-width: none; }
  .row { align-items: flex-start; }
  .btn.wide { min-width: 0; width: 100%; }
  main.center .actions { width: 100%; }
  main.center h1 { font-size: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .btn:active { transform: none; }
}

@media (forced-colors: active) {
  .dot.ok, .dot.fail { background: CanvasText; }
  .btn { border: 1px solid ButtonText; }
}
