:root {
  --bg: #f2f4f8;
  --bg-soft: #e8ecf3;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --accent-press: #0066d6;
  --ok: #34c759;
  --ok-soft: rgba(52, 199, 89, 0.14);
  --err: #ff3b30;
  --err-soft: rgba(255, 59, 48, 0.12);
  --warn: #ff9f0a;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, "Menlo", "Consolas", monospace;
  --spring: cubic-bezier(0.22, 1.1, 0.36, 1);
  --spring-soft: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 15% 0%, rgba(0, 122, 255, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 40% at 90% 10%, rgba(90, 200, 250, 0.18), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(175, 82, 222, 0.08), transparent 55%),
    linear-gradient(180deg, #f7f8fb 0%, var(--bg) 40%, var(--bg-soft) 100%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100% - 2rem, 440px);
  margin: 0 auto;
  padding: max(2.5rem, env(safe-area-inset-top)) 0 3.5rem;
}

.shell.enter {
  animation: rise-in 0.7s var(--spring) both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.35rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, #5ac8fa 0%, #007aff 55%, #5856d6 100%);
  box-shadow:
    0 10px 24px rgba(0, 122, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom-width: 0;
  border-left-width: 0;
  transform: rotate(45deg) translate(-1px, 1px);
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.lead {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Segmented control */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 4px;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.seg-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 11px;
  background: var(--surface-solid);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08), 0 1px 1px rgba(15, 23, 42, 0.04);
  transition: transform 0.45s var(--spring);
  z-index: 0;
  pointer-events: none;
}

.seg-pill.to-about { transform: translateX(100%); }

.seg-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.62rem 0.5rem;
  border-radius: 11px;
  cursor: pointer;
  transition: color 0.25s var(--ease-out);
}

.seg-btn.active { color: var(--text); }

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(1.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
  padding: 1.2rem 1.15rem 1.25rem;
}

.tab-panel {
  display: none;
  animation: panel-in 0.45s var(--spring) both;
}

.tab-panel.active { display: block; }

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stack { display: flex; flex-direction: column; gap: 1.05rem; }

.field { display: flex; flex-direction: column; gap: 0.45rem; }

label,
.label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  text-transform: uppercase;
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font: inherit;
  font-size: 0.98rem;
  padding: 0.85rem 0.95rem;
  transition:
    border-color 0.25s var(--ease-out),
    box-shadow 0.25s var(--ease-out),
    transform 0.25s var(--spring-soft);
}

textarea {
  resize: vertical;
  min-height: 150px;
  font-family: var(--mono);
  line-height: 1.5;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: rgba(0, 122, 255, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.chips {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 0.9fr;
  gap: 0.4rem;
}

.chip {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.62rem 0.35rem;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 0.3s var(--spring-soft),
    color 0.25s ease,
    transform 0.25s var(--spring),
    box-shadow 0.3s var(--spring-soft),
    border-color 0.25s ease;
}

.chip:active { transform: scale(0.96); }

.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(0, 122, 255, 0.18);
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 1.1rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.28s var(--spring),
    background 0.25s ease,
    box-shadow 0.28s var(--spring-soft),
    opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-press:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #1a86ff 0%, var(--accent) 100%);
  color: #fff;
  box-shadow:
    0 10px 28px rgba(0, 122, 255, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #2b90ff 0%, var(--accent-press) 100%);
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
  width: auto;
  min-width: 108px;
  padding-inline: 1rem;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  min-height: 40px;
  margin-top: 0.35rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.loading .btn-label { opacity: 0; }
.btn.loading .btn-spinner {
  opacity: 1;
  animation: spin 0.7s linear infinite;
}

.btn-spinner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  opacity: 0;
}

.btn-primary { position: relative; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.sheet {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  animation: sheet-pop 0.55s var(--spring) both;
  text-align: center;
}

@keyframes sheet-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sheet-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 0.7rem;
  border-radius: 50%;
  position: relative;
}

.ok-icon {
  background: var(--ok-soft);
  animation: pop-icon 0.55s var(--spring) both;
}

.ok-icon::after {
  content: "";
  position: absolute;
  left: 15px;
  top: 12px;
  width: 10px;
  height: 16px;
  border: 2.5px solid var(--ok);
  border-top: 0;
  border-left: 0;
  transform: rotate(40deg);
}

.err-icon {
  background: var(--err-soft);
}

.err-icon::before,
.err-icon::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 12px;
  width: 2.5px;
  height: 20px;
  background: var(--err);
  border-radius: 2px;
}

.err-icon::before { transform: rotate(45deg); }
.err-icon::after { transform: rotate(-45deg); }

@keyframes pop-icon {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.sheet-title {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sheet-text {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.sheet-text.warn { color: var(--warn); font-weight: 560; }

.link-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.link-row input {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-align: left;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.85rem 0 0;
  line-height: 1.4;
}

.hint.tight { margin-top: 1rem; }

.banner.error {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--err-soft);
  color: var(--err);
  font-size: 0.88rem;
  font-weight: 560;
  animation: sheet-pop 0.4s var(--spring) both;
}

.hidden { display: none !important; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  counter-reset: step;
}

.steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 0.15rem 0.75rem;
  align-items: start;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  grid-row: 1 / span 2;
}

.steps strong {
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.steps span {
  color: var(--muted);
  font-size: 0.86rem;
}

.panel-view {
  text-align: center;
  animation: panel-in 0.5s var(--spring) both;
}

.panel-view .btn { margin-top: 0.25rem; }

.lock {
  width: 56px;
  height: 56px;
  margin: 0.2rem auto 0.9rem;
  border-radius: 18px;
  background: linear-gradient(160deg, #e8f2ff, #d6e8ff);
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.lock::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 16px;
  height: 12px;
  border: 2.5px solid var(--accent);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  transform: translateX(-50%);
}

.lock::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 22px;
  width: 22px;
  height: 18px;
  margin-left: -11px;
  border-radius: 6px;
  background: var(--accent);
}

pre {
  margin: 0 0 1rem;
  padding: 1rem;
  text-align: left;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.5;
  animation: sheet-pop 0.5s var(--spring) 0.05s both;
}

.back-btn {
  display: inline-flex;
  width: auto;
  min-width: 160px;
  margin-inline: auto;
}

@media (max-width: 420px) {
  .chips { grid-template-columns: 1fr 1fr; }
  .shell { width: min(100% - 1.25rem, 440px); }
}

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