:root {
  color-scheme: dark;
  --bg: #0a0b10;
  --field: #16171f;
  --field-hover: #1b1c26;
  --hairline: rgba(255, 255, 255, 0.09);
  --text: #edeef3;
  --text-2: #9b9dab;
  --placeholder: #7e808e;
  --accent: #8c9cff;
  --accent-2: #68dcf0;
  --on-accent: #0a0b10;
  --danger: #ff8a80;
  --glass: rgba(22, 23, 31, 0.62);
  --glass-solid: #16171f;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI",
    system-ui, Roboto, "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --bar-h: calc(56px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

.iris {
  --size: 64px;
  --ring: calc(var(--size) * 0.2);
  position: relative;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  flex: none;
}
.iris::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 200deg, var(--accent), var(--accent-2), var(--accent) 60%, var(--accent));
  -webkit-mask: radial-gradient(circle closest-side, transparent calc(100% - var(--ring)), #000 calc(100% - var(--ring) + 0.5px));
          mask: radial-gradient(circle closest-side, transparent calc(100% - var(--ring)), #000 calc(100% - var(--ring) + 0.5px));
}
.iris::after {
  content: "";
  position: absolute;
  width: 16%;
  height: 16%;
  left: 42%;
  top: 42%;
  border-radius: 50%;
  background: #ebeeff;
}
.iris.glow {
  box-shadow: 0 0 calc(var(--size) * 0.9) calc(var(--size) * -0.15) rgba(140, 156, 255, 0.35);
}
.iris.spin::before { animation: spin 1.6s linear infinite; }
.iris.breathe { animation: breathe 5s var(--ease) infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.auth {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.auth-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise 0.5s var(--ease) both;
}
.auth h1 {
  margin: 28px 0 6px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
}
.auth .lede {
  margin: 0 0 32px;
  color: var(--text-2);
  font-size: 15px;
  text-align: center;
}

form { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
}
.field input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: var(--placeholder); }
.field input:hover { background: var(--field-hover); }
.field input:focus { outline: none; border-color: var(--accent); background: var(--field-hover); }
.field input:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(140, 156, 255, 0.28); }
.field input[aria-invalid="true"] { border-color: var(--danger); }

.code-input {
  text-align: center;
  font-size: 26px !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.45em;
  padding-left: calc(16px + 0.45em) !important;
  height: 60px !important;
}

.btn {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: 600 17px/1 var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.985); }
.btn[disabled] { cursor: default; filter: saturate(0.6) brightness(0.8); }
.btn .dot-spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(10, 11, 16, 0.3); border-top-color: var(--on-accent);
  animation: spin 0.7s linear infinite;
}

.btn-quiet {
  display: block;
  margin: 14px auto 0;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--text-2);
  font: 500 15px var(--font);
  cursor: pointer;
  border-radius: 10px;
}
.btn-quiet:hover { color: var(--text); }

.error {
  min-height: 22px;
  margin: 2px 2px 6px;
  color: var(--danger);
  font-size: 15px;
}

.hint {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 15px;
  text-align: center;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.shell {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}
.view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.view.on { opacity: 1; }

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  transition: opacity 0.35s var(--ease);
  z-index: 12;
}
.stage.gone { opacity: 0; pointer-events: none; }
.stage-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 320px;
}
.stage .iris { --size: 88px; }
.stage h2 {
  margin: 28px 0 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.stage p { margin: 0; color: var(--text-2); font-size: 15px; min-height: 22px; }
.stage .btn { width: auto; padding: 0 28px; margin-top: 24px; }

.scrim {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.handle {
  position: absolute;
  z-index: 5;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
          backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  opacity: 1;
  transition: opacity 0.4s var(--ease), transform 0.2s var(--ease);
}
.handle .iris { --size: 22px; }
.handle.dim { opacity: 0.38; }
.handle.dragging { cursor: grabbing; transform: scale(1.08); transition: opacity 0.4s var(--ease); }
.handle.snap { transition: left 0.28s var(--ease), top 0.28s var(--ease), opacity 0.4s var(--ease); }

.menu {
  position: absolute;
  z-index: 6;
  width: 248px;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
          backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  transform-origin: var(--origin, top right);
  animation: pop 0.18s var(--ease) both;
}
.menu-head {
  padding: 10px 12px 8px;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.menu-head .status {
  width: 8px; height: 8px; border-radius: 50%;
  background: #5ee0a0;
  flex: none;
}
.menu-head .status.warn { background: #ffc46b; }
.menu button {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font: 400 16px var(--font);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.menu button svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--hairline); margin: 4px 8px; }

.toast {
  position: absolute;
  z-index: 13;
  left: 50%;
  top: max(16px, env(safe-area-inset-top));
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px);
          backdrop-filter: blur(18px);
  font-size: 15px;
  white-space: nowrap;
  animation: pop 0.2s var(--ease) both;
}

.shell.phone .view {
  height: calc(100% - var(--bar-h));
}

.bar {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bar-h);
  padding: 6px max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
          backdrop-filter: blur(24px) saturate(1.6);
  border-top: 1px solid var(--hairline);
}
.bar-btn {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bar-btn:active { background: rgba(255, 255, 255, 0.1); }
.bar-btn[disabled] { color: var(--text-2); opacity: 0.45; }
.bar-btn svg, .pill svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.bar-btn .iris { --size: 22px; }
.tab-count {
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border: 2px solid currentColor;
  border-radius: 6px;
  font: 700 12px/18px var(--font);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pill {
  flex: 1;
  min-width: 0;
  height: 40px;
  margin: 0 4px;
  padding: 0 14px;
  border: 0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: 500 15px var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: text;
  -webkit-tap-highlight-color: transparent;
}
.pill svg { width: 14px; height: 14px; flex: none; color: var(--text-2); }
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.empty { color: var(--text-2); font-weight: 400; }
.pill:active { background: rgba(255, 255, 255, 0.16); }

.bar.addr {
  top: 0;
  bottom: auto;
  height: auto;
  z-index: 11;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  border-top: 0;
  border-bottom: 1px solid var(--hairline);
  gap: 8px;
}
.bar.addr input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: 17px var(--font);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.bar-text {
  flex: none;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font: 500 17px var(--font);
  cursor: pointer;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: rgba(0, 0, 0, 0.5);
  animation: fade 0.2s var(--ease) both;
}
.sheet {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72%;
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--hairline);
  background: var(--glass-solid);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  animation: sheet-in 0.28s var(--ease) both;
}
.sheet-grab {
  display: grid;
  place-items: center;
  height: 22px;
  touch-action: none;
  cursor: grab;
}
.sheet-grab span {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.28);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 6px 20px;
}
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.tab-list {
  list-style: none;
  margin: 0;
  padding: 0 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.tab-row {
  display: flex;
  align-items: center;
  border-radius: 14px;
}
.tab-row + .tab-row { margin-top: 2px; }
.tab-row.active { background: rgba(140, 156, 255, 0.14); }
.tab-open {
  flex: 1;
  min-width: 0;
  min-height: 60px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  border-radius: 14px;
}
.tab-title, .tab-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tab-title { font: 500 16px var(--font); }
.tab-host { font: 13px var(--font); color: var(--text-2); }
.tab-row.active .tab-title { color: var(--accent); }
.tab-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin-right: 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.tab-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.tab-close:active { background: rgba(255, 255, 255, 0.1); }
.sheet-foot { padding: 10px 16px 12px; }
.sheet-foot .btn { margin-top: 0; }

.up-sheet { z-index: 11; }
#up-backdrop { z-index: 10; }
.up-body {
  padding: 28px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.up-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(140, 156, 255, 0.16);
  color: var(--accent);
}
.up-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.up-body h2 { margin: 16px 0 6px; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; word-break: break-word; }
.up-text { margin: 0 0 16px; color: var(--text-2); font-size: 15px; }
.up-body .error { margin: 0 0 4px; }
.up-progress {
  width: 100%;
  height: 6px;
  margin: 0 0 14px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.up-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s linear;
}

@media (min-width: 600px) {
  .sheet {
    max-width: 440px;
    margin: 0 auto;
    bottom: 24px;
    border-radius: 20px;
    border: 1px solid var(--hairline);
  }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
.toast { animation-name: toast-in; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .handle, .menu, .toast, .bar {
    background: var(--glass-solid);
    -webkit-backdrop-filter: none;
            backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --hairline: rgba(255, 255, 255, 0.35);
    --text-2: #c4c6d2;
    --placeholder: #a9abb8;
  }
}
