/* Tunnel Hub – Apple Human Interface Guidelines look: system font, grouped inset lists, materials, system colors. */
:root {
  --bg: #f2f2f7; --bg2: #ffffff; --bg3: #f2f2f7; --fill: rgba(120,120,128,.12); --fill2: rgba(120,120,128,.2);
  --label: #000; --label2: rgba(60,60,67,.6); --label3: rgba(60,60,67,.3); --sep: rgba(60,60,67,.29);
  --blue: #007aff; --green: #34c759; --orange: #ff9500; --red: #ff3b30; --gray: #8e8e93;
  --material: rgba(249,249,249,.78); --shadow: 0 10px 40px rgba(0,0,0,.18);
  --r: 10px; --r-lg: 14px; --font: -apple-system, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --bg2: #1c1c1e; --bg3: #2c2c2e; --fill: rgba(118,118,128,.24); --fill2: rgba(118,118,128,.32);
    --label: #fff; --label2: rgba(235,235,245,.6); --label3: rgba(235,235,245,.3); --sep: rgba(84,84,88,.65);
    --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a; --gray: #8e8e93;
    --material: rgba(30,30,30,.72); --shadow: 0 10px 40px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--label); font: 17px/1.35 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
code, .mono { font-family: var(--mono); font-size: .88em; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--bg2); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 60%, transparent); outline-offset: 2px; }
.boot { display: grid; place-items: center; min-height: 80vh; color: var(--label2); }
.noscript { padding: 2rem; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- layout: sidebar on wide screens, tab bar on phones */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 12px; background: var(--material); border-right: .5px solid var(--sep);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; padding: 4px 10px 18px; }
.brand img { width: 30px; height: 30px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 9px; color: var(--label); text-decoration: none; font-size: 15px; }
.nav a svg { width: 22px; height: 22px; color: var(--blue); flex: none; }
.nav a[aria-current="page"] { background: var(--blue); color: #fff; }
.nav a[aria-current="page"] svg { color: #fff; }
.nav a:hover:not([aria-current="page"]) { background: var(--fill); }
.sidebar .foot { margin-top: auto; padding: 10px 12px; font-size: 13px; color: var(--label2); }
main { min-width: 0; padding: 0 0 60px; }
.content { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.tabbar { display: none; }
@media (max-width: 899px) {
  .shell { display: block; }
  .sidebar { display: none; }
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .content { padding: 0 16px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--material); border-top: .5px solid var(--sep);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px;
    font-size: 10px; font-weight: 500; color: var(--gray); text-decoration: none; }
  .tabbar a svg { width: 25px; height: 25px; }
  .tabbar a[aria-current="page"] { color: var(--blue); }
}

/* ---------------------------------------------------------------- navigation bar with a large title that collapses */
.navbar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 52px; padding: 0 16px;
  transition: background .2s, border-color .2s; border-bottom: .5px solid transparent; }
.navbar.stuck { background: var(--material); border-bottom-color: var(--sep); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.navbar .small { font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar.stuck .small { opacity: 1; }
.navbar .left { justify-self: start; } .navbar .right { justify-self: end; display: flex; gap: 4px; }
.large { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .37px; margin: 2px 0 12px; overflow-wrap: anywhere; }
.subtitle { color: var(--label2); margin: -8px 0 16px; font-size: 15px; }
@media (max-width: 380px) { .large { font-size: 28px; line-height: 34px; } }

/* ---------------------------------------------------------------- buttons */
.btn { appearance: none; border: 0; background: none; color: var(--blue); min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 10px; font-size: 17px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--fill); }
.btn:disabled { color: var(--label3); cursor: default; background: none; }
.btn svg { width: 22px; height: 22px; }
.btn.filled { background: var(--blue); color: #fff; font-weight: 600; padding: 0 20px; border-radius: 12px; }
.btn.filled:hover { filter: brightness(1.08); }
.btn.filled:disabled { background: var(--fill2); color: var(--label3); }
.btn.tinted { background: color-mix(in srgb, var(--blue) 15%, transparent); font-weight: 600; padding: 0 16px; border-radius: 12px; }
.btn.danger { color: var(--red); }
.btn.big { width: 100%; min-height: 50px; border-radius: 14px; }
.btn.bold { font-weight: 600; }

/* ---------------------------------------------------------------- grouped inset lists */
.section { margin: 0 0 30px; }
.section > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: -.08px; font-weight: 400; color: var(--label2); margin: 0 16px 7px; }
.section > .note { font-size: 13px; color: var(--label2); margin: 7px 16px 0; }
.group { background: var(--bg2); border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 16px; position: relative; color: var(--label); text-decoration: none; width: 100%; background: none; border: 0; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
.row.icon + .row.icon::before { left: 58px; }
a.row:hover, button.row:hover { background: var(--fill); cursor: pointer; }
a.row:active, button.row:active { background: var(--fill2); }
.row .grow { flex: 1; min-width: 0; }
.row .t { overflow-wrap: anywhere; }
.row .s { font-size: 13px; color: var(--label2); overflow-wrap: anywhere; }
.row .v { color: var(--label2); text-align: right; overflow-wrap: anywhere; max-width: 60%; }
.row .chev { width: 8px; height: 14px; color: var(--label3); flex: none; }
.row.destructive { color: var(--red); justify-content: center; }
.row.action { color: var(--blue); }
.tile { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.tile svg { width: 19px; height: 19px; }
.tile.blue { background: var(--blue); } .tile.green { background: var(--green); } .tile.orange { background: var(--orange); } .tile.purple { background: #af52de; } .tile.gray { background: var(--gray); } .tile.indigo { background: #5856d6; }

/* status dots */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--gray); vertical-align: 0; }
.dot.green { background: var(--green); } .dot.orange { background: var(--orange); } .dot.red { background: var(--red); }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--fill); color: var(--label2); white-space: nowrap; }
.badge.green { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.badge.orange { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.badge.red { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }

/* ---------------------------------------------------------------- forms */
.field { width: 100%; border: 0; background: transparent; padding: 0; min-height: 24px; outline: none; }
.row.input label { flex: none; min-width: 110px; }
.row.input .field { text-align: right; }
textarea.field { font-family: var(--mono); font-size: 14px; resize: vertical; min-height: 110px; text-align: left; padding: 12px 16px; display: block; }
.codebox { font-family: var(--mono); font-size: 13px; line-height: 1.45; word-break: break-all; padding: 14px 16px; user-select: all; background: var(--bg2); border-radius: var(--r); }
.fp { font-family: var(--mono); font-size: 15px; letter-spacing: .5px; }
.otp-input { font-family: var(--mono); font-size: 20px; letter-spacing: 1px; text-align: center; width: 100%; border: 0; background: var(--bg2); border-radius: 12px; padding: 14px; min-height: 52px; text-transform: uppercase; }
.err { color: var(--red); font-size: 15px; margin: 10px 16px 0; }
.err:empty { display: none; }

/* switch */
.switch { appearance: none; width: 51px; height: 31px; border-radius: 99px; background: var(--fill2); position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }

/* segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; margin: 0 0 16px; }
.segmented button { border: 0; background: none; min-height: 32px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; padding: 0 8px; }
.segmented button[aria-pressed="true"] { background: var(--bg2); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed="true"] { background: #636366; } }

/* kind chooser */
.kinds { display: grid; gap: 10px; }
.kind { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--bg2); border-radius: var(--r-lg); border: 2px solid transparent; cursor: pointer; text-align: left; min-height: 64px; }
.kind[aria-checked="true"] { border-color: var(--blue); }
.kind .tile { width: 40px; height: 40px; border-radius: 10px; } .kind .tile svg { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- sheets */
dialog.sheet { border: 0; padding: 0; background: var(--bg); color: var(--label); width: min(560px, 100vw); max-height: min(860px, 92vh); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
dialog.sheet::backdrop { background: rgba(0,0,0,.35); }
dialog.sheet[open] { animation: rise .32s cubic-bezier(.2,.9,.3,1); }
@media (max-width: 599px) { dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 12px 12px 0 0; max-height: 94vh; } }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 56px; padding: 0 8px; background: var(--material); border-bottom: .5px solid var(--sep);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 2; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.sheet-head .right { justify-self: end; }
.sheet-body { padding: 20px 16px 28px; overflow: auto; max-height: calc(min(860px, 92vh) - 56px); }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label3); margin: 6px auto 0; display: none; }
@media (max-width: 599px) { .grabber { display: block; } }
.steps { display: flex; gap: 6px; justify-content: center; margin: 0 0 20px; }
.steps span { width: 8px; height: 8px; border-radius: 50%; background: var(--fill2); }
.steps span.on { background: var(--blue); }
.lead { color: var(--label2); font-size: 15px; margin: 0 4px 18px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- empty states, welcome */
.empty { text-align: center; padding: 60px 20px; color: var(--label2); }
.empty svg { width: 64px; height: 64px; color: var(--label3); margin-bottom: 12px; }
.empty h3 { color: var(--label); font-size: 22px; margin: 0 0 6px; }
.welcome { max-width: 420px; margin: 0 auto; padding: 12vh 20px 40px; text-align: center; }
.welcome img { width: 84px; height: 84px; filter: drop-shadow(0 8px 20px rgba(0,122,255,.3)); }
.welcome h1 { font-size: 30px; margin: 20px 0 8px; }
.welcome p { color: var(--label2); margin: 0 0 26px; }
.welcome .group { text-align: left; margin-bottom: 18px; }
.check { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; margin: 10px auto 14px; }
.check svg { width: 34px; height: 34px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--fill2); border-top-color: var(--blue); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--material); color: var(--label);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--shadow); border-radius: 99px; padding: 12px 20px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { color: var(--red); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .switch, .dot { border: 1px solid CanvasText; } }
.row .t .badge { margin-left: 8px; vertical-align: 2px; }
