/* Theme tokens are injected by app.js from /v1/themes (see themes.json).
   Defaults below mirror the "classic" theme so the shell renders before JS. */
:root {
  --c-background: #F6F7F9;
  --c-surface: #FFFFFF;
  --c-text: #1B1F24;
  --c-muted: #6B7280;
  --c-accent: #4F46E5;
  --c-accent-text: #FFFFFF;
  --c-border: #E5E7EB;
  --c-success: #16A34A;
  --c-danger: #DC2626;

  --radius: 14px;
  --gap: 16px;
  --maxw: 640px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--c-background);
  color: var(--c-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  position: sticky; top: 0; z-index: 5;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; }
.brand-u { color: var(--c-accent); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* Layout */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--gap);
  display: flex; flex-direction: column; gap: var(--gap);
}
.view { display: flex; flex-direction: column; gap: var(--gap); }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 18px;
}

.section-title { margin: 0 0 12px; font-size: 1.05rem; }
.muted { color: var(--c-muted); }
.small { font-size: 0.88rem; }
.hint { color: var(--c-muted); font-size: 0.85rem; margin: 10px 0 0; }

/* Forms */
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: var(--c-background);
  color: var(--c-text);
  font-size: 1rem;
}
.input:focus { outline: 2px solid var(--c-accent); outline-offset: 1px; }
.row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.row .input { flex: 1 1 auto; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--c-accent); color: var(--c-accent-text); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--c-text); border-color: var(--c-border); }
.btn-ghost:hover { background: var(--c-background); }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }

.form-msg { margin: 12px 0 0; min-height: 1.2em; font-size: 0.9rem; }
.form-msg.error { color: var(--c-danger); }
.form-msg.ok { color: var(--c-success); }

.auth-card { text-align: center; margin-top: 6vh; }
.auth-title { font-size: 1.5rem; margin: 0 0 6px; letter-spacing: -0.02em; }
.theme-picker select {
  padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--c-border);
  background: var(--c-background); color: var(--c-text);
}
.toggle-row {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 0.95rem; cursor: pointer;
}
.toggle-row input { width: 18px; height: 18px; accent-color: var(--c-accent); }

/* Profile / avatar */
.profile-card { display: flex; gap: 16px; align-items: center; }
.avatar-wrap { flex: 0 0 auto; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--c-border);
  display: grid; place-items: center; font-size: 1.8rem;
  background: var(--c-background);
}
.avatar-placeholder { color: var(--c-muted); }
/* .avatar sets display:grid, which would otherwise override the `hidden`
   attribute's display:none — so the img and placeholder both showed as two
   stacked circles. This makes hiding the <img hidden> actually work. */
.avatar[hidden] { display: none; }
.profile-meta { flex: 1 1 auto; min-width: 0; }
.profile-email { font-weight: 700; word-break: break-all; }
.profile-controls { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Lists */
.list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 10px;
}
.list-item .email { word-break: break-all; }
.email-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-connected { background: color-mix(in srgb, var(--c-success) 18%, transparent); color: var(--c-success); }
.badge-pending { background: color-mix(in srgb, var(--c-muted) 16%, transparent); color: var(--c-muted); }
.link-danger { background: none; border: none; color: var(--c-danger); cursor: pointer; font-size: 0.85rem; }

/* Connections */
.connections { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 6px; }
.conn-card {
  border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.conn-card .avatar { width: 72px; height: 72px; }
.conn-email { font-size: 0.85rem; word-break: break-all; color: var(--c-muted); }
.missu-btn {
  background: var(--c-accent); color: var(--c-accent-text);
  border: none; border-radius: 999px; padding: 10px 18px; font-weight: 700; cursor: pointer; width: 100%;
}
.missu-btn:hover { filter: brightness(1.05); }
.missu-btn:disabled { opacity: .6; cursor: default; }

/* The one person + green-light status */
.person { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.status-row { display: flex; align-items: center; gap: 10px; }
.light {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--c-muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-muted) 16%, transparent);
  transition: background .2s ease, box-shadow .2s ease;
}
.light.on {
  background: var(--c-success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-success) 28%, transparent);
}
.person .avatar { width: 88px; height: 88px; }
.missu-btn-lg { width: auto; padding: 14px 28px; font-size: 1.05rem; }

/* Icon button (settings gear, dialog close) */
.icon-btn {
  background: transparent; border: 1px solid var(--c-border);
  border-radius: 10px; padding: 8px 11px; font-size: 1.05rem;
  line-height: 1; cursor: pointer; color: var(--c-text);
}
.icon-btn:hover { background: var(--c-background); }

/* Focused main stage: their face, status, one big button */
.stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; text-align: center;
  min-height: calc(100dvh - 140px);
}
.person-card, .empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%;
}

/* Opt-in mirror: "their view" is a picture-in-picture chip pinned to the
   card's top-right corner — the video-call self-view pattern — so it reads
   as clearly secondary to your view instead of a competing second card. */
.views { display: flex; justify-content: center; gap: 28px; width: 100%; flex-wrap: wrap; }
.person-card { position: relative; }
.person-card.mirrored {
  flex: 0 1 500px; max-width: 500px;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface); padding: 22px 16px;
}
.mirror-card {
  position: absolute; top: -14px; right: -14px; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 176px; padding: 10px 10px 12px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 14px; box-shadow: 0 8px 22px rgba(0,0,0,0.16);
}
.mirror-card .view-label { font-size: 0.6rem; }
.mirror-card .avatar { width: 54px; height: 54px; font-size: 1.5rem; border-width: 2px; }
.mirror-card .their-name { font-size: 0.85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mirror-card .last-lines { gap: 1px; min-height: 0; max-width: 100%; }
/* One line each, ellipsized — keeps the chip short enough to clear the
   scoreboard row underneath it. */
.mirror-card .last-line {
  font-size: 0.64rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Show/hide lives on the chip itself (never in a menu): a ✕ on the chip,
   and a quiet pill in the same corner to bring it back. */
.mirror-hide {
  position: absolute; top: 3px; right: 5px;
  background: none; border: none; padding: 3px; cursor: pointer;
  color: var(--c-muted); font-size: 0.8rem; line-height: 1;
}
.mirror-hide:hover { color: var(--c-text); }
.mirror-show {
  position: absolute; top: 0; right: 0; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--c-muted);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 999px; padding: 7px 13px; cursor: pointer;
}
.mirror-show:hover { color: var(--c-text); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
/* Narrow screens: no free corner to pin to — dock the chip in-flow as a
   compact strip above the card content instead. */
@media (max-width: 560px) {
  /* relative, not static: keeps the ✕ anchored to the chip while it's in flow */
  .mirror-card {
    position: relative; top: auto; right: auto; width: auto; align-self: center;
    padding: 8px 22px 10px; box-shadow: none;
    background: var(--c-background);
  }
  .mirror-show { position: static; align-self: center; order: -1; }
}
.view-label {
  font-size: 0.72rem; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.avatar-xl .avatar { width: 148px; height: 148px; font-size: 3.6rem; border-width: 3px; }
.their-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; word-break: break-word; }
.their-email { font-size: 1.05rem; color: var(--c-muted); word-break: break-all; }
.their-email:empty { display: none; }

/* Scoreboard: "U Missed" count | avatar | "Missed U" count (toggle in Settings) */
.avatar-row { display: flex; align-items: center; justify-content: center; gap: 22px; }
.score { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 74px; }
.score-num { font-size: 1.9rem; font-weight: 800; color: var(--c-accent); line-height: 1; }
.score-label {
  font-size: 0.7rem; font-weight: 700; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Always-visible "Casey missed u 10 minutes ago" lines */
.last-lines { display: flex; flex-direction: column; gap: 4px; min-height: 1.2em; }
.last-line { margin: 0; font-size: 0.95rem; color: var(--c-muted); }
.last-line:first-child { color: var(--c-text); font-weight: 600; }
.missu-huge {
  background: var(--c-accent); color: var(--c-accent-text); border: none;
  border-radius: 26px; padding: 30px 24px; font-size: 1.7rem; font-weight: 800;
  width: 100%; max-width: 440px; cursor: pointer;
  box-shadow: 0 12px 34px rgba(0,0,0,0.18);
  transition: filter .12s ease, transform .06s ease;
}
.missu-huge:hover { filter: brightness(1.05); }
.missu-huge:active { transform: translateY(2px); }
.missu-huge:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* Settings dialog: everything that isn't the button */
.settings-dialog {
  border: none; border-radius: 16px; padding: 0;
  width: min(560px, 94vw); max-height: 90dvh; overflow: auto;
  background: var(--c-surface); color: var(--c-text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.settings-dialog::backdrop { background: rgba(0,0,0,0.5); }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; background: var(--c-surface);
}
.settings-head h2 { margin: 0; font-size: 1.15rem; }
.settings-section { padding: 16px 18px; border-bottom: 1px solid var(--c-border); }
.settings-section h3 {
  margin: 0 0 12px; font-size: 0.8rem; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.settings-section .link-danger { margin-top: 10px; }
.settings-foot { padding: 16px 18px; }

/* Toasts */
.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.toast {
  background: var(--c-surface); color: var(--c-text);
  border: 1px solid var(--c-border); border-left: 4px solid var(--c-accent);
  border-radius: 10px; padding: 12px 16px; max-width: var(--maxw); width: 100%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
