/* ============================================================
   Aurora VPN — dark "polar night" theme
   ============================================================ */
:root {
  --bg: #07090f;
  --bg-2: #0a0e18;
  --ink: #ecf1f8;
  --muted: #8b95ab;
  --faint: #5b647a;
  --line: rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.055);
  --panel: rgba(255, 255, 255, 0.034);
  --panel-2: rgba(255, 255, 255, 0.05);

  --teal: #45e8c7;
  --cyan: #34c6ff;
  --violet: #9a86ff;
  --mag: #ff6fd8;
  --danger: #ff6b6b;

  --grad: linear-gradient(110deg, var(--teal), var(--cyan) 55%, var(--violet));
  --glow: 0 0 0 1px rgba(69, 232, 199, 0.35), 0 18px 50px -18px rgba(52, 198, 255, 0.55);

  --r-lg: 22px;
  --r-md: 15px;
  --r-sm: 11px;

  --display: 'Clash Display', 'Satoshi', system-ui, sans-serif;
  --body: 'Satoshi', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
.hidden { display: none !important; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
code, pre { font-family: var(--mono); }

/* ---------------- atmosphere ---------------- */
.aurora {
  position: fixed; inset: -20vh -10vw; z-index: -3;
  filter: blur(58px) saturate(135%);
  pointer-events: none;
}
.band {
  position: absolute; border-radius: 50%;
  mix-blend-mode: screen; opacity: 0.6;
  will-change: transform;
}
.band-1 {
  width: 70vw; height: 55vh; top: -12vh; left: -6vw;
  background: radial-gradient(closest-side, rgba(69, 232, 199, 0.85), transparent 72%);
  animation: drift1 24s ease-in-out infinite;
}
.band-2 {
  width: 62vw; height: 52vh; top: -16vh; right: -8vw; left: auto;
  background: radial-gradient(closest-side, rgba(52, 150, 255, 0.8), transparent 72%);
  animation: drift2 30s ease-in-out infinite;
}
.band-3 {
  width: 54vw; height: 48vh; top: -2vh; left: 22vw;
  background: radial-gradient(closest-side, rgba(154, 134, 255, 0.7), transparent 70%);
  animation: drift3 34s ease-in-out infinite;
}
.glowdot {
  position: absolute; bottom: -24vh; left: 35vw;
  width: 40vw; height: 40vh; border-radius: 50%; mix-blend-mode: screen;
  background: radial-gradient(closest-side, rgba(255, 111, 216, 0.35), transparent 70%);
  animation: drift2 40s ease-in-out infinite reverse;
}
@keyframes drift1 { 50% { transform: translate(8vw, 6vh) scale(1.12); } }
@keyframes drift2 { 50% { transform: translate(-7vw, 8vh) scale(1.1); } }
@keyframes drift3 { 50% { transform: translate(4vw, -5vh) scale(0.92); } }

.grain {
  position: fixed; inset: 0; z-index: -2; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% -10%, transparent 40%, rgba(3, 5, 9, 0.55) 100%);
}

/* ---------------- reveal animation ---------------- */
.reveal { animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.99); } }
@media (prefers-reduced-motion: reduce) {
  .reveal, .band, .glowdot { animation: none !important; }
}

/* ============================================================
   AUTH
   ============================================================ */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 20px; gap: 18px;
}
.auth-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 38px 32px 30px;
  backdrop-filter: blur(22px) saturate(120%);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative; overflow: hidden;
}
.auth-card::before {
  content: ''; position: absolute; inset: 0; padding: 1px; border-radius: inherit;
  background: linear-gradient(150deg, rgba(69, 232, 199, 0.5), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.auth-logo img { width: 168px; height: auto; display: block; }
.auth-kicker {
  margin: 14px 0 24px; color: var(--muted); font-size: 13px;
  letter-spacing: 0.14em; text-transform: uppercase;
}

/* segmented control */
.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 4px; margin-bottom: 22px;
}
.seg-btn {
  position: relative; z-index: 2; background: none; border: 0; color: var(--muted);
  font-weight: 600; font-size: 14px; padding: 9px 0; border-radius: 8px;
  transition: color 0.25s;
}
.seg-btn.is-active { color: #05221c; }
.seg-pill {
  position: absolute; z-index: 1; top: 4px; left: 4px; bottom: 4px; width: calc(50% - 4px);
  background: var(--grad); border-radius: 8px; transition: transform 0.32s cubic-bezier(0.4, 1.2, 0.4, 1);
  box-shadow: 0 6px 18px -6px rgba(52, 198, 255, 0.7);
}
.seg[data-tab='register'] .seg-pill { transform: translateX(100%); }

/* fields */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 7px 2px; font-weight: 500; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 15px; color: var(--ink);
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line);
  border-radius: var(--r-sm); outline: none; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
  border-color: rgba(69, 232, 199, 0.6);
  box-shadow: 0 0 0 4px rgba(69, 232, 199, 0.12);
  background: rgba(0, 0, 0, 0.2);
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid transparent; border-radius: var(--r-sm); padding: 12px 18px;
  font-size: 14.5px; font-weight: 600; color: var(--ink); background: var(--panel-2);
  transition: transform 0.12s, box-shadow 0.25s, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-primary {
  color: #04231d; background: var(--grad); background-size: 160% 160%;
  box-shadow: 0 10px 30px -10px rgba(52, 198, 255, 0.6);
  animation: shimmer 7s ease infinite;
}
.btn-primary:hover { box-shadow: 0 14px 36px -10px rgba(69, 232, 199, 0.7); transform: translateY(-1px); }
@keyframes shimmer { 50% { background-position: 100% 50%; } }
.btn-ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
.btn-danger { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.28); color: #ff8f8f; }
.btn-danger:hover { background: rgba(255, 107, 107, 0.18); }
.btn-spin { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-dasharray: 42; stroke-dashoffset: 12; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading .btn-label { opacity: 0.55; }

.form-msg { min-height: 18px; margin: 12px 2px 0; font-size: 13px; color: var(--danger); }
.form-msg.ok { color: var(--teal); }
.auth-foot { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.link { background: none; border: 0; color: var(--teal); font-weight: 600; font-size: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.auth-legal { color: var(--faint); font-size: 12px; text-align: center; max-width: 380px; margin: 0 auto; }

/* ============================================================
   APP
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(18px, 5vw, 56px);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(7, 9, 15, 0.82), rgba(7, 9, 15, 0.4));
  backdrop-filter: blur(16px);
}
.topbar-logo { height: 22px; width: auto; opacity: 0.95; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.who b { color: var(--ink); font-weight: 600; }
.who-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); }

.wrap { max-width: 1080px; margin: 0 auto; padding: clamp(34px, 6vw, 72px) clamp(18px, 5vw, 56px) 40px; }
.hero { margin-bottom: 40px; }
.hero h1 {
  font-family: var(--display); font-weight: 600; font-size: clamp(32px, 6vw, 52px);
  line-height: 1.02; letter-spacing: -0.02em; margin: 0 0 14px;
}
.lede { color: var(--muted); font-size: 16px; line-height: 1.6; max-width: 560px; margin: 0 0 26px; }
.lede code { background: rgba(255, 255, 255, 0.07); padding: 1px 7px; border-radius: 6px; font-size: 0.85em; color: var(--teal); }
.lede b { color: var(--ink); }
.hero-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.count { color: var(--faint); font-size: 13.5px; }

/* apps download strip */
.apps {
  display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap;
  margin: 0 0 38px; padding: 14px 18px;
  border: 1px solid var(--line-soft); border-radius: var(--r-md); background: var(--panel);
}
.apps-label { color: var(--muted); font-size: 13.5px; }
.apps-row { display: flex; gap: 10px; flex-wrap: wrap; }
.appbtn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px;
  border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-soft);
  color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: transform 0.16s, border-color 0.2s, background 0.2s;
}
.appbtn:hover { border-color: rgba(69, 232, 199, 0.45); background: rgba(255, 255, 255, 0.07); transform: translateY(-1px); }
.appbtn .pico { width: 17px; height: 17px; color: var(--teal); }

/* small text-style danger button (de-emphasized delete) */
.btn-textdanger {
  display: block; margin: 12px auto 0; padding: 6px 12px; background: none; border: 0;
  color: var(--faint); font-size: 13px; font-weight: 500; font-family: inherit;
  border-radius: 8px; transition: color 0.18s, background 0.18s;
}
.btn-textdanger:hover { color: #ff8f8f; background: rgba(255, 107, 107, 0.08); }

/* QR image + actions */
.qrimg { width: 196px; height: 196px; display: block; image-rendering: pixelated; }
.qr-actions { display: flex; gap: 8px; }
.qr-actions .btn { flex: 1; }

/* config grid */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
}
.card {
  position: relative; padding: 20px; border-radius: var(--r-md);
  background: var(--panel); border: 1px solid var(--line-soft);
  cursor: pointer; overflow: hidden;
  transition: transform 0.18s, border-color 0.2s, background 0.2s, box-shadow 0.25s;
  animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.card:hover {
  transform: translateY(-3px); background: var(--panel-2);
  border-color: rgba(69, 232, 199, 0.35);
  box-shadow: 0 24px 50px -28px rgba(52, 198, 255, 0.5);
}
.card::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px;
  background: radial-gradient(closest-side, rgba(69, 232, 199, 0.16), transparent 70%);
  opacity: 0; transition: opacity 0.3s;
}
.card:hover::after { opacity: 1; }
.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-glyph {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: rgba(69, 232, 199, 0.1); border: 1px solid rgba(69, 232, 199, 0.25);
}
.card-glyph svg { width: 20px; height: 20px; fill: none; stroke: var(--teal); stroke-width: 1.8; }
.card-name { font-family: var(--display); font-weight: 500; font-size: 18px; letter-spacing: -0.01em; }
.card-sub { color: var(--faint); font-size: 12px; margin-top: 2px; font-family: var(--mono); }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.card-addr { font-family: var(--mono); font-size: 12.5px; color: var(--cyan); }
.card-open { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }
.card-open svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.card.is-new { box-shadow: var(--glow); }

/* empty state */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-ring {
  width: 78px; height: 78px; margin: 0 auto 22px; border-radius: 50%;
  border: 2px dashed rgba(69, 232, 199, 0.4);
  background: radial-gradient(closest-side, rgba(69, 232, 199, 0.1), transparent);
  animation: spin 18s linear infinite;
}
.empty h3 { font-family: var(--display); font-weight: 600; color: var(--ink); margin: 0 0 8px; font-size: 22px; }
.empty p { margin: 0; font-size: 14.5px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 22px; }
.modal-back { position: absolute; inset: 0; background: rgba(4, 6, 11, 0.74); backdrop-filter: blur(8px); animation: fade 0.3s both; }
@keyframes fade { from { opacity: 0; } }
.modal-card, .dialog-card {
  position: relative; z-index: 2; width: min(760px, 100%);
  background: linear-gradient(180deg, rgba(20, 26, 38, 0.96), rgba(11, 15, 24, 0.97));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 60px 120px -50px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.dialog-card { width: min(440px, 100%); padding: 30px; }
.modal-x {
  position: absolute; top: 16px; right: 16px; z-index: 3; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--muted);
  display: grid; place-items: center; transition: 0.2s;
}
.modal-x:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.25); }
.modal-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.modal-grid { display: grid; grid-template-columns: 0.85fr 1fr; }

.qr-stage {
  padding: 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  border-right: 1px solid var(--line-soft);
  background: radial-gradient(120% 90% at 50% 0%, rgba(69, 232, 199, 0.08), transparent 60%);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}
.qr-frame {
  background: #fff; padding: 14px; border-radius: 16px; line-height: 0;
  box-shadow: 0 20px 50px -18px rgba(69, 232, 199, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.qr-frame svg, .qr-frame img { width: 196px; height: 196px; display: block; }
.qr-hint { text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
.qr-hint b { color: var(--ink); }

.modal-side { padding: 30px; min-width: 0; }
.modal-kicker { color: var(--teal); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; margin: 0 0 8px; font-weight: 600; }
.modal-side h2, .dialog-card h2 { font-family: var(--display); font-weight: 600; font-size: 26px; letter-spacing: -0.02em; margin: 0 0 14px; word-break: break-word; }
.modal-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.chip { font-family: var(--mono); font-size: 12px; color: var(--cyan); background: rgba(52, 198, 255, 0.1); border: 1px solid rgba(52, 198, 255, 0.22); padding: 4px 10px; border-radius: 999px; }
.chip.ghost { color: var(--muted); background: rgba(255, 255, 255, 0.04); border-color: var(--line-soft); }
.conf-box { position: relative; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: rgba(0, 0, 0, 0.34); margin-bottom: 18px; }
.conf { margin: 0; padding: 14px; max-height: 190px; overflow: auto; font-size: 11.5px; line-height: 1.7; color: #b9c6da; white-space: pre; }
.conf::-webkit-scrollbar { width: 8px; height: 8px; }
.conf::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 auto; }

/* dialog */
.dialog-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.dialog-sub i { color: var(--cyan); font-style: normal; font-family: var(--mono); font-size: 0.9em; }
#newForm input {
  width: 100%; padding: 14px 16px; font-size: 16px; color: var(--ink); font-family: var(--mono);
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: var(--r-sm);
  outline: none; margin-bottom: 18px; transition: border-color 0.2s, box-shadow 0.2s;
}
#newForm input:focus { border-color: rgba(69, 232, 199, 0.6); box-shadow: 0 0 0 4px rgba(69, 232, 199, 0.12); }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  background: rgba(16, 21, 32, 0.96); border: 1px solid var(--line);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9); backdrop-filter: blur(12px);
  animation: toast 0.35s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
@keyframes toast { from { opacity: 0; transform: translateY(14px); } }
.toast.out { animation: toastout 0.3s ease forwards; }
@keyframes toastout { to { opacity: 0; transform: translateY(10px); } }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.toast.ok .dot { background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.toast.err .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

/* ============================================================
   responsive
   ============================================================ */
.modal-card { max-height: 92dvh; overflow: auto; }

@media (max-width: 640px) {
  .modal { padding: 12px; }
  .modal-grid { grid-template-columns: 1fr; }
  .qr-stage { border-right: 0; border-bottom: 1px solid var(--line-soft); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 26px 24px; }
  .modal-side { padding: 24px; }
  .modal-actions .btn { flex: 1 1 100%; }
  .topbar { padding: 14px 18px; }
  .topbar-logo { height: 17px; }
  .wrap { padding-top: 28px; }
  .hero { margin-bottom: 28px; }
  .apps { width: 100%; }
  .apps-label { flex: 1 1 100%; }
  .apps-row { width: 100%; }
  .appbtn { flex: 1 1 calc(50% - 5px); justify-content: center; }
  .who .who-dot { display: none; }
}
