:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --card: #1e293b;
  --card-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #8b5cf6;
  --accent-2: #6d28d9;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

h1 { font-size: 22px; line-height: 1.3; }
h2 { font-size: 18px; margin-bottom: 8px; }
p { color: var(--muted); line-height: 1.5; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.hero {
  background: linear-gradient(135deg, #312e81 0%, #6d28d9 60%, #db2777 100%);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 18px;
}
.hero .logo { font-size: 40px; }
.hero h1 { font-size: 24px; margin: 8px 0 6px; }
.hero p { color: #c4b5fd; }

.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-2);
  color: var(--text);
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #06230f; }
.btn-outline { background: transparent; border: 1px solid #334155; color: var(--text); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn + .btn { margin-top: 10px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; gap: 8px; }
.seg .btn { margin-top: 0; }
.seg .btn.active { background: var(--accent); color: #fff; }

.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.step-hint {
  font-size: 13px;
  color: var(--muted);
  background: var(--card-2);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

/* Пиллярная сетка */
.pillar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pillar {
  background: var(--card-2);
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
}
.pillar .plabel { font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.pillar .cell { border-radius: 10px; padding: 8px 2px; margin-bottom: 6px; color: #fff; }
.pillar .cell:last-child { margin-bottom: 0; }
.pillar .cell .c-char { font-size: 26px; line-height: 1.1; font-weight: 700; }
.pillar .cell .c-name { font-size: 10px; opacity: .95; margin-top: 2px; }
.pillar .cell .c-meta { font-size: 9px; opacity: .75; }
.pillar.day .plabel { color: var(--warning); font-weight: 700; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid #334155;
}
.chip.big { font-size: 14px; padding: 8px 14px; }

/* Баланс элементов */
.balance { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 130px; padding: 8px 4px 0; }
.balance .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.balance .bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.balance .bar {
  width: 70%;
  border-radius: 8px 8px 4px 4px;
  min-height: 6px;
  transition: height .4s ease;
}
.balance .bar-count { font-size: 13px; font-weight: 700; }
.balance .bar-label { font-size: 11px; color: var(--muted); }

/* Круг пяти стихий */
.svg-wrap { display: flex; justify-content: center; margin: 8px 0; }
.svg-wrap svg { max-width: 100%; }
.node { cursor: pointer; }
.node .ring { transition: r .15s ease; }
.node:hover .ring { stroke-width: 3px; }

/* Подсекции */
.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.sub-item:active { background: var(--card-2); }
.sub-item.done { border-color: rgba(34,197,94,.5); }
.sub-item .check-ico { color: var(--success); }

.analysis-text {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}
.analysis-text .h {
  font-weight: 700;
  color: var(--warning);
  font-size: 16px;
  display: block;
  margin-top: 16px;
}

.divider { height: 1px; background: #334155; margin: 14px 0; }

.price { font-size: 20px; font-weight: 700; color: #fff; }
.price-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

.status-pill {
  display: inline-block;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}
.status-pill.success { background: rgba(34,197,94,.15); color: #86efac; }
.status-pill.wait { background: rgba(245,158,11,.15); color: #fcd34d; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid #334155;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 18px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #334155;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: 90vw;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #7f1d1d; }

#loading {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.mt { margin-top: 14px; }
.mt2 { margin-top: 22px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }

.notice { background: rgba(139,92,246,.1); border: 1px solid rgba(139,92,246,.35); border-radius: 12px; padding: 12px; font-size: 14px; margin-bottom: 14px; }

.resume-card { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.35); margin-top: 4px; }

.offers { display: flex; flex-direction: column; gap: 10px; }
.offer {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}
.offer:active { border-color: var(--accent); }
.offer .ic { font-size: 26px; }
.offer .t { flex: 1; }
.offer .t .n { font-weight: 600; }
.offer .t .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.offer .p { font-weight: 700; color: #fff; white-space: nowrap; }

.compat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compat-grid .pillar-grid { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 360px) {
  .pillar .cell .c-char { font-size: 22px; }
  .compat-grid { grid-template-columns: 1fr; }
}
