@font-face {
  font-family: 'Sifyna';
  src: url('sifyna.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg-deep: #080D18;
  --bg: #0E1525;
  --bg-elev: #162035;
  --bg-card: rgba(22, 32, 53, 0.86);
  --bg-card-2: #1E2B44;
  --navy: #23314A;
  --coral: #DB8084;
  --coral-soft: rgba(219, 128, 132, 0.18);
  --slate: #8FA1B1;
  --mint: #7FD1B9;
  --gold: #E6C27A;
  --blue: #72B5D8;
  --text: #F1F5FC;
  --text-muted: #B5C4D8;
  --border: rgba(143, 161, 177, 0.24);
  --border-strong: rgba(143, 161, 177, 0.42);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 22% 14%, #1A2742 0%, #0E1525 54%, #080D18 100%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
}

.hidden { display: none !important; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(180deg, #080D18, #0E1525, #17233B);
  cursor: pointer;
}
.splash canvas { width: 100%; height: 100%; display: block; }

.app-shell {
  display: flex;
  height: 100%;
  width: 100%;
  padding-top: var(--safe-top);
}

.nav-rail {
  width: 92px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: rgba(14, 21, 37, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px calc(12px + var(--safe-bottom));
  gap: 6px;
  overflow-y: auto;
}
.nav-rail-brand { width: 34px; height: 34px; margin-bottom: 10px; }

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 14px;
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.nav-item.active {
  background: var(--coral-soft);
  color: var(--coral);
}
.nav-item-icon { font-size: 18px; line-height: 1; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 21, 37, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.top-title { flex: 1; min-width: 0; }
.top-chart-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-chart-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(30, 43, 68, 0.55);
  color: var(--text);
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:active { transform: scale(0.95); background: rgba(219, 128, 132, 0.22); }

.screen-root {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 12px 12px calc(28px + var(--safe-bottom));
}

.mobile-only { display: none; }

@media (max-width: 760px) {
  .nav-rail { display: none; }
  .mobile-only { display: inline-flex; }
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 18, 0.62);
  z-index: 40;
}
.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 268px;
  background: rgba(20, 30, 50, 0.98);
  border-right: 1px solid var(--border-strong);
  z-index: 50;
  padding: calc(18px + var(--safe-top)) 12px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.drawer-header img { width: 30px; height: 30px; }
.drawer-header span { font-size: 18px; font-weight: 600; letter-spacing: 0.03em; }
.drawer-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}
.drawer-item.active {
  background: var(--coral-soft);
  color: var(--coral);
}

.two-pane {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: 1240px;
  margin: 0 auto;
}
@media (min-width: 820px) {
  .two-pane { grid-template-columns: 1.05fr 0.95fr; align-items: start; }
}

.stack { display: flex; flex-direction: column; gap: 12px; max-width: 1040px; margin: 0 auto; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}
.muted { color: var(--text-muted); font-size: 13px; }
.small { font-size: 12px; }
.accent { color: var(--coral); }
.mint { color: var(--mint); }
.gold { color: var(--gold); }
.blue { color: var(--blue); }

.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.row-scroll::-webkit-scrollbar { display: none; }

.chip-btn {
  border: 1px solid var(--border-strong);
  background: rgba(30, 43, 68, 0.55);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.chip-btn.active {
  background: var(--coral-soft);
  border-color: var(--coral);
  color: var(--coral);
}
.chip-btn:active { transform: scale(0.96); }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn-primary { background: var(--coral); color: #1A1216; }
.btn-tonal { background: rgba(143, 161, 177, 0.20); color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--coral); border: 1px solid var(--border-strong); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.btn-full { width: 100%; }
.btn:active { opacity: 0.82; transform: scale(0.98); }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.tab-btn.active {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(143, 161, 177, 0.16);
}
.list-row:last-child { border-bottom: 0; }
.list-row.clickable { cursor: pointer; }
.list-row.selected { background: rgba(219, 128, 132, 0.12); border-radius: 10px; padding-left: 8px; padding-right: 8px; }

.wheel-wrap { width: 100%; max-width: 520px; margin: 6px auto; }
.wheel-wrap svg { width: 100%; height: auto; display: block; touch-action: manipulation; }

.planet-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 9px;
  font-size: 12px;
  background: rgba(31, 45, 73, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.planet-pill.selected { border-color: var(--coral); background: var(--coral-soft); color: var(--coral); }

.bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(143, 161, 177, 0.18);
  overflow: hidden;
  margin-top: 3px;
}
.bar-fill { height: 100%; background: var(--coral); border-radius: 999px; }

.field {
  width: 100%;
  background: rgba(14, 21, 37, 0.72);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 16px; /* >=16px чтобы iOS Safari не зумил экран при фокусе */
  outline: none;
}
.field:focus { border-color: var(--coral); }
.field-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
textarea.field { min-height: 76px; resize: vertical; font-family: inherit; }

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

.matrix-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matrix-table { border-collapse: collapse; font-size: 13px; }
.matrix-table td, .matrix-table th {
  width: 32px; height: 32px; min-width: 32px;
  text-align: center;
  border: 1px solid rgba(143, 161, 177, 0.22);
  padding: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 9, 18, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #141E33;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 90;
  background: rgba(30, 43, 68, 0.96);
  border: 1px solid var(--coral);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: 90vw;
  text-align: center;
}

.divider { height: 1px; background: var(--border); margin: 10px 0; }

.glyph-svg {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.22em;
  flex-shrink: 0;
}
.nav-item-icon .glyph-svg, .drawer-item .glyph-svg {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}
