:root {
  --bg: #f6f4fb; --card: #fff; --text: #1d1a2b; --muted: #6d6880; --line: #e3dff0;
  --accent: #6a4fd8; --accent-2: #efeafd; --soft: #2e9d6a; --hard: #d2483f; --neutral: #6a4fd8;
  --fire: #d9573b; --earth: #4f8a3c; --air: #c99a16; --water: #2f78c4;
  --tabbar: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14121f; --card: #1f1c2e; --text: #ece9f6; --muted: #9c97b3; --line: #322e45;
    --accent: #9d86ff; --accent-2: #2a2442; --soft: #4cc28a; --hard: #f06b62; --neutral: #9d86ff;
    --fire: #ff7d5e; --earth: #7cc463; --air: #f0c445; --water: #5aa6f0;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: 0 14px 24px; }
h1 { font-size: 24px; margin: 6px 0 14px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 18px 0 8px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: flex-end;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; background: var(--bg);
}
.who {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 20px;
  padding: 6px 14px; font-size: 14px; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 14px;
        box-shadow: 0 1px 3px rgb(0 0 0 / .06); }
.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; flex: 1; min-width: 0; }
.form input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 4px; font-size: 16px; /* 16px — без автозума в iOS */
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
  min-height: 46px;
}
.form .row { display: flex; gap: 10px; align-items: flex-end; }
.form .narrow { flex: 0 0 96px; }
.form .check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); min-height: 46px; }
.form .check input { width: 22px; height: 22px; accent-color: var(--accent); }
.manual { margin: 0 0 12px; }
.manual summary { color: var(--accent); font-size: 14px; padding: 6px 0 10px; cursor: pointer; }
.actions { display: flex; gap: 10px; }
button { font: inherit; cursor: pointer; }
.primary, .ghost {
  min-height: 48px; border-radius: 12px; padding: 0 18px; font-weight: 600; font-size: 16px; border: 0; width: 100%;
}
.primary { background: var(--accent); color: #fff; }
.ghost { background: var(--accent-2); color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.profiles { list-style: none; margin: 0 0 14px; padding: 0; }
.profiles li { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px;
               padding: 10px 12px; margin-bottom: 8px; border: 2px solid transparent; }
.profiles li.on { border-color: var(--accent); }
.profiles .pick { flex: 1; text-align: left; background: none; border: 0; color: var(--text); padding: 4px 0; min-height: 44px; }
.profiles .pick small { display: block; color: var(--muted); }
.profiles .icon { background: none; border: 0; font-size: 20px; width: 44px; height: 44px; color: var(--muted); }

.seg { display: flex; background: var(--accent-2); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; color: var(--accent); font-weight: 600; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; height: var(--tabbar); border: 0; background: none; color: var(--muted); font-size: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tabs button span { font-size: 22px; line-height: 1; }
.tabs button.on { color: var(--accent); }

.out:empty::before { content: attr(data-empty); color: var(--muted); }
.loading { text-align: center; color: var(--muted); padding: 30px 0; }
.error { background: color-mix(in srgb, var(--hard) 12%, var(--card)); color: var(--hard); padding: 12px 14px; border-radius: 12px; }
.note { color: var(--muted); font-size: 13px; }

/* Круг карты */
.wheel { width: 100%; height: auto; display: block; font-family: "Noto Sans Symbols", "Segoe UI Symbol", "Apple Symbols", sans-serif; }
.wheel .ring { fill: none; stroke: var(--line); stroke-width: 1.5; }
.wheel .ring.inner { stroke: var(--muted); stroke-opacity: .4; }
.wheel text { text-anchor: middle; dominant-baseline: central; }
.wheel .sg { font-size: 30px; }
.wheel .el-fire { fill: var(--fire); } .wheel .el-earth { fill: var(--earth); }
.wheel .el-air { fill: var(--air); } .wheel .el-water { fill: var(--water); }
.wheel .cusp { stroke: var(--line); stroke-width: 1; }
.wheel .cusp.axis { stroke: var(--text); stroke-width: 2; }
.wheel .hn { font-size: 17px; fill: var(--muted); }
.wheel .asp { stroke-width: 1.4; stroke-opacity: .75; }
.wheel .asp.soft { stroke: var(--soft); } .wheel .asp.hard { stroke: var(--hard); }
.wheel .asp.neutral { stroke: var(--neutral); }
.wheel .pl { font-size: 38px; fill: var(--text); }
.wheel .pl.transit { fill: var(--accent); font-size: 32px; }
.wheel .deg { font-size: 17px; fill: var(--muted); }
.wheel .rx { font-size: 15px; font-family: sans-serif; font-weight: 700; }
.wheel .tick { stroke: var(--text); stroke-width: 1.5; }
.wheel .tick.transit { stroke: var(--accent); }

/* Таблицы и списки */
.pos { width: 100%; border-collapse: collapse; font-size: 15px; }
.pos td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.pos td:first-child { white-space: nowrap; }
.pos .g { font-size: 18px; width: 28px; text-align: center; }
.pos .s { white-space: nowrap; }
.pos .s small { display: block; color: var(--muted); font-size: 12px; }
.pos .r { text-align: right; color: var(--muted); white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--accent-2); color: var(--accent); margin-left: 4px; vertical-align: 1px; }

details.item { background: var(--card); border-radius: 14px; margin-bottom: 8px; overflow: hidden; }
details.item summary { list-style: none; padding: 13px 14px; display: flex; gap: 10px; align-items: center; cursor: pointer; min-height: 48px; }
details.item summary::-webkit-details-marker { display: none; }
details.item summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; transition: transform .15s; }
details.item[open] summary::after { transform: rotate(90deg); }
details.item .body { padding: 0 14px 14px; color: var(--text); font-size: 15px; }
.sum-main { flex: 1; min-width: 0; }
.sum-main small { display: block; color: var(--muted); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.soft { background: var(--soft); } .dot.hard { background: var(--hard); } .dot.neutral { background: var(--neutral); }

.bars { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; font-size: 14px; margin-bottom: 10px; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); }
.bar.fire { background: var(--fire); } .bar.earth { background: var(--earth); }
.bar.air { background: var(--air); } .bar.water { background: var(--water); }

.month { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 8px; }

/* Нумерология */
.nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.nums.three { grid-template-columns: repeat(3, 1fr); }
.num { background: var(--card); border-radius: 14px; padding: 12px; }
.num b { display: block; font-size: 34px; line-height: 1.1; color: var(--accent); }
.num small { color: var(--muted); font-size: 12px; display: block; }
.num span { font-size: 14px; font-weight: 600; }
.matrix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.matrix button {
  aspect-ratio: 1.15; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px;
}
.matrix button b { font-size: 20px; letter-spacing: 1px; word-break: break-all; }
.matrix button small { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; }
.matrix button.on { border-color: var(--accent); background: var(--accent-2); }
.cell-text { min-height: 48px; }
.lines { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 14px; }
.lines div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 0; }

@media (min-width: 700px) {
  .tabs { justify-content: center; }
  .tabs button { flex: 0 0 140px; }
}
