/* ==========================================================================
   AnonWhisper Mini App — Glassmorphic Telegram Native Theme
   ========================================================================== */

:root {
  --bg-main: var(--tg-theme-bg-color, #0b0f19);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #111827);
  --card-bg: rgba(22, 30, 46, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: var(--tg-theme-text-color, #f8fafc);
  --text-secondary: var(--tg-theme-hint-color, #94a3b8);
  --accent: var(--tg-theme-button-color, #6366f1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --star-gold: #fbbf24;
  --star-glow: rgba(251, 191, 36, 0.25);
  --green: #10b981;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(217, 70, 239, 0.10) 0%, transparent 40%);
  background-attachment: fixed;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 20px));
}

/* ==================== DEV BANNER ==================== */
.dev-banner {
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  z-index: 100;
}

.dev-badge {
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.dev-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dev-btn {
  background: #334155;
  color: #94a3b8;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s;
}

.dev-btn.active {
  background: var(--accent);
  color: #ffffff;
}

/* ==================== APP HEADER ==================== */
.app-header {
  padding: 18px 20px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 40;
  border-bottom: 1px solid var(--card-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.back-btn:active {
  transform: scale(0.92);
}

.header-title-box h1 {
  font-size: 20px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.header-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.user-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  overflow: hidden;
  font-weight: 700;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  padding: 16px 20px;
}

.tab-view {
  animation: fadeIn 0.25s ease-out;
}

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

.section-intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.create-session-fab {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
  white-space: nowrap;
}

.create-session-fab:active {
  transform: scale(0.95);
}

/* ==================== SESSIONS LIST ==================== */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.session-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.session-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.session-card:active {
  transform: scale(0.985);
}

.session-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.session-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topic-tag {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.count-tag {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.session-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 10px;
}

.link-code {
  font-family: monospace;
  font-size: 12px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}

.card-action-btns {
  display: flex;
  gap: 6px;
}

.tiny-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-primary);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tiny-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.tiny-btn:active {
  transform: scale(0.92);
}

/* ==================== SESSION HEADER IN MESSAGES VIEW ==================== */
.session-header-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.active-title {
  font-size: 19px;
  font-weight: 800;
  color: #ffffff;
  margin: 10px 0;
}

.link-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.link-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: #ffffff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.messages-heading {
  margin-bottom: 12px;
}

.messages-heading h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ==================== MESSAGES LIST ==================== */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-card:active {
  transform: scale(0.985);
}

.message-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.time-tag {
  font-size: 12px;
  color: var(--text-secondary);
}

.message-preview-text {
  font-size: 15px;
  line-height: 1.45;
  color: #f1f5f9;
  font-weight: 500;
  word-break: break-word;
}

.message-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.status-pill.locked {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.status-pill.unlocked {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.status-pill.replied {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.status-pill.waiting {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.reply-preview-chip {
  font-size: 12px;
  color: #818cf8;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==================== BOTTOM NAV ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(65px + env(safe-area-inset-bottom, 16px));
  padding-bottom: env(safe-area-inset-bottom, 16px);
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 30px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-icon-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
}

.nav-label {
  font-size: 12px;
  font-weight: 600;
}

.nav-tab.active {
  color: #818cf8;
}

.nav-tab.active .nav-icon-box svg {
  stroke: #818cf8;
}

/* ==================== MODALS & SHEETS ==================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: #131b2e;
  border: 1px solid var(--card-border);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 550px;
  max-height: 85vh;
  padding: 22px 24px calc(24px + env(safe-area-inset-bottom, 20px));
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-pill-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 12px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
}

.close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* Form controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"], textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.suggested-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.chip:active {
  background: var(--accent);
  color: #ffffff;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.btn-primary {
  flex: 1;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ==================== ANONYMOUS MESSAGE DETAIL BUBBLE ==================== */
.anon-bubble {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 18px;
}

.bubble-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #a5b4fc;
  margin-bottom: 8px;
}

.bubble-text {
  font-size: 17px;
  line-height: 1.5;
  color: #ffffff;
  font-weight: 600;
}

/* ==================== CLUES BOX ==================== */
.clues-section {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
}

.clues-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.clues-title {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
}

.clues-locked-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clues-teaser {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.unlock-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--star-glow);
}

.unlock-btn:active {
  transform: scale(0.98);
}

.clue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.clue-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.clue-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.clue-val {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.clue-val.hint-code {
  font-family: monospace;
  color: #38bdf8;
}

/* ==================== REPLY SECTION ==================== */
.reply-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply-title {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
}

.already-replied-box .reply-bubble {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 12px 14px;
}

.reply-meta {
  font-size: 11px;
  font-weight: 700;
  color: #a5b4fc;
}

.reply-text {
  font-size: 15px;
  color: #ffffff;
  margin: 4px 0 6px;
  font-weight: 500;
}

.reply-timestamp {
  font-size: 11px;
  color: var(--text-secondary);
}

.reply-form-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply-send-btn {
  padding: 11px 16px;
}

/* ==================== EMPTY & LOADING STATES ==================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 40px;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-sub {
  font-size: 13px;
  max-width: 280px;
  line-height: 1.4;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  bottom: calc(85px + env(safe-area-inset-bottom, 16px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  z-index: 200;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.hidden {
  display: none !important;
}

