/* ═══════════════ CellTale — "neon shield" theme (violet/pink/cyan) ═══════════════ */
:root {
  --bg: #14081f;
  --bg-grad: radial-gradient(1200px 600px at 70% -10%, #3a1560 0%, #14081f 55%);
  --surface: #221232;
  --surface-2: #2e1a44;
  --border: #452a63;
  --text: #f5efff;
  --text-dim: #b3a3cc;
  --primary: #a855f7;
  --primary-hover: #b96bff;
  --primary-text: #1b0b2b;
  --accent: #ff4da6;
  --danger: #ff5c7a;
  --radius: 16px;
  --nav-h: 78px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg); background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh; min-height: 100dvh;
}
a { color: var(--accent); }
.hidden { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: .2px; }

/* ── Ambient background glows (violet + cyan neon haze) ── */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  border-radius: 50%;
}
body::before {
  top: -180px; right: -120px; width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(168,85,247,.17), transparent 65%);
}
body::after {
  bottom: -220px; left: -160px; width: 560px; height: 560px;
  background: radial-gradient(circle, rgba(34,211,238,.13), transparent 65%);
}

/* ── Views & pages ── */
.view { min-height: 100vh; min-height: 100dvh; }
#view-app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.page { max-width: 560px; margin: 0 auto; padding: 20px 16px 24px; animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-header { padding: 10px 4px 18px; }
.page-header h2 { font-size: 27px; }
.page-sub { color: var(--text-dim); font-size: 14px; margin-top: 5px; line-height: 1.45; }
.section-title { font-size: 13px; margin: 20px 0 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.section-hint { font-size: 13px; color: var(--text-dim); margin: -4px 0 12px; line-height: 1.5; }
.section-hint:empty { display: none; }
.new-tag {
  display: inline-block; vertical-align: 2px; margin-left: 8px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--accent); color: #2b0a1c;
  font-family: var(--font-body); font-size: 11px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(255,77,166,.45);
}

/* ── Welcome banner ── */
.welcome-banner {
  background: linear-gradient(135deg, rgba(168,85,247,.18), rgba(255,77,166,.06));
  border: 1px solid rgba(168,85,247,.4);
  border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
  box-shadow: 0 4px 20px rgba(168,85,247,.1);
}
.welcome-greeting { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.welcome-stats { color: var(--text-dim); font-size: 13.5px; margin-top: 5px; line-height: 1.5; }

/* ── Buttons ── */
.btn {
  display: inline-block; border: none; border-radius: 999px;
  padding: 13px 22px; font-size: 16px; font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer; transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 4px 18px rgba(168,85,247,.4); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--border); color: var(--text-dim); box-shadow: none; cursor: not-allowed; }
.btn-accent { background: linear-gradient(135deg, #ff4da6, #a855f7); color: #fff; width: 100%; margin-top: 10px; box-shadow: 0 4px 18px rgba(255,77,166,.35); }
.btn-secondary { background: var(--surface-2); color: var(--text); width: 100%; margin-top: 10px; border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); width: 100%; margin-top: 10px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--danger); font-size: 13px; cursor: pointer; }
.btn-link-neutral { color: var(--text-dim); margin-right: 10px; }

/* ── Auth / landing ── */
#view-auth { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-hero { width: 100%; display: flex; justify-content: center; position: relative; }
.auth-glow {
  position: absolute; top: -60px; left: 50%; transform: translateX(-50%);
  width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(168,85,247,.24), transparent 65%);
  pointer-events: none;
}
.auth-card {
  position: relative; width: 100%; max-width: 400px;
  background: rgba(34,18,50,.88); backdrop-filter: blur(8px);
  border-radius: 24px; padding: 36px 26px; text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-logo { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 8px 24px rgba(168,85,247,.4); }
.auth-card h1 { font-size: 30px; margin-top: 14px; }
.tagline { color: var(--accent); font-size: 15px; margin: 8px 0 2px; font-weight: 600; }
.tagline-sub { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 6px 0 16px; }
.trust-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.trust-pill {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 999px; font-size: 12px; padding: 5px 12px;
}
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--bg); border-radius: 999px; padding: 5px; border: 1px solid var(--border); }
.auth-tab {
  flex: 1; padding: 10px; border: none; border-radius: 999px;
  background: transparent; color: var(--text-dim);
  font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.auth-tab.active { background: var(--primary); color: var(--primary-text); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.error-text { color: var(--danger); font-size: 14px; margin-top: 12px; }
.success-text { color: #6fd6a0; font-size: 14px; margin-top: 12px; line-height: 1.5; }
.forgot-link { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 13px; margin-top: 10px; cursor: pointer; align-self: center; text-decoration: underline; text-underline-offset: 3px; opacity: .85; }
.forgot-link:hover { opacity: 1; }
.fine-print { color: var(--text-dim); font-size: 12px; margin-top: 18px; }
.fine-print.center { text-align: center; }

/* ── Inputs ── */
.field-label {
  display: block; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-dim); margin: -4px 4px -6px; letter-spacing: .3px;
}
input[type="date"] { color-scheme: dark; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"], input[type="number"], input[type="date"] {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 16px; outline: none;
  font-family: var(--font-body);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(168,85,247,.2); }
input::placeholder { color: #8f7bab; }

/* Number inputs: force the same dark theme, hide browser spinner arrows */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

/* Chrome autofill: keep fields dark instead of Chrome's light-blue */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 99999s ease-in-out 0s;
}

/* ── Search ── */
.search-bar { position: relative; margin-bottom: 16px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .7; }
.search-bar input { padding-left: 40px; border-radius: 999px; }

/* ── Cards & lists ── */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: transform .12s ease, border-color .15s ease;
}
.card.tappable { cursor: pointer; }
.card.tappable:hover { border-color: var(--primary); transform: translateY(-1px); }
.card.tappable:active { transform: scale(.99); }
.card-title { font-size: 16px; font-weight: 600; }
.card-sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-row .btn { padding: 9px 16px; font-size: 14px; }
.card-actions { display: flex; justify-content: flex-end; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.remove-link, .edit-link {
  background: none; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px;
  font-family: var(--font-body);
}
.remove-link { color: var(--danger); }
.edit-link { color: var(--text-dim); }
.remove-link:hover, .edit-link:hover { text-decoration: underline; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 40px 24px; }
.empty-emoji { font-size: 40px; margin-bottom: 12px; }
.empty-state p { color: var(--text); font-size: 15px; font-weight: 600; }
.empty-hint { color: var(--text-dim) !important; font-size: 13px !important; font-weight: 400 !important; margin-top: 6px; line-height: 1.5; }

/* ── Pills & badges ── */
.count-pill {
  background: var(--primary); color: var(--primary-text); border-radius: 999px;
  font-size: 12px; padding: 2px 10px; margin-left: 6px; font-weight: 700;
}
.rel-pill {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--accent); border-radius: 999px; font-size: 12px; padding: 4px 11px; font-weight: 600;
}
.badge-pro {
  background: linear-gradient(135deg, #ff4da6, #a855f7); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .5px;
  border-radius: 999px; padding: 4px 10px; margin-left: 8px; vertical-align: middle;
}

/* ── Avatars ── */
.avatar {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #ff4da6, #a855f7);
  flex-shrink: 0; user-select: none;
}
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-sm { width: 34px; height: 34px; font-size: 14px; }

/* ── Chips ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 14px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.chip:active { transform: scale(.95); }
.chip.selected { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }

/* ── Other-detail box ── */
#other-detail-wrap { margin-bottom: 16px; }
.char-counter { text-align: right; color: var(--text-dim); font-size: 12px; margin-top: 5px; }

/* ── Upsell ── */
.upsell {
  margin-top: 22px; background: linear-gradient(135deg, #2e1a44, #4a1538);
  border: 1px solid var(--accent); border-radius: 20px;
  padding: 26px 20px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.upsell-emoji { font-size: 34px; margin-bottom: 8px; }
.upsell h3 { margin-bottom: 8px; font-size: 20px; }
.upsell p { color: var(--text-dim); font-size: 14px; line-height: 1.55; }

/* ── Profile ── */
.profile-hero { display: flex; align-items: center; gap: 14px; padding: 6px 4px 18px; }
.profile-name { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.profile-plan-pill {
  display: inline-block; margin-top: 5px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; font-size: 12px; padding: 3px 11px;
}
.profile-row {
  display: flex; justify-content: space-between; padding: 11px 0;
  border-bottom: 1px solid var(--border); font-size: 15px; gap: 12px;
}
.profile-row:last-child { border-bottom: none; }
.profile-row .label { color: var(--text-dim); flex-shrink: 0; }
.profile-row span:last-child { text-align: right; word-break: break-all; }

/* ── Inmate sheet hero ── */
.inmate-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-right: 30px; }
.inmate-hero h3 { font-size: 20px; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(34,18,50,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex; z-index: 50;
}
.nav-btn {
  flex: 1; border: none; background: none; color: #a68fc4;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  transition: color .15s ease; position: relative;
}
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 30px);
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: #2b0a1c;
  font-size: 12px !important; font-weight: 700; line-height: 20px;
  text-align: center; letter-spacing: 0 !important;
  box-shadow: 0 2px 8px rgba(255,77,166,.5);
}
.nav-icon { font-size: 24px; filter: grayscale(.5); opacity: .85; transition: filter .15s ease, opacity .15s ease, transform .15s ease; }
.nav-btn span:last-child { font-size: 13px; font-weight: 600; letter-spacing: .3px; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active .nav-icon { filter: none; opacity: 1; transform: scale(1.1); }

/* ── Sheets / modals ── */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10,4,18,.72); backdrop-filter: blur(3px); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  border: 1px solid var(--border); border-bottom: none;
  padding: 26px 20px calc(26px + env(safe-area-inset-bottom));
  animation: slide-up .22s ease;
  box-shadow: 0 -10px 50px rgba(0,0,0,.5);
}
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-close {
  position: absolute; top: 14px; right: 16px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 50%; font-size: 15px; cursor: pointer;
}

/* ── Thread ── */
.sheet-thread-body { display: flex; flex-direction: column; height: 88vh; height: 88dvh; }
.thread-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.thread-id-block { flex: 1; min-width: 0; }
.thread-header h3 { font-size: 18px; }
.thread-sub { color: var(--text-dim); font-size: 12px; margin-top: 1px; }
.thread-sub:empty { display: none; }
.thread-header .sheet-close { position: static; border: none; }
.thread-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 8px; padding: 8px 2px;
}
.msg {
  max-width: 78%; padding: 11px 15px; border-radius: 18px;
  font-size: 15px; line-height: 1.45; word-wrap: break-word;
  animation: fade-in .18s ease;
}
.msg.mine { align-self: flex-end; background: var(--primary); color: var(--primary-text); border-bottom-right-radius: 5px; }
.msg.theirs { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg-time { font-size: 10px; opacity: .6; margin-top: 4px; }
.thread-input { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.thread-input input { flex: 1; border-radius: 999px; }
.thread-input .btn { padding: 12px 20px; }

/* ── Dialog ── */
.dialog-body { color: var(--text-dim); font-size: 14px; line-height: 1.65; margin: 14px 0; white-space: pre-wrap; }
#dialog-actions { display: flex; flex-direction: column; gap: 8px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--primary);
  color: var(--text); padding: 12px 22px; border-radius: 999px;
  font-size: 14px; z-index: 200; animation: slide-up .2s ease;
  max-width: 90vw; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}

/* ── Desktop layout: top nav bar, wider pages, card grids ── */
.nav-brand { display: none; }
@media (min-width: 900px) {
  #view-app { padding-bottom: 40px; padding-top: 88px; }
  .page { max-width: 980px; padding-top: 24px; }
  .page-header h2 { font-size: 34px; }
  .bottom-nav {
    top: 0; bottom: auto;
    height: 72px; padding-bottom: 0;
    border-top: none; border-bottom: 1px solid var(--border);
    justify-content: center; gap: 10px;
    padding-left: 48px; padding-right: 48px;
    box-shadow: 0 4px 24px rgba(0,0,0,.4);
  }
  .nav-brand {
    display: flex; align-items: center; gap: 12px; flex-shrink: 0;
    font-family: var(--font-display); font-size: 23px; font-weight: 700;
    color: var(--text); margin-right: auto; letter-spacing: .3px;
  }
  .nav-brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 3px 10px rgba(168,85,247,.45); }
  .nav-btn {
    flex: 0 0 auto; flex-direction: row; gap: 8px;
    padding: 9px 18px; border-radius: 999px;
  }
  .nav-icon { font-size: 18px; }
  .nav-btn span:last-child { font-size: 14px; }
  .nav-btn.active { background: rgba(255,77,166,.14); }
  .nav-btn.active .nav-icon { transform: none; }
  .nav-badge { position: static; margin-left: 4px; }
  #directory-list, #connections-list {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  }
  .empty-state { padding: 70px 24px; }
  .empty-emoji { font-size: 52px; }
  .welcome-greeting { font-size: 24px; }
}

/* ── Larger screens ── */
@media (min-width: 640px) {
  .sheet-body { max-width: 560px; left: 50%; transform: translateX(-50%); border-radius: 24px; bottom: 5vh; border-bottom: 1px solid var(--border); }
  @keyframes slide-up { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
  .sheet-thread-body { height: 80vh; }
}
