:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #0b1220;
  --muted: rgba(11, 18, 32, 0.72);
  --stroke: #cbd5e1;
  --brand: #2f4aa8;
  --brand2: #1f8a94;
  --accent: #f2b84b;
  --danger: #b42318;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--ink);
}

.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(203, 213, 225, 0.7);
}

.topbar-inner {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  padding: 12px 12px;
  gap: 8px;
}

.topbar-title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.2px;
}

.iconbtn {
  appearance: none;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: var(--surface);
  border-radius: 12px;
  height: 40px;
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.iconbtn:active { transform: translateY(1px); }

.content {
  padding: 16px 14px 92px;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: var(--radius);
  padding: 14px;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }

.h1 { font-size: 22px; line-height: 1.2; margin: 0; letter-spacing: -0.2px; }
.p { margin: 0; color: var(--muted); line-height: 1.45; }
.small { font-size: 12px; color: var(--muted); line-height: 1.35; }

.progress {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 2px 6px;
}
.progress .step { font-weight: 700; font-size: 12px; }

.divider { height: 1px; background: rgba(203, 213, 225, 0.7); margin: 12px 0; }

.choices {
  display: grid;
  gap: 10px;
}
.choice {
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: #fff;
  font-size: 14px;
  line-height: 1.25;
}
.choice strong { display: block; margin-bottom: 2px; }
.choice:active { transform: translateY(1px); }
.choice.selected { border-color: rgba(47, 74, 168, 0.65); box-shadow: 0 0 0 3px rgba(47, 74, 168, 0.12); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 14px;
  overflow: hidden;
}
.segmented button {
  appearance: none;
  border: 0;
  background: #fff;
  padding: 10px 8px;
  font-size: 13px;
  color: var(--ink);
}
.segmented button + button { border-left: 1px solid rgba(203, 213, 225, 0.9); }
.segmented button.active { background: rgba(47, 74, 168, 0.08); font-weight: 700; }

.field label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  padding: 12px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(203, 213, 225, 0.9);
  font-size: 14px;
  outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.error { color: var(--danger); font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: #fff;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
}

.sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 14px;
  background: rgba(247, 248, 250, 0.92);
  border-top: 1px solid rgba(203, 213, 225, 0.7);
  display: flex;
  justify-content: center;
}
.sticky-inner { max-width: 420px; width: 100%; display: flex; gap: 10px; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 12px;
  font-weight: 700;
  font-size: 14px;
  width: 100%;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.secondary { background: #fff; border-color: rgba(203, 213, 225, 0.9); color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn:disabled { opacity: 0.45; }
.btn:active { transform: translateY(1px); }

.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.toggle .meta { flex: 1; }
.switch {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: rgba(203, 213, 225, 0.35);
  position: relative;
}
.switch::after {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: left 120ms ease;
  border: 1px solid rgba(203, 213, 225, 0.9);
}
.switch.on { background: rgba(47, 74, 168, 0.35); border-color: rgba(47, 74, 168, 0.55); }
.switch.on::after { left: 19px; }

.navgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.navcard {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: #fff;
}
.navcard .k { font-weight: 800; font-size: 13px; }
.navcard .d { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }

.banner {
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(47, 74, 168, 0.06);
}
.banner .k { font-weight: 800; font-size: 13px; }
.banner .d { color: var(--muted); font-size: 12px; margin-top: 2px; }

.msglist { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; border-radius: 14px; padding: 10px 11px; font-size: 14px; line-height: 1.35; border: 1px solid rgba(203, 213, 225, 0.9); background: #fff; }
.msg.me { margin-left: auto; border-color: rgba(47, 74, 168, 0.35); background: rgba(47, 74, 168, 0.06); }
.msg.sys { max-width: 100%; background: rgba(203, 213, 225, 0.22); border-style: dashed; color: rgba(11, 18, 32, 0.8); }
.msg.blur { background: rgba(203, 213, 225, 0.24); color: rgba(11, 18, 32, 0.7); }

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 62px;
  padding: 0 14px 12px;
  display: flex;
  justify-content: center;
}
.composer-inner {
  max-width: 420px;
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer-inner textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
}
.sendbtn {
  height: 44px;
  width: 62px;
  border-radius: 14px;
  border: 1px solid rgba(47, 74, 168, 0.35);
  background: rgba(47, 74, 168, 0.08);
  color: var(--brand);
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  max-width: 420px;
  width: 100%;
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  border: 1px solid rgba(203, 213, 225, 0.9);
}
.modal .title { font-weight: 900; font-size: 14px; }
.modal .body { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.35; }

