/* Натальная карта — стиль в духе tragos.ru */
:root {
  --red: #fa0000;
  --blue: #1a1ae6;
  --dark: #222;
  --gray: #666;
  --line: #ddd;
  --bg: #f5f5f5;
}

/* астрологические шрифты (символы планет, узлов, знаков и аспектов) */
@font-face {
  font-family: 'HamburgSymbols';
  src: url('fonts/HamburgSymbols.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'ZodiacPictogram';
  src: url('fonts/ZodiacPictogram.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
/* буквы Hamburg Symbols: Q Солнце, W Луна, E Меркурий, R Венера, T Марс,
   Y Юпитер, U Сатурн, I Уран, O Нептун, P Плутон, { Сев. узел, } Юж. узел,
   q/i/y/t/r/e/u/o/w — символы аспектов, 0-9 — цифры */
.sym-planet { font-family: 'HamburgSymbols', Arial, sans-serif; }
/* буквы Zodiac Pictogram: a…l = Овен…Рыбы */
.sym-sign   { font-family: 'ZodiacPictogram', Arial, sans-serif; }

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Segoe UI', 'PT Sans', 'DejaVu Sans', Arial, sans-serif;
  color: var(--dark);
  background: var(--bg);
}

/* ---------------------------------------------------------- шапка */
.topbar {
  background: #3b3b3b;
  color: #fff;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.logo {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .3px;
}
.logo::first-letter { color: #ff5c33; }
.sub { font-size: 12.5px; color: #c9c9c9; }

/* ---------------------------------------------------------- форма */
.wrap {
  max-width: 1180px;
  margin: 18px auto 30px;
  padding: 0 16px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 22px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
h1 { font-size: 24px; margin: 4px 0 6px; }
h2 { font-size: 16px; margin: 0 0 8px; color: #444; }
.lead { color: var(--gray); font-size: 14px; margin: 0 0 16px; line-height: 1.45; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.field { display: flex; flex-direction: column; }
.field.span2 { grid-column: span 2; }
.city-field { position: relative; grid-column: span 2; }
.field label {
  font-size: 12.5px;
  color: var(--gray);
  margin-bottom: 4px;
}
.field input, .field select {
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid #c4c4c4;
  border-radius: 4px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus { border-color: #4a6cd4; box-shadow: 0 0 0 2px rgba(74,108,212,.15); }
.field select { cursor: pointer; }
.field input.readonly {
  background: #f1f1f1;
  color: #222;
  font-weight: 700;
  letter-spacing: .5px;
}
.city-hint { font-size: 12px; color: #888; margin-top: 4px; min-height: 15px; }

/* переключатель «Дома на колесе» (пропорциональные дома) */
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 41px;
}
.field input.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 13px;
  background: #b9b9b9;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background .18s;
}
.field input.switch:checked { background: var(--red); }
.field input.switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: left .18s;
}
.field input.switch:checked::before { left: 23px; }
.field input.switch:focus-visible { box-shadow: 0 0 0 2px rgba(74,108,212,.35); }
.switch-state { font-size: 13.5px; color: #444; user-select: none; }

/* подсказки городов */
.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid #c4c4c4;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 320px;
  overflow: auto;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.suggest-item {
  padding: 8px 12px;
  font-size: 14.5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.suggest-item:hover, .suggest-item.active { background: #eef2ff; }
.suggest-side { font-size: 12px; color: #999; white-space: nowrap; }

.actions { margin-top: 16px; display: flex; align-items: center; gap: 14px; }
.btn {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--red);
  border: none;
  border-radius: 5px;
  padding: 10px 26px;
  cursor: pointer;
}
.btn:hover { background: #d50000; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-minor {
  font: inherit;
  font-size: 12.5px;
  padding: 3px 10px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #444;
}
.btn-minor:hover { background: #f2f2f2; }

.error { color: #c40000; font-size: 14px; }

/* ---------------------------------------------------------- результат */
.result {
  margin-top: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 22px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.info-line {
  font-size: 15.5px;
  line-height: 1.55;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}
.info-line .tzbadge {
  color: #1a5c00;
  font-weight: 600;
  white-space: nowrap;
}
.info-line .asc { font-weight: 600; }

/* ------------------------------------------------- фигура Джоунса */
.pattern-box {
  margin-top: 14px;
  padding: 10px 14px 11px;
  background: #fafafa;
  border-left: 3px solid var(--red);
  border-radius: 0 4px 4px 0;
  font-size: 14px;
  line-height: 1.5;
}
.pattern-name { font-size: 16px; font-weight: 700; }
.pattern-alt { font-weight: 400; color: #999; font-size: 12.5px; }
.pattern-desc { margin: 4px 0 6px; color: #333; }
.pattern-lines {
  margin: 0 0 4px;
  padding-left: 18px;
  color: #555;
  font-size: 13.5px;
}
.pattern-lines li { margin: 1px 0; }
.pattern-note { color: #999; font-size: 11.5px; margin-top: 5px; }

/* --------------------------------------------- структура Хубера */
.huber-box { border-left-color: var(--blue); }
.huber-counts { margin: 6px 0 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.huber-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; }
.huber-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.huber-group { margin: 4px 0; }
.huber-gname { font-size: 12.5px; font-weight: 700; }
.huber-group .pattern-lines { margin-top: 2px; }
.huber-facts { margin-top: 7px; color: #555; }

/* ------------------------------------------ замкнутые фигуры аспектов */
.figures-box { border-left-color: #2e965e; }

/* ------------------------------------------ внешность (1-й дом) */
.appearance-box { border-left-color: #8a5fb0; }
.appear-mark { color: #8a5fb0; font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ------------------------------------------ малый, большой и высшие миры */
.worlds-box { border-left-color: #b8860b; }
.world-intro { margin: 2px 0 4px; }
.world-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px 9px;
  margin: 8px 0;
}
.world-lead { background: #fdf8ec; border-color: #e8d9b0; }
.world-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.world-title { font-size: 15px; }
.world-houses { color: #777; font-size: 12.5px; }
.world-badge {
  background: #f5e6c4;
  color: #7a5b00;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
}
.world-score { margin-left: auto; color: #999; font-size: 12px; white-space: nowrap; }
.world-house { color: #888; font-size: 12px; white-space: nowrap; }
.world-border {
  margin: 0 0 2px;
  font-style: italic;
  color: #6b5b2e;
  border-left: 2px solid #d9c98a;
  padding-left: 8px;
}
.world-bar {
  display: flex;
  height: 13px;
  border-radius: 7px;
  overflow: hidden;
  margin: 10px 0 5px;
  background: #eee;
}
.world-bar i { display: block; height: 100%; min-width: 2px; }
.world-bar-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12.5px;
  color: #555;
  margin: 0 0 8px;
}
.world-bar-labels .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
}

/* --------------------- оптимист, пессимист и реалист */
.outlook-box { border-left-color: #546e7a; }
.outlook-card {
  background: #eef3f4;
  border-color: #ccd9dc;
  border-left-color: #546e7a;
}
/* --------------------- кто я на самом деле и в чем моя сила (Солнце) */
.identity-box { border-left-color: #c8871a; }
.identity-step {
  background: #fdf8ee;
  border-color: #ecd9b0;
  border-left-color: #c8871a;
}
.outlook-badge {
  background: #d8e4e7;
  color: #37474f;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
}

.result-layout {
  display: flex;
  gap: 26px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.chart-box { flex: 0 0 auto; }
.chart-box svg { width: 620px; max-width: 100%; height: auto; }

.tables { flex: 1 1 300px; min-width: 280px; display: flex; flex-direction: column; gap: 18px; }
.table-block { margin: 0; }

.pos-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.pos-table th, .pos-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
  white-space: nowrap;
}
.pos-table th { color: #888; font-weight: 600; font-size: 12px; }
.pos-table .g { font-size: 17px; width: 26px; }
.pos-table .h { color: #555; }
.pos-table .retro { color: #999; font-size: 11px; }
/* планета на границе домов: формальный → фактический дом (правило 5°) */
.house-shift { color: #8a5fb0; font-weight: 700; cursor: help; border-bottom: 1px dotted #b39ac6; }

/* -------------------------------------------------- матрицы аспектов
   Компактные таблицы в духе tragos.ru: «планеты к планетам» — треугольник
   с глифами планет на диагонали, «планеты к домам» — прямоугольник
   «куспиды домов × планеты». В ячейке — цветной символ аспекта и мелкий орб. */
.asp-matrix {
  border-collapse: collapse;
  margin-top: 4px;
}
.asp-matrix td {
  width: 34px;
  height: 36px;
  min-width: 34px;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  border: 1px solid #e2e2e2;
}
.asp-matrix td.lb {
  width: auto;
  min-width: 40px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}
.asp-matrix td.dc { background: #fafafa; }
.asp-matrix .dc .sym-planet,
.asp-matrix tr.hd td .sym-planet { font-size: 15px; color: #333; }
.asp-matrix .amark {
  display: block;
  font-size: 15px;
  line-height: 1;
}
.asp-matrix .aorb {
  display: block;
  font-size: 8.5px;
  line-height: 1;
  color: #999;
  margin-top: 3px;
  white-space: nowrap;
}
.orb-note { color: #999; font-size: 12.5px; margin: 6px 0 0; }

/* --------------------------------------------- знак синтеза */
.synth-table {
  border-collapse: collapse;
  margin: 4px auto 0;
  font-size: 14px;
}
.synth-table th, .synth-table td {
  border: 1px solid #ddd;
  padding: 4px 12px;
  text-align: center;
}
.synth-table th { color: #333; font-size: 13.5px; font-weight: 700; }
.synth-table td { min-width: 44px; }
.synth-table .t { background: #fff; }
.synth-signs { margin: 8px 0 0; text-align: center; font-size: 14.5px; }
.synth-signs .sym-sign { font-size: 16px; }

/* темперамент по возрастным периодам (нижний блок, в стиле блоков анализа) */
.temper-box .synth-table { margin: 8px auto 0; }
.temper-table th:first-child, .temper-table td:first-child { text-align: left; white-space: nowrap; }
.temper-table .age { font-weight: 700; color: #333; font-size: 13px; }
.temper-table .planets { white-space: nowrap; font-size: 15px; min-width: 96px; }
.temper-table .planets .pnew { color: #b35c00; }
.temper-table td.mx { font-weight: 700; outline: 1.5px solid #666; outline-offset: -1.5px; }
.temper-table .temper { min-width: 120px; white-space: nowrap; }
.temper-chip { padding: 1px 7px; border-radius: 8px; font-size: 13px; white-space: nowrap; }

/* трактовка темперамента по возрастам */
.temper-interp { margin-top: 14px; text-align: left; }
.temper-age { margin: 12px 0 4px; font-weight: 700; color: #333; }
.temper-text { margin: 0 0 6px; font-size: 14px; color: #333; text-align: left; }

.share-hint { margin-top: 18px; font-size: 13px; color: var(--gray); }
.share-hint a { color: #1a4db3; word-break: break-all; }

/* ссылка «на все карты» в блоке сохранённых карт */
.share-all-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
#share-all-row { font-size: 13px; color: var(--gray); }
#share-all-row a { color: #1a4db3; word-break: break-all; }
.share-import { color: #1a4db3; }

/* ---------------------------------------------------------- спиннер */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.65);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: #555;
  font-size: 15px;
}
.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid #e0e0e0;
  border-top-color: var(--red);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.foot {
  max-width: 1180px;
  margin: 0 auto 24px;
  padding: 0 16px;
  font-size: 12px;
  color: #999;
}

/* версия приложения (natal-chart.php — модуль, внизу виджета) */
.nc-version {
  margin-top: 12px;
  font-size: 12px;
  color: #999;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.span2, .city-field { grid-column: span 1; }
  .chart-box { flex: 0 1 auto; min-width: 0; }
  .chart-box svg { width: 100%; height: auto; }
  /* матрицы аспектов на телефоне: чуть уже, при нехватке места — прокрутка */
  .asp-matrix td { width: 28px; min-width: 28px; height: 30px; }
  .asp-matrix .amark { font-size: 13px; }
  .table-block, .pattern-box { overflow-x: auto; }
}

/* ------------------------------------------------- сохранённые карты */
.saved-card { margin-top: 16px; }
.saved-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.saved-head h2 { margin: 0; }
.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.saved-item {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.saved-item.current {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red) inset;
}
.saved-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  min-width: 0;
}
.saved-open:hover { background: #f7f7f7; }
.saved-open b {
  font-size: 14px;
  color: var(--dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.saved-meta { font-size: 12px; color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.saved-del {
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  cursor: pointer;
  color: #999;
  width: 34px;
  font-size: 16px;
  line-height: 1;
}
.saved-del:hover { color: #c40000; background: #fff2f2; }
.saved-note { color: var(--gray); font-size: 12.5px; margin: 12px 0 0; line-height: 1.5; }
.save-status { color: #2e965e; font-size: 14px; }

@media (max-width: 640px) {
  .saved-list { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
}
