@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@400;600;700;900&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg-base: #080B12;
  --bg-surface: #0D1220;
  --bg-card: #111827;
  --bg-card-hover: #161f30;
  --bg-popup: #0E1523;
  --border: rgba(255,255,255,0.06);
  --border-glow: rgba(0,200,255,0.25);
  --neon-cyan: #00C8FF;
  --neon-blue: #3D7EFF;
  --neon-purple: #8B5CF6;
  --neon-green: #00E5A0;
  --text-primary: #F0F4FF;
  --text-secondary: #7A8BA6;
  --text-muted: #3D4F6B;
  --accent-gradient: linear-gradient(135deg, #00C8FF 0%, #3D7EFF 50%, #8B5CF6 100%);
  --btn-gradient: linear-gradient(135deg, #00C8FF 0%, #3D7EFF 100%);
  --btn-gradient-green: linear-gradient(135deg, #00E5A0 0%, #00C8FF 100%);
  --card-shadow: 0 4px 24px rgba(0,0,0,0.4);
  --glow-shadow: 0 0 20px rgba(0,200,255,0.15), 0 4px 24px rgba(0,0,0,0.5);
  --radius-card: 20px;
  --radius-btn: 14px;
  --font-display: 'Unbounded', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --app-width: 420px;
}

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

html, body {
  height: 100%;
  background: #04060C;
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

/* ── PHONE SHELL ── */
#app {
  width: 100%;
  max-width: var(--app-width);
  min-height: 100vh;
  background: var(--bg-base);
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 20px 14px;
  background: rgba(8,11,18,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-back {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.header-back svg { display: block; pointer-events: none; }
.header-back:active { transform: scale(0.9); background: var(--bg-card-hover); }

.header-title-wrap { flex: 1; min-width: 0; }
.header-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.2px;
}

.header-logo {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── HERO BANNER ── */
.hero {
  padding: 28px 20px 20px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(61,126,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(139,92,246,0.1) 0%, transparent 70%);
  pointer-events: none;
}

.hero-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--neon-cyan);
  margin-bottom: 8px;
}

.hero-heading {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.8px;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.hero-heading span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 280px;
}

.hero-stats {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── SECTION LABEL ── */
.section-label {
  padding: 20px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-label-text {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-label-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── GRID ── */
.grid {
  padding: 0 16px 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.grid.grid-2col {
  grid-template-columns: repeat(2, 1fr);
}

/* ── CARD ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), 
              border-color 0.2s, 
              box-shadow 0.2s,
              background 0.2s;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,200,255,0.04) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--border-glow);
  box-shadow: var(--glow-shadow);
  background: var(--bg-card-hover);
}

.card:hover::before { opacity: 1; }

.card:active {
  transform: scale(0.94);
  transition: transform 0.1s;
}

.card-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}

.card-icon-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
}

.card-icon-placeholder,
.card-icon-svg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.card-icon-svg svg { display: block; flex-shrink: 0; }

.type-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg-card);
  overflow: hidden;
}

.type-badge svg { display: block; }

.type-badge.chat    { background: var(--neon-cyan); }
.type-badge.contact { background: var(--neon-green); }
.type-badge.section { background: var(--neon-purple); }

.card-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.2px;
  width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-subtitle {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1.4;
  width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── LIST CARDS (section page) ── */
.list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), 
              border-color 0.2s,
              box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.list-card:hover {
  transform: translateX(4px);
  border-color: var(--border-glow);
  box-shadow: var(--glow-shadow);
}

.list-card:active {
  transform: scale(0.97);
  transition: transform 0.08s;
}

.list-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.list-card-icon img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
}

.list-card-icon-svg {
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-card-icon-svg svg { display: block; }

.list-card-body { flex: 1; min-width: 0; }

.list-card-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.list-card-arrow {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.list-card-arrow svg { display: block; }

.list-grid {
  padding: 0 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── TYPE TAG ── */
.type-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 20px;
  margin-top: 4px;
}

.type-tag-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.type-tag-icon svg { display: block; }

.type-tag.chat {
  background: rgba(0,200,255,0.1);
  color: var(--neon-cyan);
  border: 1px solid rgba(0,200,255,0.2);
}

.type-tag.contact {
  background: rgba(0,229,160,0.1);
  color: var(--neon-green);
  border: 1px solid rgba(0,229,160,0.2);
}

/* ── POPUP ── */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.popup-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.popup {
  width: 100%;
  max-width: var(--app-width);
  background: var(--bg-popup);
  border-radius: 28px 28px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 0 0 32px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34,1.2,0.64,1);
  position: relative;
  overflow: hidden;
}

.popup-overlay.active .popup {
  transform: translateY(0);
}

.popup-drag {
  display: flex;
  justify-content: center;
  padding: 14px 0 10px;
}

.popup-drag-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-card-hover);
}

.popup-glow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  opacity: 0.6;
}

.popup-content {
  padding: 16px 24px 0;
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.popup-avatar {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.popup-avatar img {
  display: block;
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  max-width: 64px;
  max-height: 64px;
  object-fit: cover;
  object-position: center center;
  flex-shrink: 0;
  border-radius: 0;
}

.popup-avatar-svg {
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-avatar-svg svg { display: block; }

.popup-info { flex: 1; min-width: 0; }

.popup-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.popup-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 22px;
  word-break: break-word;
}

/* ── BUTTONS ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-btn);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: none;
  outline: none;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), 
              box-shadow 0.2s,
              opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.15s;
}

.btn:active {
  transform: scale(0.96);
}

.btn:active::after {
  background: rgba(255,255,255,0.08);
}

.btn-primary {
  background: var(--btn-gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,200,255,0.3), 0 0 0 1px rgba(0,200,255,0.2);
}

.btn-primary:hover {
  box-shadow: 0 6px 28px rgba(0,200,255,0.45), 0 0 0 1px rgba(0,200,255,0.3);
  transform: translateY(-1px);
}

.btn-green {
  background: var(--btn-gradient-green);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,229,160,0.3), 0 0 0 1px rgba(0,229,160,0.2);
}

.btn-green:hover {
  box-shadow: 0 6px 28px rgba(0,229,160,0.45), 0 0 0 1px rgba(0,229,160,0.3);
  transform: translateY(-1px);
}

.btn-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-icon svg { display: block; }

.popup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* ── LOADING ── */
.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--neon-cyan);
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ── EMPTY STATE ── */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
}

.empty-icon svg { display: block; }

.empty-text {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

/* ── SCROLL ── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.scroll-area::-webkit-scrollbar { display: none; }

/* ── FADE IN ANIMATION ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card, .list-card {
  animation: fadeInUp 0.3s ease both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.20s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.30s; }
.card:nth-child(n+7) { animation-delay: 0.35s; }

.list-card:nth-child(1) { animation-delay: 0.05s; }
.list-card:nth-child(2) { animation-delay: 0.10s; }
.list-card:nth-child(3) { animation-delay: 0.15s; }
.list-card:nth-child(4) { animation-delay: 0.20s; }
.list-card:nth-child(n+5) { animation-delay: 0.25s; }

/* ── BOTTOM SAFE AREA ── */
.safe-bottom { height: env(safe-area-inset-bottom, 16px); }

/* ── LANGUAGE SWITCHER ── */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 6px;
}

.lang-btn {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn.active {
  color: var(--neon-cyan);
  background: rgba(0,200,255,0.1);
}

.lang-btn:active { transform: scale(0.9); }

.lang-sep {
  color: var(--text-muted);
  font-size: 10px;
  opacity: 0.4;
}

/* ── DESKTOP PHONE CHROME ── */
@media (min-width: 480px) {
  body {
    background: #02040A;
    align-items: center;
    min-height: 100vh;
  }

  #app {
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: 0 0 80px rgba(0,200,255,0.08), 0 0 0 1px rgba(255,255,255,0.04);
  }
}
