@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,700;1,9..40,400&display=swap');

:root {
  --brand: #EBC736;
  --brand-ink: #7A5E00; /* dark enough to sit on brand-tinted surfaces at readable contrast */
  --action: #0EA5E9;
  --action-hover: #38BDF8;
  --action-active: #0284C7;
  --success: #34C759;
  --error: #FF3B30;
  --error-hover: #FF453A;
  --warning: #FF9F0A;

  --surface: #FFFFFF;
  --light-bg: #F6F6F6;
  --page-bg: #F2F1EC; /* faint warm tint so white cards read as elevated, not just "white on white" */

  --text-primary: #000000;
  --text-secondary: #525252;
  --text-tertiary: #6B6B6B;
  --text-placeholder: #A3A3A3;

  --border: #C4C4C4;
  --border-hover: #A3A3A3;
  --divider: #EEEEEE;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  --dur-instant: 100ms;
  --dur-micro: 150ms;
  --dur-short: 250ms;
  --dur-medium: 400ms;

  /* Approximates a critically-damped spring (no overshoot) using a native
     CSS easing curve — the closest we can get without a JS spring library. */
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 2px 4px rgba(0,0,0,0.05), 0 16px 32px rgba(0,0,0,0.09);
  --shadow-toast: 0 8px 24px rgba(0,0,0,0.2);
  --shadow-topbar: 0 1px 0 rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.03);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }
html, body { min-height: 100vh; min-height: 100dvh; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── TYPOGRAPHY (size-specific tracking + leading, per platform craft) ── */

h1, .h1 { font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -0.022em; }
h2, .h2 { font-size: 25px; font-weight: 700; line-height: 1.2; letter-spacing: -0.016em; }
h3, .h3 { font-size: 18px; font-weight: 700; line-height: 1.3; letter-spacing: -0.008em; }
.body-lg { font-size: 18px; font-weight: 400; letter-spacing: -0.004em; }
p, .body { font-size: 16px; font-weight: 400; }
.caption { font-size: 13px; color: var(--text-tertiary); letter-spacing: 0.002em; }
.label-text { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-placeholder); }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* ─── LAYOUT ──────────────────────────────────────────────────── */

.container { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 var(--space-6); }

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-topbar);
  padding: var(--space-4) var(--space-6);
  padding-top: calc(var(--space-4) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.app-logo { height: 22px; width: auto; display: block; }

.app-nav { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }

.app-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  transition: background var(--dur-instant) var(--ease-out), color var(--dur-instant) var(--ease-out);
}

.app-nav-link:hover { color: var(--text-primary); background: rgba(0,0,0,0.045); }
.app-nav-link:active { transform: scale(0.96); }
.app-nav-link.active { color: var(--text-primary); background: rgba(0,0,0,0.06); font-weight: 700; }
.app-nav-link:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* Sign out is a destructive-leaning action (ends your session) — visually
   separated from ordinary navigation, never styled like a plain nav link. */
.app-nav-divider-v { width: 1px; height: 22px; background: var(--divider); margin: 0 var(--space-2); }

.app-nav-signout { color: var(--error); }
.app-nav-signout:hover { color: var(--error-hover); background: rgba(255,59,48,0.08); }

.app-nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.app-nav-toggle:hover { background: var(--light-bg); }
.app-nav-toggle:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

.app-nav-close { display: none; }

/* ─── NAV DROPDOWN (Resources) ───────────────────────────────────
   Desktop: a floating dark panel per the IDL navigation-dropdown spec.
   Mobile: overridden below to sit inline inside the full-screen menu panel. */
.app-nav-dropdown-wrap { position: relative; }

.app-nav-dropdown-trigger i { transition: transform var(--dur-instant) var(--ease-out); }
.app-nav-dropdown-wrap.open .app-nav-dropdown-trigger i { transform: rotate(180deg); }
.app-nav-dropdown-wrap.open .app-nav-dropdown-trigger { color: var(--text-primary); background: rgba(0,0,0,0.045); }

.app-nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 210px;
  background: rgba(17,17,17,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out), visibility 0s linear var(--dur-short);
  z-index: 50;
}

.app-nav-dropdown-wrap.open .app-nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
}

.app-nav-dropdown .app-nav-link {
  color: rgba(255,255,255,0.85);
  justify-content: flex-start;
  border-radius: var(--radius-md);
}
.app-nav-dropdown .app-nav-link:hover { background: rgba(255,255,255,0.06); color: var(--action-hover); }
.app-nav-dropdown .app-nav-link.active { background: rgba(255,255,255,0.08); color: var(--action-hover); font-weight: 700; }

/* Sign Out is a destructive-leaning action — it must stay red even inside
   the dark dropdown, which otherwise sets every link to a neutral white. */
.app-nav-dropdown .app-nav-signout { color: var(--error); }
.app-nav-dropdown .app-nav-signout:hover { color: var(--error-hover); background: rgba(255,59,48,0.12); }

/* ─── ACCOUNT MENU (avatar) ──────────────────────────────────────
   Reuses the .app-nav-dropdown-wrap/.app-nav-dropdown pattern above,
   right-aligned since it's the last item in the nav. */
.app-avatar-wrap .app-nav-dropdown { left: auto; right: 0; min-width: 220px; }

.app-avatar-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: none;
  cursor: pointer;
}
.app-avatar-trigger:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 999px; }

.app-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--action);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.app-avatar-notif-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--error);
  border: 2px solid var(--surface);
}

.app-avatar-dropdown .app-nav-link { justify-content: flex-start; position: relative; }
.app-notif-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-avatar-trigger-label, .app-avatar-trigger-chevron { display: none; }

/* Unread-message count on the Messages nav link itself — the badge lives
   here instead of the notification center so the same "new message" signal
   never shows in two places at once. */
.nav-msg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Mobile navigation is a full-screen panel, not a dropdown, per the IDL's
   mobile navigation spec. */
@media (max-width: 860px) {
  .app-nav-toggle { display: flex; }

  /* backdrop-filter on an ancestor creates a new containing block for
     position:fixed descendants (a CSS quirk) — without this, the "full
     screen" nav panel below sizes itself relative to the topbar's own
     ~72px box instead of the viewport. Mobile doesn't need the blur. */
  .app-topbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--surface);
  }

  .app-nav {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    /* Top padding clears the absolutely positioned close button (24px offset
       + 40px tall), plus a small gap, so the first link never sits under it. */
    padding: calc(var(--space-8) + var(--space-8) + var(--space-2) + env(safe-area-inset-top)) var(--space-6) var(--space-6);
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out), visibility 0s linear var(--dur-short);
  }

  .app-shell.nav-open .app-nav {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
  }

  .app-nav-link {
    font-size: 19px;
    font-weight: 700;
    padding: var(--space-4) var(--space-3);
    border-radius: var(--radius-md);
    justify-content: flex-start;
  }

  .app-nav-divider-v {
    width: auto;
    height: 1px;
    margin: var(--space-4) 0;
  }

  .app-nav-signout { margin-top: auto; }

  /* The nav panel is a full-screen overlay (z-index 200) that sits above the
     topbar (z-index 100), so the hamburger-to-X toggle button underneath
     becomes invisible once open — this close button lives inside the panel
     itself so there's always a visible, reachable way to dismiss it. */
  .app-nav-close {
    display: flex;
    position: absolute;
    top: calc(var(--space-6) + env(safe-area-inset-top));
    right: var(--space-6);
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
  }
  .app-nav-close:hover { background: var(--light-bg); }
  .app-nav-close:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

  /* Inside the full-screen mobile panel the dropdown behaves like the IDL's
     details/summary sub-link pattern: it expands inline, not as a floating
     dark panel (there's no page content behind it to float over). */
  .app-nav-dropdown-wrap { position: static; }
  .app-nav-dropdown {
    position: static;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 0 0 0 var(--space-4);
    max-height: 0;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: max-height var(--dur-short) var(--ease-out);
  }
  .app-nav-dropdown-wrap.open .app-nav-dropdown {
    max-height: 200px;
    transition: max-height var(--dur-short) var(--ease-out);
  }
  /* The account menu has more items (4 links + a divider) than Resources
     (2 links), so it needs more room before content gets clipped. */
  .app-avatar-wrap.open .app-nav-dropdown {
    max-height: 320px;
  }
  .app-nav-dropdown .app-nav-link {
    color: var(--text-secondary);
    font-size: 17px;
  }
  .app-nav-dropdown .app-nav-link:hover { background: rgba(0,0,0,0.045); color: var(--text-primary); }
  .app-nav-dropdown .app-nav-link.active { background: rgba(0,0,0,0.06); color: var(--text-primary); }
  .app-nav-dropdown .app-nav-signout { color: var(--error); }
  .app-nav-dropdown .app-nav-signout:hover { color: var(--error-hover); background: rgba(255,59,48,0.08); }

  /* Account menu becomes a full-width row like every other nav item. */
  .app-avatar-trigger {
    width: 100%;
    height: auto;
    padding: var(--space-4) var(--space-3);
    border-radius: var(--radius-md);
    justify-content: flex-start;
    gap: var(--space-3);
  }
  .app-avatar-trigger:hover { background: rgba(0,0,0,0.045); }
  .app-avatar-trigger-label { display: block; font-size: 19px; font-weight: 700; color: var(--text-primary); }
  .app-avatar-trigger-chevron { display: block; margin-left: auto; color: var(--text-secondary); }
  .app-avatar-wrap.open .app-avatar-trigger-chevron { transform: rotate(180deg); }
  .app-avatar-notif-dot { top: 2px; right: 2px; }
  .app-avatar-dropdown .app-nav-link { padding-left: var(--space-8); }
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6);
  animation: view-in var(--dur-medium) var(--ease-out);
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) { .app-main { padding: var(--space-8) var(--space-4); } }

.page-header { margin-bottom: var(--space-8); }
.page-eyebrow { font-size: 13px; font-weight: 700; color: var(--action); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: var(--space-2); }

/* ─── BUTTONS ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.006em;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-instant) var(--ease-out), border-color var(--dur-instant) var(--ease-out),
              transform var(--dur-instant) var(--ease-spring), box-shadow var(--dur-instant) var(--ease-out);
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--action); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--action-hover); }
.btn-primary:active { background: var(--action-active); }

.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--light-bg); border-color: var(--border-hover); }

.btn-destructive { background: var(--error); color: #fff; }
.btn-destructive:hover { background: var(--error-hover); }
.btn-destructive:active { background: #D70015; }

.btn-google {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-google:hover { background: var(--light-bg); }

.btn-sm { min-height: 38px; padding: 8px 18px; font-size: 14px; }
.w-full { width: 100%; }

/* ─── FORMS ───────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label { font-size: 13px; font-weight: 700; color: var(--text-secondary); letter-spacing: -0.002em; }
.field-required { color: var(--error); font-size: 12px; font-weight: 700; margin-left: 4px; }
.field-helper { font-size: 13px; color: var(--text-tertiary); }

.input, textarea.input, select.input {
  width: 100%;
  min-height: 46px;
  padding: 11px var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  transition: border-color var(--dur-instant) var(--ease-out), box-shadow var(--dur-instant) var(--ease-out);
}

.input:hover { border-color: var(--border-hover); }
.input:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 4px rgba(14,165,233,0.14); }
.input::placeholder { color: var(--text-placeholder); }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }

.input-group { position: relative; }
.input-group .input { padding-right: 46px; }
.input-icon-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
}
.input-icon-btn:hover { color: var(--text-primary); background: var(--light-bg); }

.select-wrapper { position: relative; }
.select-wrapper select { appearance: none; padding-right: 40px; cursor: pointer; }
.select-chevron { position: absolute; right: var(--space-4); top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-tertiary); }

.field-error {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--error);
  font-size: 13px;
  animation: shake-in var(--dur-short) var(--ease-out);
}

@keyframes shake-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── CHOICE CHIPS (issue type, severity, yes/no groups) ─────────── */

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-2);
}

.choice-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  transition: border-color var(--dur-instant) var(--ease-out), background var(--dur-instant) var(--ease-out),
              transform var(--dur-instant) var(--ease-spring);
}

.choice-chip:hover { border-color: var(--border-hover); background: var(--light-bg); }
.choice-chip:active { transform: scale(0.98); }
.choice-chip.active {
  border-color: var(--action);
  background: rgba(14,165,233,0.08);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

.choice-chip i { flex-shrink: 0; }

/* Bug severity chips: selected color communicates severity per the IDL semantic
   palette (green/yellow/orange/red), overriding the default blue active state. */
#bug-severity-group .choice-chip[data-value="low"].active {
  border-color: #34C759;
  background: rgba(52,199,89,0.1);
  color: #1F8A3B;
  box-shadow: 0 0 0 3px rgba(52,199,89,0.12);
}
#bug-severity-group .choice-chip[data-value="medium"].active {
  border-color: #EBC736;
  background: rgba(235,199,54,0.18);
  color: #7A6205;
  box-shadow: 0 0 0 3px rgba(235,199,54,0.15);
}
#bug-severity-group .choice-chip[data-value="high"].active {
  border-color: #FF9F0A;
  background: rgba(255,159,10,0.1);
  color: #B5650A;
  box-shadow: 0 0 0 3px rgba(255,159,10,0.12);
}
#bug-severity-group .choice-chip[data-value="blocking"].active {
  border-color: #FF3B30;
  background: rgba(255,59,48,0.08);
  color: #C0281E;
  box-shadow: 0 0 0 3px rgba(255,59,48,0.1);
}

.choice-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.choice-row .choice-chip { flex: 1; min-width: 100px; justify-content: center; text-align: center; }

/* ─── CARDS & SECTIONS ────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.form-section {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
}

.form-section-title { font-size: 15px; font-weight: 700; margin-bottom: var(--space-4); }

/* ─── HOME ─────────────────────────────────────────────────────── */

.home-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.home-link-card {
  cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-out);
}
.home-link-card:hover { border-color: var(--border-hover); }
.home-link-card i:first-child { color: var(--text-primary); }
.home-link-title { margin: var(--space-3) 0 var(--space-1); }
.home-link-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-4);
  font-size: 14px;
  font-weight: 700;
  color: var(--action);
}

.divider { border: none; border-top: 1px solid var(--divider); }

/* ─── STATUS PILL ─────────────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  background: var(--light-bg);
  border: 1px solid rgba(0,0,0,0.05);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-placeholder); }
.status-pill.is-installed .status-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(52,199,89,0.18); }
.status-pill.is-scheduled .status-dot { background: var(--warning); box-shadow: 0 0 0 3px rgba(255,159,10,0.18); }

/* ─── ALERT ───────────────────────────────────────────────────── */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.alert-success { background: rgba(52,199,89,0.08); border-color: rgba(52,199,89,0.25); }
.alert-info { background: rgba(14,165,233,0.07); border-color: rgba(14,165,233,0.22); }

/* ─── TOAST ───────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: rgba(28,28,30,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-toast);
  font-size: 14px;
  animation: toast-in var(--dur-medium) var(--ease-spring);
}

.toast.out { animation: toast-out var(--dur-short) var(--ease-out) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }

/* ─── LOGIN / ACTIVATE ────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  padding-top: calc(var(--space-6) + env(safe-area-inset-top));
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  background: var(--page-bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-8);
  animation: card-in var(--dur-medium) var(--ease-spring);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo { height: 26px; width: auto; display: block; margin: 0 auto var(--space-8); }
.login-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: var(--space-2); letter-spacing: -0.02em; }
.login-subtitle { font-size: 15px; color: var(--text-secondary); text-align: center; margin-bottom: var(--space-8); }
.login-form { display: flex; flex-direction: column; gap: var(--space-4); }

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-6) 0;
  color: var(--text-placeholder);
  font-size: 13px;
}
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--divider); }

/* ─── REFERRAL ────────────────────────────────────────────────── */

.referral-link-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--light-bg);
  font-size: 14px;
  color: var(--action);
  text-decoration: none;
  transition: border-color var(--dur-instant) var(--ease-out), background var(--dur-instant) var(--ease-out);
  overflow-x: auto;
  white-space: nowrap;
}

.referral-link-box:hover { border-color: var(--action); background: rgba(14,165,233,0.06); }

.referral-note {
  border-left: 3px solid var(--brand);
  padding-left: var(--space-4);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ─── FILE DROP (attachments) ─────────────────────────────────── */

.file-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-instant) var(--ease-out), background var(--dur-instant) var(--ease-out);
}

.file-drop:hover { border-color: var(--action); background: rgba(14,165,233,0.04); }
.file-drop.has-file { border-color: var(--success); background: rgba(52,199,89,0.05); border-style: solid; }
.file-drop input { display: none; }

/* ─── UTILITIES ───────────────────────────────────────────────── */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.font-bold { font-weight: 700; }
.ml-1 { margin-left: var(--space-1); }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-secondary); font-size: 13px; }

/* ─── ADMINISTRATOR PLATFORM ──────────────────────────────────────────────── */

.app-shell:not(.is-admin) #admin-nav { display: none; }
.app-shell.is-admin #app-nav { display: none; }
.app-shell.is-admin .app-main { max-width: 1080px; }

.admin-page-subtitle { color: var(--text-secondary); margin-top: var(--space-1); }

.admin-loading {
  display: flex; align-items: center; gap: var(--space-2);
  color: var(--text-secondary); padding: var(--space-8) 0;
}
.spin { animation: admin-spin 0.8s linear infinite; }
@keyframes admin-spin { to { transform: rotate(360deg); } }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface);
}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.15; }
.stat-value-of { font-size: 16px; font-weight: 400; color: var(--text-secondary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: var(--space-1); }

.admin-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 700px) { .admin-split { grid-template-columns: 1fr; } }

.breakdown-list { display: flex; flex-direction: column; gap: var(--space-2); }
.breakdown-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) 0; border-bottom: 1px solid var(--divider);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-count { font-weight: 700; }

.badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.badge-red { background: rgba(255,59,48,0.12); color: #C0281E; }
.badge-orange { background: rgba(255,149,0,0.14); color: #B5650A; }
.badge-yellow { background: rgba(235,199,54,0.22); color: #7A6205; }
.badge-blue { background: rgba(14,165,233,0.12); color: #0B7CB0; }
.badge-green { background: rgba(52,199,89,0.14); color: #1F8A3B; }
.badge-gray { background: rgba(0,0,0,0.06); color: var(--text-secondary); }

.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-secondary); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.admin-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--divider); white-space: nowrap; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table-row { cursor: pointer; }
.admin-table-row:hover { background: var(--light-bg, rgba(0,0,0,0.02)); }

.admin-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}

.admin-record {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.admin-record-link { cursor: pointer; }
.admin-record-link:hover { border-color: var(--border-hover); }
.admin-record-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.admin-record-title { font-weight: 700; margin-bottom: var(--space-1); }
.admin-record-meta { font-size: 13px; color: var(--text-secondary); margin-top: var(--space-1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* An in-app override of the above, toggled from Settings — some users want
   motion off regardless of what their OS preference happens to be. */
.force-reduced-motion, .force-reduced-motion *, .force-reduced-motion *::before, .force-reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ─── MODAL (confirmation) ────────────────────────────────────────
   Used for irreversible actions only — Settings > Delete Account today. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  z-index: 300;
  opacity: 0;
  animation: modal-overlay-in var(--dur-short) var(--ease-out) forwards;
}
@keyframes modal-overlay-in { to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.16);
  opacity: 0;
  transform: translateY(16px);
  animation: modal-card-in var(--dur-medium) var(--ease-out) forwards;
}
@keyframes modal-card-in { to { opacity: 1; transform: translateY(0); } }

.modal-title { font-size: 24px; font-weight: 700; margin-bottom: var(--space-4); }
.modal-body { color: var(--text-secondary); font-size: 16px; line-height: 1.5; margin-bottom: var(--space-6); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-3); }

/* ─── PROFILE ──────────────────────────────────────────────────── */

.profile-avatar-row { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-6); }
.profile-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: var(--action);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

/* ─── NOTIFICATIONS ────────────────────────────────────────────── */

.notif-item { display: flex; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); cursor: pointer; }
.notif-item:hover { background: var(--light-bg); }
.notif-item.unread { background: rgba(14,165,233,0.05); }
.notif-icon {
  width: 36px; height: 36px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14,165,233,0.1); color: var(--action);
}
.notif-dot-inline { width: 8px; height: 8px; border-radius: 999px; background: var(--action); flex-shrink: 0; margin-top: 6px; }

/* ─── SETTINGS ─────────────────────────────────────────────────── */

.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.toggle-switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.toggle-track {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px;
  transition: background var(--dur-instant) var(--ease-out);
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform var(--dur-instant) var(--ease-out);
}
.toggle-switch input:checked ~ .toggle-track { background: var(--action); }
.toggle-switch input:checked ~ .toggle-thumb { transform: translateX(18px); }
.toggle-switch input:focus-visible ~ .toggle-track { outline: 2px solid var(--action); outline-offset: 2px; }

/* ─── MESSAGES (chat thread) ─────────────────────────────────────
   iMessage-style: own messages right-aligned/blue, the other side's
   left-aligned/grey. "Mine" is relative to whoever is viewing — an EA's
   own messages are blue on their screen, and an admin's own replies are
   blue on the admin's screen, even though it's the same message row. */

.chat-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 260px);
  min-height: 420px;
  max-height: 640px;
  padding: 0;
  overflow: hidden;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Each row is its own column so a message's timestamp always sits directly
   under that message — a single trailing timestamp for the whole thread
   read as buggy/disconnected once more than one message was on screen. */
.chat-row { display: flex; flex-direction: column; margin-bottom: var(--space-3); max-width: 75%; }
.chat-row.mine { align-items: flex-end; align-self: flex-end; }
.chat-row.theirs { align-items: flex-start; align-self: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-row.mine .chat-bubble { background: var(--action); color: #fff; border-bottom-right-radius: 4px; }
.chat-row.theirs .chat-bubble { background: var(--light-bg); color: var(--text-primary); border-bottom-left-radius: 4px; }

.chat-attachment-img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 14px;
  display: block;
  margin-bottom: 4px;
  object-fit: cover;
}

.chat-bubble-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
  padding: 0 4px;
}

.chat-timestamp {
  align-self: center;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin: var(--space-4) 0 var(--space-2);
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--divider);
  background: var(--surface);
}
.chat-input-bar textarea.input {
  min-height: 40px;
  max-height: 120px;
  padding: 9px var(--space-4);
  resize: none;
  border-radius: var(--radius-lg);
  font-size: 15px;
}
.chat-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-attach-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}
.chat-attach-btn:hover { background: var(--light-bg); color: var(--text-primary); }

.chat-attach-preview-wrap { padding: var(--space-3) var(--space-4) 0; }
.chat-attach-preview { position: relative; display: inline-block; }
.chat-attach-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.chat-attach-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--text-primary);
  color: #fff;
  border: 2px solid var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6);
}

/* Conversation list (admin) */
.convo-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.convo-item:hover { background: var(--light-bg); }
.convo-avatar {
  width: 44px; height: 44px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--action); color: #fff; font-size: 14px; font-weight: 700;
  background-size: cover; background-position: center;
}
/* HowardAI's own brand mark shouldn't fill the circle edge-to-edge like a
   cropped photo — it sits smaller on the IDL's light grey surface instead. */
.convo-avatar-brand {
  background-color: var(--light-bg);
  background-size: 60%;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
}
.convo-preview { flex: 1; min-width: 0; }
.convo-name-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.convo-name { font-weight: 700; }
.convo-time { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }
.convo-snippet {
  color: var(--text-secondary);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo-item.unread .convo-snippet { color: var(--text-primary); font-weight: 600; }
.convo-unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--action); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ─── NEWSROOM ─────────────────────────────────────────────────── */

.newsroom-filters {
  display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-6);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.post-card { cursor: pointer; padding: 0; overflow: hidden; }
.post-card-cover { width: 100%; height: 140px; object-fit: cover; display: block; }
.post-card-body { padding: var(--space-4); }
.post-card-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-article-cover { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius-md); margin-bottom: var(--space-6); }
.post-article-body { line-height: 1.6; }
.post-article-body p { margin: 0 0 var(--space-4); }
.post-article-body p:last-child { margin-bottom: 0; }
.post-article-body ul, .post-article-body ol { margin: 0 0 var(--space-4); padding-left: var(--space-6); }
.post-article-body li { margin-bottom: var(--space-1); }
.post-article-body strong { font-weight: 700; }
.post-article-body em { font-style: italic; }
.post-article-body a { color: var(--action); text-decoration: underline; }

.post-body-toolbar {
  display: flex; gap: var(--space-1); margin-bottom: var(--space-2);
}
.post-body-tool-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  cursor: pointer;
}
.post-body-tool-btn:hover { background: var(--light-bg); color: var(--text-primary); }
.post-body-tool-btn.active {
  background: var(--action); border-color: var(--action); color: #fff;
}

.post-body-editor {
  min-height: 140px; height: auto; cursor: text;
  line-height: 1.6; overflow-y: auto;
}
.post-body-editor p { margin: 0 0 var(--space-3); }
.post-body-editor p:last-child { margin-bottom: 0; }
.post-body-editor ul, .post-body-editor ol { margin: 0 0 var(--space-3); padding-left: var(--space-6); }
.post-body-editor a { color: var(--action); text-decoration: underline; }
.post-body-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--text-secondary);
  pointer-events: none;
}

.post-category-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--light-bg); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
.post-new-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--action); color: #fff;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
