:root {
  --gold: #F0B429;
  --gold-deep: #E8820C;
  --bg-top: #141026;
  --bg-bottom: #05040F;
  --text: #FFFFFF;
  --muted: rgba(255, 255, 255, 0.62);
  --faint: rgba(255, 255, 255, 0.42);
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-stroke: rgba(255, 255, 255, 0.16);
  --radius: 24px;
  --danger: #FF6B6B;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  min-height: 100%;
  background: var(--bg-bottom);
  color: var(--text);
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden { display: none !important; }

/* ---------- Aurora background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, var(--bg-top), var(--bg-bottom));
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.55;
}
.b1 { width: 440px; height: 440px; background: #7A3FF2; top: -120px; left: -80px; animation: drift1 16s ease-in-out infinite alternate; }
.b2 { width: 380px; height: 380px; background: var(--gold); bottom: -100px; right: -60px; animation: drift2 18s ease-in-out infinite alternate; }
.b3 { width: 320px; height: 320px; background: #2E6BFF; top: 30%; right: 20%; animation: drift3 20s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(60px, 80px); } }
@keyframes drift2 { to { transform: translate(-60px, -50px); } }
@keyframes drift3 { to { transform: translate(-40px, 60px); } }

/* ---------- Glass surface ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid var(--glass-stroke);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* ---------- Screens ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Lock screen ---------- */
.lock-screen { align-items: center; justify-content: center; padding: 24px; }
.lock-card {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius);
  padding: 40px 30px 30px;
  text-align: center;
  animation: rise 0.5s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.brand-mark { width: 78px; height: 78px; margin: 0 auto 14px; filter: drop-shadow(0 8px 22px rgba(240, 135, 12, 0.4)); }
.brand-mark svg { width: 100%; height: 100%; }
.brand { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.lock-sub { color: var(--muted); margin-top: 6px; font-size: 15px; }

.pin-dots {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 30px 0 6px;
}
.pin-dots span {
  width: 42px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid var(--glass-stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.pin-dots span.filled { border-color: var(--gold); background: rgba(240, 180, 41, 0.12); }
.pin-dots span.active { transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.15); }
.pin-dots.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-9px); }
  40%, 80% { transform: translateX(9px); }
}
.pin-hidden { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pin-error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 12px; }

.text-btn {
  background: none; border: none; color: var(--faint);
  font-size: 13px; margin-top: 6px; cursor: pointer; padding: 6px;
}
.text-btn:hover { color: var(--muted); }

/* ---------- Top bar ---------- */
.app-screen { align-items: center; }
.topbar {
  width: 100%;
  max-width: 620px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.topbar-logo { width: 30px; height: 30px; }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer; font-size: 16px;
  border: 1px solid var(--glass-stroke);
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- App main ---------- */
.app-main {
  width: 100%;
  max-width: 620px;
  padding: 8px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.hero { text-align: center; padding: 10px 0 2px; }
.hero-icon { filter: drop-shadow(0 6px 20px rgba(240, 180, 41, 0.5)); margin-bottom: 8px; }
.tagline { color: var(--muted); font-size: 16px; max-width: 320px; margin: 0 auto; line-height: 1.4; }

.search { border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.search-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-stroke);
  border-radius: 18px;
  padding: 14px 16px;
}
.search-ic { color: var(--faint); flex: none; }
#query {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 17px; min-width: 0;
}
#query::placeholder { color: var(--faint); }
.clear-btn { background: none; border: none; color: var(--faint); font-size: 16px; cursor: pointer; }

/* ---------- CTA ---------- */
.cta {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 16px;
  font-size: 16px; font-weight: 700;
  color: #1A1206;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 10px 26px rgba(240, 180, 41, 0.34);
  transition: transform 0.15s, opacity 0.2s;
}
.cta:active { transform: scale(0.98); }
.cta:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.cta .spin { width: 18px; height: 18px; }

/* ---------- Output cards ---------- */
.card {
  border-radius: 20px; padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise 0.35s ease;
}
.card.status, .card.hint-card, .card.error { flex-direction: row; align-items: center; gap: 12px; }
.card .ic { flex: none; }
.card .msg { font-size: 15px; color: var(--text); }
.hint-card .msg { color: var(--muted); }
.error .ic { color: var(--danger); }
.badge { font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.result-title { font-size: 21px; font-weight: 800; }
.result-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; color: var(--gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-actions { display: flex; flex-direction: column; gap: 10px; }
.secondary-btn {
  border-radius: 14px; padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-stroke);
  color: rgba(255, 255, 255, 0.85);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.secondary-btn:active { transform: scale(0.98); }

/* ---------- Spinner ---------- */
.spinner, .spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}
.cta .spin { border-top-color: #1A1206; border-color: rgba(26,18,6,0.25); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 560px;
  border-radius: 28px 28px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 20px;
  max-height: 92dvh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(40px); } to { transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 20px; font-weight: 800; }

.field { display: flex; flex-direction: column; gap: 10px; }
.field label { font-size: 13px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.5px; }
.key-row { display: flex; gap: 8px; }
#apiKey {
  flex: 1; background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-stroke); border-radius: 14px;
  padding: 13px 14px; color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px;
  outline: none;
}
.mini-btn {
  width: 48px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-stroke);
  color: var(--text); font-size: 16px; cursor: pointer;
}
.hint { font-size: 13px; color: var(--faint); line-height: 1.4; }
.link { font-size: 13px; color: var(--gold); text-decoration: none; }
.link:hover { text-decoration: underline; }

.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-stroke);
  border-radius: 14px;
}
.segmented button {
  flex: 1; padding: 10px 8px; border: none; border-radius: 10px;
  background: none; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.segmented button.active { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #1A1206; }

.ghost-btn {
  padding: 13px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-stroke);
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.ghost-btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.ghost-btn:active { transform: scale(0.98); }

/* ---------- Player ---------- */
.player-modal { flex-direction: column; align-items: stretch; background: #000; backdrop-filter: none; }
.player-bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7), transparent);
}
.player-title { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-btn {
  padding: 9px 14px; border-radius: 999px;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #1A1206; font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.player-frame-wrap { position: relative; flex: 1; background: #000; }
.player-frame { width: 100%; height: 100%; border: 0; }
.player-loader { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.player-loader .spinner { width: 40px; height: 40px; }

/* ---------- Tabs ---------- */
.app-screen { align-items: center; }
.tab-view {
  width: 100%;
  max-width: 620px;
  padding: 8px 18px calc(110px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.hero-icon { font-size: 40px; line-height: 1; }

.panel { border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  padding: 9px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-stroke);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.chip:active { transform: scale(0.95); }
.chip.active { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #1A1206; border-color: rgba(255, 255, 255, 0.3); }

.suggestions-header {
  font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); padding-left: 4px; margin-bottom: -6px;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 420px;
  display: flex; gap: 6px; padding: 8px;
  border-radius: 26px;
  z-index: 40;
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 6px; border: none; border-radius: 18px;
  background: none; color: var(--faint); cursor: pointer;
  font-size: 11px; font-weight: 600;
  transition: color 0.2s, background 0.2s;
}
.tab-btn.active { color: var(--gold); background: rgba(240, 180, 41, 0.12); }
.tab-btn svg { display: block; }

/* ---------- Desktop refinements ---------- */
@media (min-width: 720px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 28px; }
  .tab-view { padding-top: 24px; }
}
