:root {
  --bg: #0c0a14;
  --bg-2: #14111f;
  --panel: rgba(28, 23, 44, 0.72);
  --panel-solid: #1a1628;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #ece9f6;
  --muted: #9a93b3;
  --accent: #ff7a59;
  --accent-2: #e0457b;
  --accent-3: #7b5cff;
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  --good: #3ddc97;
  --warn: #ffc857;
  --bad: #ff5d6c;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  --display: "Space Grotesk", var(--font);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* Ambient background */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: .28; animation: drift 26s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { background: var(--accent); top: -25vmax; left: -15vmax; }
.aurora span:nth-child(2) { background: var(--accent-3); bottom: -30vmax; right: -20vmax; animation-delay: -8s; }
.aurora span:nth-child(3) { background: var(--accent-2); top: 30%; left: 40%; width: 35vmax; height: 35vmax; opacity: .16; animation-delay: -16s; }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.12); } }

#app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; }

/* ---------- Chrome ---------- */
.chrome {
  background: linear-gradient(to bottom, rgba(18, 15, 29, .92), rgba(18, 15, 29, .78));
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tabstrip { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px 0; min-width: 0; }
.brand { flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 4px; }
.brand img { width: 24px; height: 24px; filter: drop-shadow(0 0 8px rgba(255,122,89,.5)); }
.tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative; display: flex; align-items: center; gap: 8px;
  width: 220px; min-width: 120px; flex: 0 1 220px; height: 36px; padding: 0 8px 0 12px;
  border-radius: 11px 11px 0 0; border: 1px solid transparent; border-bottom: none;
  color: var(--muted); background: transparent; transition: background .15s, color .15s;
  user-select: none; animation: tabIn .22s ease-out;
}
@keyframes tabIn { from { opacity: 0; transform: translateY(6px); } }
.tab:hover { background: rgba(255,255,255,.04); color: var(--text); }
.tab.active { background: var(--bg-2); color: var(--text); border-color: var(--line); }
.tab.active::before { content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 2px; border-radius: 2px; background: var(--grad); }
.tab .fav { width: 16px; height: 16px; flex: none; border-radius: 4px; display: grid; place-items: center; overflow: hidden; }
.tab .fav img { width: 16px; height: 16px; }
.tab .fav.loading { border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tab .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.tab .close { flex: none; width: 22px; height: 22px; border: none; background: none; border-radius: 6px; display: grid; place-items: center; color: var(--muted); opacity: 0; }
.tab:hover .close, .tab.active .close { opacity: 1; }
.tab .close:hover { background: rgba(255,255,255,.1); color: var(--text); }
.tab .close svg { width: 13px; height: 13px; }

.icon-btn {
  flex: none; width: 34px; height: 34px; border-radius: 10px; border: none; background: transparent;
  display: grid; place-items: center; color: var(--muted); transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.add { margin-bottom: 2px; }

.toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 10px 8px; background: var(--bg-2); }
.omnibox {
  position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; margin: 0 6px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s, background .15s;
  overflow: hidden;
}
.omnibox:focus-within { border-color: rgba(255,122,89,.55); background: rgba(255,255,255,.07); box-shadow: 0 0 0 4px rgba(255,122,89,.12); }
.omnibox input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 14px; }
.omnibox input::placeholder { color: var(--muted); }
.lock { color: var(--good); display: grid; place-items: center; }
.lock svg { width: 15px; height: 15px; }
.lock.off { color: var(--muted); }
.progress { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--grad); opacity: 0; transition: width .4s ease, opacity .3s; }
.progress.on { opacity: 1; }

.server-chip {
  flex: none; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04);
  color: var(--muted); font-size: 12.5px; max-width: 210px;
}
.server-chip:hover { color: var(--text); border-color: var(--line-2); }
.server-chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.dot.good { background: var(--good); box-shadow: 0 0 10px var(--good); }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.dot.bad { background: var(--bad); box-shadow: 0 0 10px var(--bad); }

/* ---------- Viewport ---------- */
.viewport { position: relative; flex: 1; min-height: 0; background: var(--bg-2); }
.viewport > .pane { position: absolute; inset: 0; display: none; }
.viewport > .pane.active { display: block; }
.viewport iframe { width: 100%; height: 100%; border: none; background: #fff; }
.viewport .pane.blank iframe { display: none; }
.viewport .pane:not(.blank) .start { display: none; }

/* ---------- Start page ---------- */
.start {
  position: absolute; inset: 0; overflow: auto; display: flex; flex-direction: column; align-items: center;
  padding: 12vh 16px 40px; background: radial-gradient(ellipse at top, rgba(123,92,255,.12), transparent 60%), var(--bg-2);
}
.hero { text-align: center; margin-bottom: 28px; animation: rise .5s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.logo-mark { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 22px; display: grid; place-items: center; background: rgba(255,255,255,.03); border: 1px solid var(--line); box-shadow: 0 20px 60px -20px rgba(224,69,123,.6); }
.logo-mark img { width: 56px; height: 56px; }
.hero h1 { margin: 0; font: 700 clamp(40px, 7vw, 64px)/1 var(--display); letter-spacing: -0.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { margin: 10px 0 0; color: var(--muted); font-size: 15px; }

.start-search {
  width: min(640px, 100%); display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 18px;
  border-radius: 18px; background: var(--panel); border: 1px solid var(--line-2); backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8); transition: border-color .15s, box-shadow .15s; animation: rise .6s ease-out;
}
.start-search:focus-within { border-color: rgba(255,122,89,.6); box-shadow: 0 0 0 5px rgba(255,122,89,.12), 0 30px 80px -30px rgba(0,0,0,.8); }
.start-search svg { color: var(--muted); width: 20px; height: 20px; flex: none; }
.start-search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-size: 16px; }
.start-search kbd { font: 500 11px var(--font); color: var(--muted); border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 7px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; width: min(640px, 100%); margin-top: 34px; animation: rise .7s ease-out; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 8px 12px;
  border-radius: var(--radius); border: 1px solid var(--line); background: rgba(255,255,255,.03);
  color: var(--text); font-size: 12.5px; transition: transform .15s, background .15s, border-color .15s;
}
.tile:hover { transform: translateY(-3px); background: rgba(255,255,255,.06); border-color: var(--line-2); }
.tile .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font: 700 18px var(--display); color: #fff; }
.foot { margin-top: auto; padding-top: 40px; color: var(--muted); font-size: 12px; }
.foot b { color: var(--text); font-weight: 600; }

/* ---------- Settings drawer ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(5,4,10,.5); backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; z-index: 21; top: 10px; right: 10px; bottom: 10px; width: min(400px, calc(100vw - 20px));
  overflow: auto; padding: 18px 20px 24px; border-radius: 20px; background: rgba(22, 18, 35, .94);
  border: 1px solid var(--line-2); backdrop-filter: blur(20px); box-shadow: 0 40px 100px -20px rgba(0,0,0,.9);
  animation: slide .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer h2 { margin: 0; font: 700 22px var(--display); }
.drawer h3 { margin: 22px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }

.server-list { display: flex; flex-direction: column; gap: 6px; }
.server {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; text-align: left;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); transition: border-color .15s, background .15s;
}
.server:hover { background: rgba(255,255,255,.06); }
.server.selected { border-color: rgba(255,122,89,.6); background: rgba(255,122,89,.08); }
.server .meta { flex: 1; min-width: 0; }
.server .name { font-weight: 600; }
.server .url { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server .ms { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.server .rm { border: none; background: none; color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.server .rm:hover { color: var(--bad); }

.custom-server { display: flex; gap: 8px; margin-top: 10px; }
.custom-server input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(255,255,255,.04); outline: none; }
.custom-server input:focus { border-color: rgba(255,122,89,.6); }
.btn { height: 38px; padding: 0 16px; border-radius: 10px; border: none; background: var(--grad); color: #fff; font-weight: 600; }
.btn.ghost { margin-top: 10px; width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.btn.ghost:hover { background: rgba(255,255,255,.09); }

.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.seg button { flex: 1; min-width: 80px; height: 32px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-solid); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.4), inset 0 0 0 1px var(--line-2); }

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 10px 16px;
  border-radius: 12px; background: rgba(22,18,35,.95); border: 1px solid var(--line-2); font-size: 13px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.8); animation: rise .25s ease-out; max-width: calc(100vw - 32px);
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  #forward, #home { display: none; }
  .server-chip span:last-child { display: none; }
  .server-chip { padding: 0 11px; }
  .tab { width: 150px; flex-basis: 150px; }
  .omnibox { margin: 0 2px; }
}
