/* JDS Student App — premium mobile-first PWA */

:root {
  --purple: #5b1d78;
  --purple-mid: #6e2a8f;
  --purple-dark: #2a0d3a;
  --purple-deep: #1a0826;
  --purple-light: #8b4aad;
  --gold: #d4a84b;
  --gold-soft: #e8c878;
  --gold-glow: rgba(212, 168, 75, 0.35);
  --accent: #c47aff;
  --bg: #f6f3f9;
  --bg-soft: #efe8f5;
  --card: #ffffff;
  --text: #1a1024;
  --muted: #6f6578;
  --border: #e8dff0;
  --border-soft: rgba(91, 29, 120, 0.08);
  --debit: #d32f2f;
  --credit: #2e7d32;
  --pending: #e65100;
  --ok: #2e7d32;
  --danger: #c62828;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 4px 20px rgba(42, 13, 58, 0.08), 0 1px 3px rgba(42, 13, 58, 0.04);
  --shadow-lg: 0 12px 40px rgba(42, 13, 58, 0.14), 0 4px 12px rgba(42, 13, 58, 0.06);
  --shadow-tile: 0 6px 24px rgba(91, 29, 120, 0.1);
  --header-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(196, 122, 255, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(212, 168, 75, 0.1), transparent 50%),
    linear-gradient(180deg, #faf7fc 0%, var(--bg) 40%, var(--bg-soft) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: var(--safe-bottom);
  min-height: 100dvh;
}

button, input, textarea, select { font: inherit; }
a {
  color: var(--purple-mid);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--purple); }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

/* Header — polished purple/dark */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background:
    linear-gradient(135deg, var(--purple-deep) 0%, var(--purple-dark) 45%, var(--purple) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 14px;
  padding-right: 14px;
  box-shadow:
    0 4px 24px rgba(26, 8, 38, 0.35),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(212, 168, 75, 0.22);
}

.app-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.55;
  pointer-events: none;
}

.app-header .logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #fff;
  font-size: 1.35rem;
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.12s ease;
  text-decoration: none;
  flex-shrink: 0;
}
.app-header .icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.app-header .icon-btn:active {
  transform: scale(0.94);
}

/* Screens */
.screen {
  min-height: calc(100dvh - var(--header-h) - var(--safe-top));
  padding: 20px 18px 28px;
  max-width: 560px;
  margin: 0 auto;
  animation: fadeUp 0.35s ease both;
}
.screen.full { max-width: 720px; }

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

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  padding: 22px 20px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease;
}
.card h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--purple-dark);
}
.muted {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}
.center { text-align: center; }

/* Hero logo on gate */
.gate-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 16px;
  object-fit: cover;
  background: #000;
  box-shadow:
    0 0 0 3px var(--gold),
    0 0 0 8px rgba(212, 168, 75, 0.2),
    var(--shadow-lg);
}

.gate-photo {
  width: 120px;
  height: 120px;
  border-radius: 20px;
  margin: 0 auto 14px;
  object-fit: cover;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}

/* Forms */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 16px 0 8px;
  color: var(--purple-dark);
}
label:first-child { margin-top: 0; }

input[type="text"],
input[type="number"],
input[type="search"],
input[type="password"],
input[type="date"],
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfafc;
  outline: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:hover, textarea:hover {
  border-color: #d4c4e0;
}
input:focus, textarea:focus {
  border-color: var(--purple-light);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(139, 74, 173, 0.16);
}
textarea { min-height: 80px; resize: vertical; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-weight: 650;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple-mid) 0%, var(--purple) 100%);
  color: #fff;
  width: 100%;
  margin-top: 14px;
  box-shadow: 0 4px 14px rgba(91, 29, 120, 0.3);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 6px 18px rgba(91, 29, 120, 0.38);
}
.btn:active { transform: scale(0.98); }

.btn.secondary {
  background: linear-gradient(135deg, #5c5664 0%, #4a4450 100%);
  box-shadow: 0 4px 12px rgba(40, 36, 48, 0.2);
}
.btn.ghost {
  background: transparent;
  color: var(--purple);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn.ghost:hover {
  background: rgba(91, 29, 120, 0.05);
  border-color: var(--purple-light);
  filter: none;
}
.btn.danger {
  background: linear-gradient(135deg, #e53935 0%, var(--danger) 100%);
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.28);
}
.btn.ok {
  background: linear-gradient(135deg, #43a047 0%, var(--ok) 100%);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.28);
}
.btn.sm {
  width: auto;
  padding: 9px 16px;
  margin: 0;
  font-size: 0.875rem;
  box-shadow: 0 2px 8px rgba(91, 29, 120, 0.2);
}
.btn.ghost.sm { box-shadow: none; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.btn-row .btn { margin-top: 0; flex: 1; min-width: 120px; }

/* Language bar */
.lang-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 14px 0 0;
  flex-wrap: wrap;
}
.lang-bar .btn {
  width: auto;
  margin: 0;
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Face capture */
.face-box {
  position: relative;
  width: 100%;
  max-width: 260px;
  margin: 14px auto;
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(160deg, #1a0826, #2a0d3a);
  border: 2px solid rgba(212, 168, 75, 0.45);
  box-shadow: var(--shadow-lg), 0 0 0 6px rgba(212, 168, 75, 0.1);
}
.face-box video,
.face-box img,
.face-box canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  opacity: 0.55;
  pointer-events: none;
}
.face-box video:not(.hidden) ~ .face-placeholder,
.face-box img:not(.hidden) ~ .face-placeholder { display: none; }
.btn:disabled { opacity: 0.65; cursor: wait; filter: grayscale(0.2); }

.face-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.status-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.status-pill.pending {
  background: linear-gradient(135deg, #fff8e1, #ffe0b2);
  color: var(--pending);
}
.status-pill.approved {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  color: var(--ok);
}
.status-pill.denied {
  background: linear-gradient(135deg, #ffebee, #ffcdd2);
  color: var(--danger);
}
.status-pill.unlocked {
  background: linear-gradient(135deg, #f3e5f5, #e1bee7);
  color: var(--purple);
}

.passcode-input {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.45em;
  text-align: center;
  font-weight: 700;
  padding-left: 0.45em !important;
}

/* Home */
.welcome {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  padding: 16px 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
}
.welcome img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  box-shadow: 0 0 0 2px var(--gold), 0 2px 10px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.welcome strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}
.tile {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tile);
  border: 1px solid var(--border-soft);
  padding: 22px 14px 18px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  min-height: 124px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(91, 29, 120, 0.04), transparent 55%);
  pointer-events: none;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(139, 74, 173, 0.25);
}
.tile:active { transform: scale(0.97); }
.tile .emoji {
  font-size: 1.85rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #f3e8fa, #ebe0f5);
  margin-bottom: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.tile .label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  position: relative;
}
.tile .sub {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
  position: relative;
}

.admin-link {
  display: block;
  text-align: center;
  margin-top: 28px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.admin-link:hover {
  color: var(--purple);
  background: rgba(91, 29, 120, 0.05);
}

/* Ledger — create banner */
.create-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  padding: 16px 18px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  margin-bottom: 14px;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.create-banner:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.create-banner:active { transform: scale(0.99); }
.create-banner .book-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--purple-mid), #a855c8 60%, var(--gold-soft));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(91, 29, 120, 0.3);
}
.create-banner .text { flex: 1; min-width: 0; }
.create-banner .text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.create-banner .text span {
  font-size: 0.78rem;
  color: var(--muted);
}
.create-banner .plus {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #66bb6a, #2e7d32);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
  flex-shrink: 0;
}

.search-wrap {
  margin-bottom: 14px;
  position: relative;
}
.search-wrap input {
  padding-left: 44px;
  border-radius: var(--radius-pill);
  background: var(--card);
}
.search-wrap .search-ico {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.45;
  font-size: 0.95rem;
  pointer-events: none;
}

.book-list { list-style: none; margin: 0; padding: 0; }
.book-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.book-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.book-item:active { transform: scale(0.99); }
.book-item .thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple) 0%, #ce93d8 100%);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91, 29, 120, 0.25);
}
.book-item .meta { flex: 1; min-width: 0; }
.book-item .meta strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-item .bal {
  font-family: var(--font-display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}
.book-item .bal.neg { color: var(--debit); }
.book-item .bal.pos { color: var(--credit); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Ledger — book detail */
.balance-hero {
  text-align: center;
  padding: 24px 8px 6px;
  font-family: var(--font-display);
  font-size: 2.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--purple-dark);
}
.balance-hero.neg { color: var(--debit); }

.dc-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.dc-btn {
  flex: 1;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border-soft);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.dc-btn:hover { box-shadow: var(--shadow-lg); }
.dc-btn:active { transform: scale(0.97); }
.dc-btn.debit {
  color: var(--debit);
  background: linear-gradient(180deg, #fff 0%, #fff5f5 100%);
  border-color: rgba(211, 47, 47, 0.15);
}
.dc-btn.credit {
  color: var(--credit);
  background: linear-gradient(180deg, #fff 0%, #f1f8f2 100%);
  border-color: rgba(46, 125, 50, 0.15);
}
.dc-btn .sign { font-size: 1.35rem; font-weight: 800; }

.ledger-table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}
.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 480px;
}
.ledger-table th {
  background: linear-gradient(180deg, #f8f0fc, #f3e5f5);
  color: var(--purple-dark);
  padding: 12px 10px;
  text-align: left;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}
.ledger-table th.debits { color: var(--debit); }
.ledger-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
}
.ledger-table tbody tr {
  transition: background 0.12s ease;
  cursor: pointer;
}
.ledger-table tbody tr:hover { background: #faf5fc; }
.ledger-table tbody tr:active { background: #f3e8fa; }

.ledger-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  padding: 12px 4px;
  color: var(--muted);
}
.ledger-footer .totals {
  margin-left: auto;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ledger-footer .totals .d {
  color: var(--debit);
  margin-right: 10px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 6, 28, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: linear-gradient(160deg, #2e2438 0%, #1f1828 100%);
  color: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 380px;
  padding: 24px 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal.light {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-soft);
}
.modal h3 {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
  font-size: 1.2rem;
}
.modal.light h3 { color: var(--purple-dark); }
.modal input, .modal textarea {
  margin-bottom: 10px;
  background: #fff;
  color: #111;
}
.modal .hint-req::placeholder { color: #c62828; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.modal-actions .btn {
  margin-top: 0;
  background: #4a4554;
  box-shadow: none;
}
.modal-actions .btn.primary {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #1a1024;
  font-weight: 750;
}
.modal.light .modal-actions .btn {
  background: linear-gradient(135deg, var(--purple-mid), var(--purple));
  color: #fff;
  box-shadow: 0 4px 12px rgba(91, 29, 120, 0.25);
}
.modal.light .modal-actions .btn.secondary {
  background: #5a5460;
  box-shadow: none;
}

/* Admin */
.admin-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.admin-card img.face {
  width: 96px;
  height: 96px;
  border-radius: 16px;
  object-fit: cover;
  flex-shrink: 0;
  background: #eee;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}
.admin-card .info { flex: 1; min-width: 0; }
.admin-card .info > strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.passcode-reveal {
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  color: #fff;
  padding: 14px 16px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.3em;
  font-weight: 800;
  text-align: center;
  margin-top: 10px;
  box-shadow: 0 4px 14px rgba(46, 125, 50, 0.3);
}

.stub-body {
  padding: 36px 16px;
  text-align: center;
}
.stub-body .emoji {
  font-size: 3.2rem;
  margin-bottom: 12px;
  display: inline-grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: linear-gradient(145deg, #f3e8fa, #ebe0f5);
  box-shadow: var(--shadow);
}

/* Banner accent for admin deep-link results */
.banner-ok {
  border-left: 4px solid var(--ok) !important;
}
.banner-err {
  border-left: 4px solid var(--danger) !important;
}

@media (min-width: 600px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .screen { padding: 28px 24px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* —— Profile / Prayer / Translator (v7) —— */
.welcome-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.55), 0 2px 8px rgba(0, 0, 0, 0.12);
  background: #eee;
}
.welcome-fb {
  margin-left: 6px;
  font-weight: 600;
  font-size: 0.8rem;
}

.profile-card .profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.profile-avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-lg), 0 0 0 3px rgba(212, 168, 75, 0.45);
  background: linear-gradient(145deg, #f3e8fa, #ebe0f5);
}
.profile-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.feature-hero {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}
.feature-emoji {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f3e8fa, #ebe0f5);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.confirm-card { padding: 36px 20px; }
.confirm-check {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  box-shadow: 0 8px 24px rgba(46, 125, 50, 0.35);
}

.tx-langs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.tx-langs select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--purple) 50%),
    linear-gradient(135deg, var(--purple) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.tx-swap {
  margin-bottom: 2px;
  background: linear-gradient(145deg, #f3e8fa, #ebe0f5) !important;
  color: var(--purple-dark) !important;
  border: 1px solid var(--border-soft);
  width: 44px;
  height: 44px;
  border-radius: 12px;
}
.tx-result {
  background: linear-gradient(180deg, #faf7fc, #f3e8fa);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 64px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 1.05rem;
  margin-bottom: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--purple-dark);
}
.phrase-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.phrase-cat {
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--purple-mid);
  margin: 8px 2px 2px;
}
.phrase-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.phrase-row:hover {
  box-shadow: var(--shadow-tile);
  transform: translateY(-1px);
}
.phrase-row:active { transform: scale(0.99); }
.phrase-row strong {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
}
.phrase-row .muted { font-size: 0.82rem; }

textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  resize: vertical;
  min-height: 96px;
  margin-bottom: 10px;
  line-height: 1.45;
}
textarea:focus {
  outline: none;
  border-color: var(--purple-light);
  box-shadow: 0 0 0 3px rgba(139, 74, 173, 0.18);
}


.welcome-meta { flex: 1; min-width: 0; }
.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.welcome-edit {
  margin: 0 !important;
  padding: 6px 12px !important;
  font-size: 0.78rem !important;
  border-radius: var(--radius-pill) !important;
  background: rgba(91, 29, 120, 0.08) !important;
  color: var(--purple) !important;
  border: 1px solid var(--border-soft) !important;
  box-shadow: none !important;
  width: auto !important;
}
.welcome-edit:hover {
  background: rgba(91, 29, 120, 0.14) !important;
}

.profile-wall {
  text-align: center;
  padding: 28px 20px 22px !important;
  background:
    radial-gradient(600px 200px at 50% 0%, rgba(196, 122, 255, 0.16), transparent 60%),
    var(--card) !important;
}
.profile-wall-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.profile-wall-name {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--purple-dark);
}
.profile-fb-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 650;
  font-size: 0.9rem;
  color: var(--purple-mid);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(91, 29, 120, 0.06);
  border: 1px solid var(--border-soft);
}
.profile-fb-link:hover { background: rgba(91, 29, 120, 0.12); }

/* —— Group Chat (Slack-style) —— */
.chat-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 8px;
  min-height: calc(100dvh - var(--header-h) - var(--safe-top) - 8px);
}

.chat-channel-screen {
  gap: 0;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
  height: calc(100dvh - var(--header-h) - var(--safe-top));
  min-height: 0;
  max-width: none;
}

.chat-hero {
  margin: 0 4px;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(42, 13, 58, 0.96), rgba(91, 29, 120, 0.92)),
    var(--purple-dark);
  color: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(212, 168, 75, 0.28);
}

.chat-hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.chat-hero-sub {
  margin: 6px 0 0;
  opacity: 0.85;
  font-size: 0.9rem;
  line-height: 1.45;
}

.chat-pad { padding: 0 16px; }

.chat-section-card {
  margin: 0 4px 12px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-nav-list {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}

.chat-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s ease;
}

.chat-nav-item:hover,
.chat-nav-item:active {
  background: var(--bg-soft);
}

.chat-nav-hash {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--purple-mid), var(--purple-dark));
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-nav-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-nav-meta strong {
  font-weight: 650;
  font-size: 0.98rem;
}

.chat-nav-meta .muted {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-nav-chev {
  color: var(--muted);
  font-size: 1.25rem;
  opacity: 0.55;
}

.chat-empty-inline,
.chat-empty,
.chat-loading {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.chat-topic {
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
}

.chat-timeline {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.chat-day-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

.chat-day-sep span {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: chatIn 0.22s ease;
}

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

.chat-msg.mine .chat-msg-body {
  background: linear-gradient(160deg, rgba(91, 29, 120, 0.08), rgba(212, 168, 75, 0.06));
  border-color: rgba(91, 29, 120, 0.14);
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
}

.chat-avatar.sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.chat-avatar-fallback {
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, var(--purple-light), var(--purple-dark));
  border: 0;
}

.chat-msg-body {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 10px 12px 8px;
  box-shadow: 0 2px 10px rgba(42, 13, 58, 0.04);
}

.chat-msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-msg-head strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.chat-msg-time {
  font-size: 0.72rem;
  color: var(--muted);
}

.chat-msg-text {
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-photo {
  margin-top: 8px;
  border-radius: 12px;
  max-height: 280px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border: 1px solid var(--border-soft);
}

.chat-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.chat-action,
.chat-replies-btn {
  border: 0;
  background: transparent;
  color: var(--purple-mid);
  font-size: 0.78rem;
  font-weight: 650;
  padding: 4px 0;
  cursor: pointer;
}

.chat-replies-btn {
  color: var(--gold);
  background: rgba(212, 168, 75, 0.12);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.chat-composer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px calc(12px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(246, 243, 249, 0.4), rgba(255, 255, 255, 0.98));
  border-top: 1px solid var(--border-soft);
  backdrop-filter: blur(12px);
}

.chat-xlate-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.chat-xlate-label {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-xlate-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chat-xlate-pill {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 650;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.chat-xlate-pill.active {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple-mid));
  color: #fff;
  border-color: transparent;
}
.chat-xlate-hint {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  background: rgba(212, 168, 75, 0.12);
  border: 1px solid rgba(212, 168, 75, 0.28);
  border-radius: 10px;
  padding: 6px 10px;
}

.chat-composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-attach-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.25rem;
}

#chat-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: none;
  min-height: 56px;
  max-height: 160px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  outline: none;
  line-height: 1.45;
  font-size: 1.05rem;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

#chat-input:focus {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 3px rgba(139, 74, 173, 0.18);
}

.chat-send {
  flex: 1;
  min-height: 48px;
  height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
}

.chat-msg-xlate {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(139, 74, 173, 0.08);
  border: 1px solid rgba(139, 74, 173, 0.16);
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}
.chat-xlate-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--purple-mid);
  margin-right: 6px;
  vertical-align: middle;
}
.chat-xlate-body { vertical-align: middle; }
.chat-xlate-pending,
.chat-xlate-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}
.chat-xlate-engine {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.8;
}

.chat-attach-preview {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
}

.chat-attach-preview img {
  max-height: 96px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.chat-attach-x {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--purple-dark);
  color: #fff;
  border: 0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.chat-send-err {
  min-height: 1.1em;
  font-size: 0.8rem;
  margin-top: 4px;
  color: var(--danger);
}

/* —— Games —— */
.games-screen { gap: 14px; }
.games-hero {
  margin: 0 4px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1a0826, #5b1d78 70%);
  color: #fff;
  border: 1px solid rgba(212, 168, 75, 0.28);
  box-shadow: var(--shadow-lg);
}
.games-hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
}
.games-hero-sub { margin: 6px 0 0; opacity: 0.85; font-size: 0.9rem; }

.games-tiles { display: flex; flex-direction: column; gap: 10px; margin: 0 4px; }
.games-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  color: inherit;
}
.games-tile:active { transform: scale(0.98); }
.games-tile-emoji {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.5rem;
  background: linear-gradient(145deg, var(--bg-soft), #fff);
  border: 1px solid var(--border);
}
.games-tile-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.games-tile-meta strong { font-weight: 700; }

.sudoku-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: space-between;
  margin: 0 4px;
}
.sudoku-diffs { display: flex; gap: 6px; flex-wrap: wrap; }

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
  margin: 8px auto;
  width: min(100%, 360px);
  aspect-ratio: 1;
  background: var(--purple-dark);
  border: 3px solid var(--purple-dark);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.sudoku-cell {
  border: 0;
  border-right: 1px solid rgba(255,255,255,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.95rem, 4.2vw, 1.25rem);
  color: var(--text);
  cursor: pointer;
  aspect-ratio: 1;
  padding: 0;
}
.sudoku-cell.br { border-right: 2px solid var(--purple-dark); }
.sudoku-cell.bb { border-bottom: 2px solid var(--purple-dark); }
.sudoku-cell.given { color: var(--purple-dark); background: #f3eef8; }
.sudoku-cell.selected { background: rgba(212, 168, 75, 0.35); box-shadow: inset 0 0 0 2px var(--gold); }
.sudoku-cell.same { background: rgba(91, 29, 120, 0.1); }

.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  width: min(100%, 360px);
  margin: 0 auto;
}
.sudoku-key {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  padding: 12px 0;
  font-weight: 750;
  font-family: var(--font-display);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sudoku-key:active { background: var(--bg-soft); }
.sudoku-actions {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin: 4px 0 0;
}
.sudoku-msg { text-align: center; min-height: 1.4em; font-weight: 600; }
.sudoku-msg.ok { color: var(--ok); }

.fruit-screen { align-items: stretch; }
.fruit-hud {
  display: flex; justify-content: space-between;
  margin: 0 8px; font-size: 0.95rem;
}
.fruit-hint { margin: 0 8px; font-size: 0.85rem; }
.fruit-canvas {
  display: block;
  margin: 0 auto;
  width: min(100%, 360px);
  border-radius: 16px;
  border: 1px solid rgba(212, 168, 75, 0.3);
  box-shadow: var(--shadow-lg);
  touch-action: none;
  background: #1a0826;
}
.fruit-overlay {
  position: relative;
  margin: -200px auto 0;
  z-index: 2;
  width: min(86%, 300px);
  text-align: center;
  padding: 20px;
  background: rgba(255,255,255,0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.fruit-screen #f-start { margin: 8px auto 0; display: block; width: min(100%, 200px); }
