/* Texas Empty Lots — shared styles.
   Mobile-first; letterboxes into a centered phone-width column on desktop.
   Palette is a PLACEHOLDER (deep green + gravel-gray) — easy to swap. */
:root {
  --brand: #1f5e3a;        /* deep green — text/foreground accents */
  --brand-dk: #164229;
  --brand-solid: var(--brand);       /* solid backgrounds paired with white text — must hold 4.5:1 in BOTH themes */
  --brand-solid-active: var(--brand-dk);
  --brand-ink: #ffffff;    /* on-brand text (see .btn) */
  --accent: #c8a24b;       /* muted brass, for highlights + focus rings */
  --bg: #f4f5f2;           /* gravel-tinted off-white */
  --surface: #ffffff;
  --surface-2: #eceee8;
  --ink: #1b1f1c;
  --muted: #5f6a62;
  --line: #d9ddd4;
  --ok: #2f8f4e;
  --warn: #b8860b;
  --danger: #b3402f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20,40,25,.08);
  --maxw: 480px;
  /* Pill bg/fg pairs — opaque (not theme-surface-derived) so contrast is guaranteed
     regardless of what card/background they sit on. Verified >=4.5:1 each. */
  --pill-ok-bg: #dcfce7; --pill-ok-fg: #166534;
  --pill-warn-bg: #fef3c7; --pill-warn-fg: #92400e;
  --pill-danger-bg: #fee2e2; --pill-danger-fg: #991b1b;
}
:root[data-theme="dark"] {
  --brand: #3f9d68;
  --brand-dk: #2a6e47;
  --brand-solid: var(--brand-dk);    /* #3f9d68 only hits 3.37:1 on white — too low; brand-dk hits 6.1:1 */
  --brand-solid-active: #1c4a30;
  --accent: #d8b968;
  --bg: #12140f;
  --surface: #1b1e18;
  --surface-2: #23271f;
  --ink: #eef1ea;
  --muted: #9aa89c;
  --line: #333a2e;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
  --pill-ok-bg: #14532d; --pill-ok-fg: #86efac;
  --pill-warn-bg: #78350f; --pill-warn-fg: #fcd34d;
  --pill-danger-bg: #7f1d1d; --pill-danger-fg: #fca5a5;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
/* Desktop letterbox: center a phone-width column, gravel backdrop */
.app-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
}
@media (min-width: 520px) {
  body { background: linear-gradient(160deg, #2a3229, #141712); }
}

/* Safe-area aware top bar with Back button */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand-solid);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right,0px) + 14px) 12px calc(env(safe-area-inset-left,0px) + 14px);
  display: flex; align-items: center; gap: 10px;
}
.topbar .title { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; flex: 1; }
.topbar .back, .topbar .icon-btn {
  background: rgba(255,255,255,.16); color: #fff; border: 0;
  width: 40px; height: 40px; border-radius: 9px;
  font-size: 1rem; display: grid; place-items: center; cursor: pointer;
}
.topbar .back:active, .topbar .icon-btn:active { background: rgba(255,255,255,.3); }

.content {
  flex: 1;
  padding: calc(env(safe-area-inset-top,0px) + 16px) calc(env(safe-area-inset-right,0px) + 14px)
           calc(env(safe-area-inset-bottom,0px) + 90px) calc(env(safe-area-inset-left,0px) + 14px);
}
/* Pages with a topbar (rendered into #bar) handle the top safe-area inset
   there already — content shouldn't double it up. #bar only exists on pages
   that call ILApp.topbar(), and is always .content's immediate sibling. */
#bar + .content { padding-top: 16px; }
/* Pages with no bottom tab bar don't need the 90px reserved for it. */
.content.no-tabbar { padding-bottom: calc(env(safe-area-inset-bottom,0px) + 20px); }

/* Bottom nav */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: var(--maxw);
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  z-index: 15;
}
.tabbar a {
  flex: 1; text-align: center; padding: 9px 4px 10px; text-decoration: none;
  color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .2px;
}
.tabbar a .mono {
  display: grid; place-items: center; width: 26px; height: 26px; margin: 0 auto 3px;
  border: 1.5px solid currentColor; border-radius: 8px; font-size: .8rem; font-weight: 800;
}
.tabbar a.active { color: var(--brand); }
/* Count badge on the Manage tab — the only signal Ian gets that someone is
   waiting (no email/push exists). Anchored to the .mono square. */
.tabbar a .mono { position: relative; }
.tab-badge {
  position: absolute; top: -6px; right: -8px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .62rem; font-weight: 800; line-height: 16px; text-align: center;
}

/* Cards + type */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 8px; }
h1 { font-size: 1.4rem; margin: 4px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.pill.ok { background: var(--pill-ok-bg); color: var(--pill-ok-fg); }
.pill.warn { background: var(--pill-warn-bg); color: var(--pill-warn-fg); }
.pill.danger { background: var(--pill-danger-bg); color: var(--pill-danger-fg); }
.pill.muted { background: var(--surface-2); color: var(--muted); }

/* Forms */
label { display: block; font-weight: 600; font-size: .85rem; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 1rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.field-error { color: var(--danger); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 16px; border: 0; border-radius: 11px;
  background: var(--brand-solid); color: #fff; font-size: 1rem; font-weight: 700;
  cursor: pointer; margin-top: 12px; text-decoration: none;
}
.btn:active { background: var(--brand-solid-active); }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.danger { background: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.compact { padding-left: 10px; padding-right: 10px; font-size: .92rem; white-space: nowrap; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 12px; }
.row.btn-toggle { gap: 8px; }
.row.btn-toggle .btn { flex: 1 1 0; min-width: 0; }

/* Visible, consistent focus ring on every interactive element (browser default
   outlines are invisible against the brand-green buttons/topbar). */
a:focus-visible, button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Visually hidden but still announced by screen readers — for headings that
   are needed for correct document structure but would be visually redundant. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Skip link — hidden until focused, jumps past nav to main content */
.skip-link {
  position: absolute; left: 10px; top: -100px; z-index: 100;
  background: var(--brand-solid); color: #fff; padding: 10px 16px;
  border-radius: 8px; text-decoration: none; font-weight: 700; transition: top .15s;
}
.skip-link:focus { top: 10px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; border: 0; }
.center { text-align: center; }
.spacer { height: 8px; }
.list-empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* Shown in #content until IL.init() resolves and render() replaces it —
   otherwise the page is a blank rectangle for ~500ms on every load. */
.loading-spin { display: flex; align-items: center; justify-content: center; padding: 70px 0; }
.loading-spin::after {
  content: ""; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: il-spin .8s linear infinite;
}
@keyframes il-spin { to { transform: rotate(360deg); } }

/* Brand monogram mark */
.mark {
  width: 56px; height: 56px; border-radius: 14px; background: var(--brand-solid); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 1.5rem; letter-spacing: -1px;
}
.notice {
  background: rgba(184,134,11,.1); border: 1px solid rgba(184,134,11,.35);
  border-radius: 10px; padding: 10px 12px; font-size: .82rem; color: var(--ink); margin: 10px 0;
}
/* Plain inline prose links (e.g. "Sign now" inside a .notice) have no class,
   unlike every button-style anchor in this app (.btn/.tabbar a/.cft-family all
   carry a class) — so this can never clash with those. Previously these fell
   through to the browser's unstyled default link blue, which is unreadable on
   a .notice's tinted background (measured ~1.5:1 in dark mode). */
a:not([class]) { color: var(--brand); font-weight: 600; text-decoration: underline; }
a:not([class]):active { color: var(--brand-dk); }

/* Social sign-in (Google / Apple) */
.social-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.btn-social {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px; border-radius: 11px; font-size: .95rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn-social:active { background: var(--surface-2); }
.btn-social svg { flex: none; }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: .78rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* CFT family badge — links back to the parent studio's site */
.cft-family {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 14px 10px 6px; text-decoration: none; color: var(--muted); font-size: .76rem;
}
.cft-family .cft-mark {
  width: 16px; height: 16px; border-radius: 4px; background: var(--brand-solid);
  color: #fff; display: grid; place-items: center; font-size: .55rem; font-weight: 800; flex: none;
}
.cft-family strong { color: var(--ink); font-weight: 700; }
