:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --p: #6d5efc;
  --p2: #8b7cff;
  --ok: #12b76a;
  --bad: #f04438;
  --soft: #f3f4f6;
  --radius: 16px;
  --nav: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: Inter, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--font);
}
button, input { font: inherit; }
.hidden { display: none !important; }

.gate {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px;
}
.gate-logo { width: 88px; height: 88px; object-fit: contain; }

.app {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  padding-bottom: calc(var(--nav) + var(--safe-b) + 8px);
  background: var(--bg);
}

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: rgba(244,245,247,.92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 12px;
  background: var(--soft); cursor: pointer;
}

.main { padding: 12px 14px; }
.screen { display: none; animation: up .18s ease; }
.screen.active { display: block; }
@keyframes up { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.banner {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, #6d5efc, #4f8cff);
  color: #fff; border-radius: 20px; padding: 16px 18px; margin-bottom: 12px;
}
.banner h2 { margin: 0; font-size: 1.2rem; }
.banner p { margin: 4px 0 0; opacity: .9; font-size: .85rem; }
.banner img { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,.15)); }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px;
}
.stats > div {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 8px; text-align: center;
}
.stats b { display: block; font-size: 1.1rem; }
.stats span { font-size: .72rem; color: var(--muted); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.card h4 { margin: 0 0 8px; font-size: .9rem; }
.card ul { margin: 0 0 12px; padding-left: 18px; color: var(--muted); line-height: 1.5; }
.muted { color: var(--muted); font-size: .9rem; }
.mt { margin-top: 12px; }
.page-h { margin: 0 0 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; text-align: left; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.tile span { font-size: 1.2rem; }

.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--p); color: #fff; }
.btn.primary:active { background: #5a4ce0; }
.btn.soft { background: var(--soft); color: var(--text); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--p); font-weight: 700; cursor: pointer; padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  border: 1px solid var(--line); background: var(--soft); border-radius: 999px;
  padding: 8px 12px; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.chip.on { background: #111; color: #fff; border-color: #111; }

.kim {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-height: 40vh; overflow: auto;
}
.kim button {
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 10px 8px; text-align: left; font-size: .78rem; font-weight: 700; cursor: pointer; min-height: 52px;
}
.kim button small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }
.kim button.on { border-color: var(--p); background: #f0eeff; }

.row { display: flex; align-items: end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.field input, .answer-row input, .composer input {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; outline: none; background: #fff;
}
.field input:focus, .answer-row input:focus, .composer input:focus { border-color: var(--p); }

.solve-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.tags { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tag {
  background: #f0eeff; color: var(--p); font-size: .72rem; font-weight: 800;
  padding: 4px 8px; border-radius: 999px;
}
.tag.soft { background: var(--soft); color: var(--muted); }
.body { white-space: pre-wrap; line-height: 1.55; margin: 8px 0 12px; font-size: .95rem; }
.answer-row { display: flex; gap: 8px; }
.answer-row input { flex: 1; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fb { margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 700; font-size: .9rem; }
.fb.ok { background: #ecfdf3; color: #027a48; }
.fb.bad { background: #fef3f2; color: #b42318; }

.chat { display: flex; flex-direction: column; gap: 8px; min-height: 58vh; }
.chat-log {
  flex: 1; min-height: 38vh; max-height: 48vh; overflow: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.bubble {
  max-width: 88%; padding: 10px 12px; border-radius: 16px;
  font-size: .92rem; line-height: 1.45; white-space: pre-wrap;
}
.bubble.bot { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--p); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-actions { display: flex; gap: 6px; overflow-x: auto; }
.chat-actions button {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 8px 12px; font-size: .78rem; font-weight: 600;
}
.composer {
  display: flex; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 6px 8px;
}
.composer input { flex: 1; border: 0; padding: 8px; }
.send {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: var(--p); color: #fff; font-weight: 700; cursor: pointer;
}
.hint { margin: 0; font-size: .72rem; color: var(--muted); }

.plans { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.plan {
  background: #fff; border: 2px solid var(--line); border-radius: 16px;
  padding: 14px; text-align: left; cursor: pointer;
}
.plan.on { border-color: var(--p); box-shadow: 0 0 0 3px rgba(109,94,252,.15); }
.plan h4 { margin: 0 0 4px; }
.plan .price { color: var(--p); font-weight: 800; font-size: 1.15rem; margin: 6px 0; }
.plan ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: .85rem; }
.status { min-height: 1.2em; color: var(--p); font-size: .85rem; font-weight: 600; }

.profile { display: flex; gap: 12px; align-items: center; }
.profile img { width: 48px; height: 48px; object-fit: contain; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.nav-i {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .65rem; font-weight: 700; cursor: pointer;
}
.nav-i i { font-style: normal; font-size: 1.1rem; }
.nav-i.active { color: var(--p); }

@media (min-width: 520px) {
  .app, .nav { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
