:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --ink: #152033;
  --muted: #6b7a90;
  --accent: #0b7dda;
  --accent-soft: #e8f3fc;
  --danger: #d14343;
  --line: #dde3ec;
  --shadow: 0 8px 24px rgba(21, 32, 51, 0.06);
  --nav-h: 64px;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.brand {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.page-title {
  margin: 4px 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.greeting {
  margin: 0;
  max-width: 46%;
  text-align: right;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff6e8;
  color: #8a5a12;
  font-size: 0.85rem;
  line-height: 1.4;
}

.pages { flex: 1; }

.page { display: none; animation: fade .18s ease; }
.page.is-active { display: block; }

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

.lead {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 650;
}

.token-box {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.token-value {
  flex: 1;
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--ink);
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.btn-row.wrap { margin-bottom: 12px; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; margin-top: 8px; }

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-danger-outline {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(209, 67, 67, 0.35);
  background: #fff;
  color: var(--danger);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.status-line {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.code-block, .mono {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: #f3f6fa;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #243247;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink);
  line-height: 1.55;
}

.steps code {
  font-size: 0.8rem;
  color: var(--accent);
}

.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.seg-inline {
  display: flex;
  width: 100%;
  margin: 10px 0;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(21, 32, 51, 0.08);
}

.seg-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.syntax-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.syntax-table th,
.syntax-table td {
  text-align: left;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.syntax-table th { color: var(--muted); font-weight: 600; }
.syntax-table code { font-size: 0.78rem; color: var(--accent); }

.textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.field-label {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:active { background: var(--accent-soft); color: var(--accent); }

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
}

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
  border-radius: 12px;
  padding: 6px 4px;
}

.nav-item.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
