:root {
  --blue: #3574bb;
  --blue-dark: #2865a8;
  --blue-soft: #5b85ab;
  --gray-50: #f7f8fa;
  --gray-100: #eef1f4;
  --gray-300: #c8c7cb;
  --gray-500: #858585;
  --gray-800: #292d32;
  --danger-soft: #fff7e8;
  --danger: #9a6200;
  --shadow: 0 12px 36px rgb(25 42 70 / 12%);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Arial, sans-serif;
  color: var(--gray-800);
  background: var(--gray-100);
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: linear-gradient(145deg, #eef3f8, #f8fafc);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

.phone-shell {
  position: relative;
  width: min(100%, 760px);
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  margin-inline: auto;
  overflow: hidden;
  background: #fff;
}

.onboarding { display: flex; flex-direction: column; }
.slides { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: pan-y; outline: none; cursor: grab; }
.slides:active { cursor: grabbing; }
.slide-track { position: absolute; inset: 0; display: flex; transition: transform 360ms cubic-bezier(.2,.8,.2,1); }
.slide { position: relative; flex: 0 0 100%; min-width: 0; min-height: 0; padding: 4px 10px; }
.slide img { position: absolute; inset: 4px 10px; display: block; width: calc(100% - 20px); height: calc(100% - 8px); object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }

.demo-badge {
  position: absolute;
  z-index: 3;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  padding: 6px 9px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  color: var(--blue);
  background: rgb(255 255 255 / 86%);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

.dots { display: flex; justify-content: center; gap: 8px; padding: 12px; }
.dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--gray-300);
  cursor: pointer;
  transition: width 220ms ease, background 220ms ease;
}
.dot.active { width: 20px; background: var(--blue); }

.onboarding-actions {
  display: grid;
  gap: 8px;
  width: min(100%, 340px);
  margin-inline: auto;
  padding: 18px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.primary-button, .secondary-button {
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 15px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  white-space: normal;
  transition: transform 120ms ease, background 160ms ease, opacity 160ms ease;
}

.primary-button { border: 0; color: #fff; background: var(--blue); box-shadow: 0 7px 18px rgb(53 116 187 / 24%); }
.primary-button:hover { background: var(--blue-dark); }
.primary-button:active, .secondary-button:active { transform: scale(.985); }
.primary-button:focus-visible, .secondary-button:focus-visible, .tab:focus-visible,
.legal-row:focus-visible, .icon-button:focus-visible, .dot:focus-visible, input:focus-visible {
  outline: 3px solid rgb(53 116 187 / 28%);
  outline-offset: 2px;
}
.primary-button:disabled { color: #aaa; background: #ddd; cursor: not-allowed; }
.secondary-button { border: 1px solid var(--blue); color: var(--blue); background: #fff; }
.text-link { min-height: 44px; padding: 12px 8px; color: var(--blue-soft); text-align: center; text-decoration: none; }

.page-shell { display: flex; flex-direction: column; min-height: 0; }
.page-shell > * { min-width: 0; }
.app-bar {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  color: #fff;
  background: var(--blue);
}
.app-bar h1 { margin: 0; overflow: hidden; font-size: clamp(18px, 4.8vw, 22px); font-weight: 700; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 6px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgb(255 255 255 / 10%);
  text-decoration: none;
  cursor: pointer;
}
.icon-button:active { background: rgb(255 255 255 / 22%); }
.icon-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.info-button svg { width: 23px; height: 23px; }
.page-content { flex: 1; min-height: 0; overflow-y: auto; padding: 20px max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; }
.intro-copy { margin: 6px 0 28px; font-size: 12px; text-align: center; }
.legal-card { margin: 0 4px; overflow: hidden; border: 1px solid #e9edf2; border-radius: var(--radius-md); background: #fff; box-shadow: 0 8px 22px rgb(0 0 0 / 10%); }
.legal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 8px 16px;
  border: 0;
  border-bottom: 1px solid #eee;
  color: #aaa;
  background: #fff;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.legal-row:last-child { border-bottom: 0; }
.legal-continue { width: min(100%, 320px); margin: clamp(28px, 8vh, 48px) auto 10px; display: block; }
.check-row { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; color: var(--blue); line-height: 1.45; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin: 1px 0; accent-color: var(--blue); }
.prototype-note { margin-top: 48px; color: var(--gray-500); font-size: 12px; text-align: center; }

.info-dialog { width: min(calc(100% - 32px), 420px); max-height: calc(100dvh - 40px); overflow-y: auto; border: 0; border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.info-dialog::backdrop { background: rgb(23 35 51 / 52%); }
.info-dialog h2 { margin-top: 0; }
.info-dialog p { color: var(--gray-500); line-height: 1.6; }
.info-dialog .primary-button { margin-top: 12px; }

.search-bar { grid-template-columns: 56px minmax(0, 1fr) 52px 52px; }
.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
}
.search-wrap input::placeholder { color: #fff; opacity: 1; }
.search-wrap input::-webkit-search-cancel-button { filter: brightness(0) invert(1); }
.network-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background: var(--gray-50); -webkit-overflow-scrolling: touch; }
.network-item {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 10px 14px;
  border-bottom: 1px solid #edf0f3;
  color: #111;
  background: #fff;
  text-decoration: none;
}
.network-item:first-child { margin-bottom: 10px; border: 0; border-radius: var(--radius-md); box-shadow: 0 4px 14px rgb(0 0 0 / 6%); }
.network-item:nth-child(2) { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.network-item:last-child { border-bottom: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.network-item:hover { background: var(--gray-50); }
.network-item img { width: 40px; height: 40px; object-fit: contain; }
.network-item span { font-size: 14px; font-weight: 700; }
.empty-state { margin: auto; color: var(--gray-500); }

.safety-banner {
  display: grid;
  gap: 4px;
  margin: 12px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  padding: 12px 14px;
  border: 1px solid #f0d697;
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
  line-height: 1.4;
}
.safety-banner span { overflow-wrap: anywhere; }
.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;

  margin:
    16px
    max(12px, env(safe-area-inset-right))
    2px
    max(12px, env(safe-area-inset-left));

  padding: 3px;
  border-radius: var(--radius-sm);
  background: #edf0f4;
}.tab { min-width: 0; min-height: 40px; padding: 7px 3px; border: 0; border-radius: 9px; color: var(--gray-500); background: transparent; font-size: 12px; cursor: pointer; }
.tab.active { color: var(--blue); background: #fff; box-shadow: 0 2px 7px rgb(0 0 0 / 13%); font-weight: 700; }
.tab-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 18px max(14px, env(safe-area-inset-right)) max(26px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; }
.safe-panel { display: grid; align-content: center; justify-items: center; min-height: 100%; text-align: center; }
.safe-panel[hidden], .tab-panel[hidden] { display: none; }
.safe-panel h2 { margin: 8px 0; font-size: 20px; }
.safe-panel p { max-width: 430px; margin: 0 0 26px; color: var(--gray-500); line-height: 1.55; }
.safe-panel .secondary-button { max-width: 300px; }
.locked-icon { font-size: 42px; }
.visual-form { display: grid; min-width: 0; gap: 18px; }
.paste-badge { position: absolute; top: 16px; right: 13px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.import-form { display: grid; min-width: 0; gap: 18px; }
.field { display: grid; width: 100%; min-width: 0; gap: 6px; color: var(--blue); font-size: 12px; }
.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 14px 12px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  color: #182230;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
  box-shadow: 0 1px 0 rgb(255 255 255 / 80%) inset, 0 3px 12px rgb(31 72 118 / 6%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
  caret-color: var(--blue);
  appearance: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.field input::placeholder,
.field textarea::placeholder { color: #9aa4b1; font-weight: 400; opacity: 1; }
.field input:focus,
.field textarea:focus { border-color: var(--blue); outline: none; background: #fff; box-shadow: 0 0 0 4px rgb(53 116 187 / 13%), 0 7px 20px rgb(31 72 118 / 10%); }
.field input[type="password"] { letter-spacing: .08em; }
.field textarea { min-height: 108px; resize: vertical; line-height: 1.45; }
.sensitive-field { position: relative; }
.sensitive-field input,
.sensitive-field textarea { padding-right: 72px; }
.sensitive-field .paste-badge { top: 36px; right: 13px; pointer-events: none; }
.field input.invalid { border-color: #c0362c; }
.field-error { min-height: 14px; color: #c0362c; }
.helper-copy { margin: 0; color: var(--gray-500); font-size: 13px; line-height: 1.5; }
.question-link { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; justify-self: center; padding: 10px 14px; border: 0; border-radius: 12px; color: var(--blue); background: transparent; cursor: pointer; text-decoration: none; }

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  color: #fff;
  background: #273443;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: 200ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.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; }

@media (min-width: 900px) and (min-height: 700px) {
  body { padding-block: 24px; }
  .phone-shell { height: calc(100dvh - 48px); border-radius: 24px; box-shadow: var(--shadow); }
}

@media (max-height: 650px) {
  .onboarding-actions { padding-top: 8px; }
  .dots { padding-block: 6px; }
}

@media (max-width: 359px) {
  .app-bar { grid-template-columns: 50px 1fr 50px; }
  .search-bar { grid-template-columns: 50px minmax(0, 1fr) 46px 46px; }
  .icon-button { width: 42px; height: 42px; margin: 4px; }
  .safety-banner { padding: 10px 11px; font-size: 11px; }
  .tabs { margin-inline: 8px; }
  .tab { font-size: 10.5px; }
  .tab-panel { padding-inline: 10px; }
  .import-form { gap: 14px; }
  .network-item { min-height: 64px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .onboarding {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(270px, 42%);
    grid-template-rows: 1fr auto;
  }
  .slides { grid-column: 1; grid-row: 1 / 3; }
  .dots { grid-column: 2; grid-row: 1; align-self: end; padding-block: 6px; }
  .onboarding-actions { grid-column: 2; grid-row: 2; width: 100%; padding: 8px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) 16px; }
  .app-bar { min-height: calc(50px + env(safe-area-inset-top)); }
  .safety-banner { margin-block: 7px; padding-block: 8px; }
  .tabs { flex: 0 0 auto; }
  .tab-panel { padding-top: 10px; }
  .import-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
  .import-form .helper-copy, .import-form .primary-button, .import-form .question-link { grid-column: 1 / -1; }
  .visual-form { gap: 12px; }
  .field textarea { min-height: 84px; }
  .safe-panel { min-height: 230px; }
  .legal-continue { margin-top: 22px; }
  .prototype-note { margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
