/* v3.9 — webapp/app.css (Complete File — Comforting Sky Light Blue Rounded Design System) */
:root {
  --bg: #f6fbff;
  --bg-sec: #ebf4fc;
  --section-bg: #ffffff;
  --surface-soft: #f2f8fe;
  --surface-tint: #e1f1fd;

  --text: #152b3c;
  --hint: #5c768d;
  --link: #0284c7;

  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-text: #ffffff;
  --accent-soft: rgba(2, 132, 199, 0.12);

  --sep: rgba(14, 116, 196, 0.13);
  --card-border: rgba(14, 116, 196, 0.14);
  --card-shadow: 0 2px 10px rgba(14, 90, 145, 0.055);

  --success: #1e9b60;
  --success-soft: rgba(30, 155, 96, 0.13);
  --warn: #c77b24;
  --warn-soft: rgba(199, 123, 36, 0.14);
  --danger: #d44a4a;
  --danger-soft: rgba(212, 74, 74, 0.13);

  --bubble-out: #dff1fd;
  --bubble-out-border: rgba(2, 132, 199, 0.22);

  --safe-top: 0px;
  --safe-bottom: 0px;
  --app-h: 100vh;
  --nav-h: 60px;
  --top-h: 56px;
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111d28;
    --bg-sec: #0d1720;
    --section-bg: #162432;
    --surface-soft: #1b2c3d;
    --surface-tint: rgba(56, 189, 248, 0.14);

    --text: #e6f1fa;
    --hint: #8ca4ba;
    --link: #56bff7;

    --accent: #38a9e8;
    --accent-hover: #2b96d3;
    --accent-text: #ffffff;
    --accent-soft: rgba(56, 169, 232, 0.16);

    --sep: rgba(148, 197, 238, 0.10);
    --card-border: rgba(148, 197, 238, 0.12);
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);

    --success: #3cb57a;
    --success-soft: rgba(60, 181, 122, 0.16);
    --warn: #e29d4c;
    --warn-soft: rgba(226, 157, 76, 0.16);
    --danger: #e06363;
    --danger-soft: rgba(224, 99, 99, 0.16);

    --bubble-out: #1c3952;
    --bubble-out-border: rgba(86, 191, 247, 0.25);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* v4.0 — webapp/app.css (Patch 2A — fixed full-viewport shell, no resume blank glitch) */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-sec);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------------- APP SHELL ---------------- */

.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding-top: var(--safe-top);
  background: var(--bg-sec);
  overflow: hidden;
}

.top-bar {
  flex: 0 0 var(--top-h);
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  background: var(--section-bg);
  border-bottom: 1px solid var(--sep);
  z-index: 20;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.top-title-wrap {
  min-width: 0;
  flex: 1;
}

.top-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-subtitle {
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.main-view {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 calc(20px + var(--safe-bottom));
  position: relative;
  z-index: 1;
}

.main-view.scroll-locked {
  overflow: hidden;
  pointer-events: none;
}

.bottom-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  background: var(--section-bg);
  border-top: 1px solid var(--sep);
  padding: 4px 6px calc(4px + var(--safe-bottom));
  gap: 2px;
  z-index: 20;
}

.nav-item {
  flex: 1;
  height: calc(var(--nav-h) - 8px);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--hint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 4px 2px;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-ico {
  width: 21px;
  height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-lbl {
  font-size: 11px;
  font-weight: 600;
}

/* ---------------- PREMIUM ROUNDED CARDS & LISTS ---------------- */

.section-pad {
  padding: 6px 12px 10px;
}

.section-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  color: var(--hint);
  padding: 12px 16px 6px;
}

.card {
  margin: 0 12px 10px;
  padding: 14px;
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.card-sky {
  margin: 0 12px 10px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.tg-list {
  margin: 0 12px 10px;
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.sheet-body .tg-list {
  margin: 0 0 12px;
  box-shadow: none;
}

.tg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--sep);
  min-height: 52px;
}

.tg-row:last-child {
  border-bottom: none;
}

.tg-row.clickable {
  cursor: pointer;
}

.tg-row.clickable:active {
  background: var(--surface-soft);
}

.row-main {
  min-width: 0;
  flex: 1;
}

.row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.row-sub {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
  word-break: break-word;
}

.row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.row-ico {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--surface-tint);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.row-ico.danger { color: var(--danger); background: var(--danger-soft); }
.row-ico.success { color: var(--success); background: var(--success-soft); }
.row-ico.warn { color: var(--warn); background: var(--warn-soft); }

/* ---------------- STATS & ONBOARDING STEPS ---------------- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 12px 10px;
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.stat-cell {
  padding: 12px 6px;
  text-align: center;
  border-right: 1px solid var(--sep);
}

.stat-cell:last-child {
  border-right: none;
}

.stat-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.stat-key {
  font-size: 11px;
  color: var(--hint);
  margin-top: 2px;
}

.stat-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 12px 10px;
}

.stat-tile {
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--card-shadow);
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--section-bg);
  border: 1px solid var(--card-border);
}

.step-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-badge.done {
  background: var(--success);
}

/* ---------------- PILLS & TACTILE TOGGLE SLIDERS ---------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-muted { background: var(--surface-soft); color: var(--hint); border: 1px solid var(--sep); }

.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(120, 144, 168, 0.34);
  border: 1px solid rgba(14, 116, 196, 0.12);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.toggle-switch.on {
  background: var(--success);
  border-color: var(--success);
}

.toggle-switch.on::after {
  transform: translateX(20px);
}

.toggle-switch:disabled {
  opacity: 0.52;
  cursor: wait;
}

/* ---------------- BUTTONS, SEGMENTED CONTROLS & CHIPS ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.12s ease, transform 0.08s ease;
}

.btn:active { opacity: 0.84; transform: scale(0.99); }
.btn:disabled { opacity: 0.48; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-success { background: var(--success); color: #ffffff; }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-soft {
  background: var(--surface-tint);
  color: var(--accent);
  border-color: var(--card-border);
}
.btn-secondary {
  background: var(--section-bg);
  color: var(--text);
  border-color: var(--card-border);
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
}
.btn-sm {
  min-height: 32px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: var(--surface-soft);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:active {
  background: var(--surface-tint);
}

.back-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 33px;
  padding: 4px 11px 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--surface-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.back-pill-btn:active {
  background: var(--surface-tint);
}

.seg-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 5px;
  margin: 0 12px 10px;
  padding: 4px;
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}

.seg-btn {
  flex: 1;
  min-height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--hint);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.chip-scroll {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 12px 10px;
  scrollbar-width: none;
}

.chip-scroll::-webkit-scrollbar { display: none; }

.overlay-screen .chip-scroll {
  padding: 8px 12px;
  background: var(--section-bg);
  border-bottom: 1px solid var(--sep);
}

.chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--section-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* ---------------- INPUTS & FORMS ---------------- */

.search-wrap {
  flex: 0 0 auto;
  padding: 0 12px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.overlay-screen .search-wrap {
  padding: 8px 12px;
  background: var(--section-bg);
  border-bottom: 1px solid var(--sep);
}

.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--section-bg);
  color: var(--text);
  outline: none;
}

.sheet-body .input, .sheet-body .textarea, .sheet-body .select,
.card .input, .card .textarea, .card .select {
  background: var(--surface-soft);
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.field {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 5px;
}

.field-hint {
  font-size: 11.5px;
  color: var(--hint);
  margin-top: 4px;
}

/* ---------------- OTP KEYPAD & CLOCK ---------------- */

.otp-display {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
}

.otp-slot {
  width: 44px;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--card-border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.otp-slot.filled {
  border-color: var(--accent);
  background: var(--section-bg);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 8px;
}

.key-btn {
  height: 46px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--section-bg);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.key-btn:active {
  background: var(--surface-tint);
}

.clock-readout {
  text-align: center;
  padding: 16px 12px;
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}

/* ---------------- EMPTY, NOTICE & SKELETON STATES ---------------- */

.empty-state {
  margin: 0 12px 10px;
  padding: 26px 18px;
  text-align: center;
  color: var(--hint);
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.empty-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.notice-box {
  margin: 0 12px 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--section-bg);
  font-size: 13px;
  box-shadow: var(--card-shadow);
}

.notice-box.sky { background: var(--surface-soft); border-color: rgba(2, 132, 199, 0.25); }
.notice-box.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice-box.danger { border-color: var(--danger); background: var(--danger-soft); }
.notice-box.success { border-color: var(--success); background: var(--success-soft); }

.skeleton {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.06) 25%, rgba(2, 132, 199, 0.13) 50%, rgba(2, 132, 199, 0.06) 75%);
  background-size: 200% 100%;
  animation: skPulse 1.2s infinite linear;
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.sk-card { height: 78px; }
.sk-row { height: 54px; }

@keyframes skPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------------- BOUNDED BOTTOM SHEET (MAX 76VH + EXPLICIT CLOSE) ---------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 44, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 120;
}

.sheet-panel {
  width: 100%;
  max-width: 560px;
  max-height: 76vh;
  background: var(--section-bg);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
  box-shadow: 0 -8px 28px rgba(10, 35, 60, 0.20);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--sep);
  margin: 8px auto 2px;
  flex-shrink: 0;
}

.sheet-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 14px 10px;
  border-bottom: 1px solid var(--sep);
}

.sheet-title {
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-body {
  flex: 1 1 auto;
  padding: 14px 14px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 44, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 140;
}

.confirm-box {
  width: 100%;
  max-width: 340px;
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 12px 32px rgba(10, 35, 60, 0.24);
}

.confirm-title {
  font-size: 15.5px;
  font-weight: 700;
  margin-bottom: 6px;
}

.confirm-desc {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 16px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-bar {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 10px);
  max-width: 480px;
  margin: 0 auto;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: #173046;
  color: #f4f9fd;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  z-index: 180;
  box-shadow: 0 6px 18px rgba(10, 35, 60, 0.26);
}

.toast-bar.error { background: var(--danger); color: #ffffff; }
.toast-bar.success { background: var(--success); color: #ffffff; }

/* ---------------- ISOLATED CHAT OVERLAY & ADMIN LIGHTBOX ---------------- */

/* v4.0 — webapp/app.css (Patch 2B — resilient full-screen chat overlay) */
/* ---------------- ISOLATED CHAT OVERLAY & ADMIN LIGHTBOX ---------------- */

.overlay-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background: var(--bg-sec);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--section-bg);
  border-bottom: 1px solid var(--sep);
  z-index: 5;
}

.chat-stream {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.msg-row.in { align-self: flex-start; }
.msg-row.out { align-self: flex-end; }

.msg-bubble {
  padding: 9px 12px;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: var(--section-bg);
  color: var(--text);
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(14, 90, 145, 0.04);
}

.msg-row.out .msg-bubble {
  background: var(--bubble-out);
  border-color: var(--bubble-out-border);
}

.msg-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.msg-fwd {
  font-size: 11px;
  color: var(--hint);
  border-left: 2px solid var(--accent);
  padding-left: 6px;
  margin-bottom: 4px;
}

.msg-text {
  font-size: 13.5px;
  white-space: pre-wrap;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--hint);
}

.msg-media-thumb {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  cursor: pointer;
}

.msg-media-thumb img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
}

.media-tile {
  aspect-ratio: 1 / 1;
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.media-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-tile-badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  right: 5px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15, 29, 44, 0.76);
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 17, 25, 0.96);
  color: #f4f9fd;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  z-index: 160;
}

.lightbox-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.lightbox-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 10px;
}

.lightbox-stage img,
.lightbox-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.lightbox-bottom {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}