:root {
  color-scheme: dark;
  --bg: #111119;
  --panel: #1a1924;
  --surface: #22212e;
  --ink: #f2ecf8;
  --secondary: #c5becf;
  --muted: #a9a0b7;
  --line: #393445;
  --gold: #edcd94;
  --indigo: #aab0ff;
  --teal: #8cddd1;
  --lilac: #d0aef2;
  --shell: 1190px;
  --safe-start: max(env(safe-area-inset-left, 0px), var(--telegram-left, 0px));
  --safe-end: max(env(safe-area-inset-right, 0px), var(--telegram-right, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: var(--telegram-height, 100vh);
  color: var(--ink);
  background: radial-gradient(ellipse 75% 35% at 28% 0%, #211b2e, transparent 100%), var(--bg);
  padding-top: max(env(safe-area-inset-top, 0px), var(--telegram-top, 0px));
  padding-inline: var(--safe-start) var(--safe-end);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--telegram-bottom, 0px));
}
button, input, select { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.shell { width: min(calc(100% - 64px), var(--shell)); margin-inline: auto; }
.topbar { border-bottom: 1px solid #d9bff216; }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 560; letter-spacing: .07em; text-decoration: none; }
.top-link { color: var(--secondary); font-size: .81rem; text-decoration: none; }
.top-link:hover { color: var(--gold); }
.top-link span { margin-inline-start: 5px; color: var(--gold); }
main.shell { padding-bottom: 64px; }
.intro { padding-block: 38px 26px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { font-size: clamp(3rem, 7vw, 5.65rem); letter-spacing: -.065em; line-height: .98; }
h1 em { color: var(--gold); font-weight: 400; }
.intro p { margin-top: 15px; color: var(--secondary); font-size: clamp(.87rem, 1.8vw, 1.03rem); line-height: 1.45; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 385px);
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}
.observatory {
  min-width: 0;
  padding: 9px 18px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  background:
    radial-gradient(circle at 50% 47%, #30243e 0, #1d1929 47%, #171621 76%),
    #171621;
}
.figure { width: min(100%, 558px); }
.wheel { display: block; width: 100%; height: auto; overflow: visible; user-select: none; }
.wheel-guide { fill: none; stroke: #ba9ec82c; stroke-width: .8; }
.wheel-tick { stroke: #b1a2c375; stroke-width: .72; }
.wheel-tick.major { stroke: #ebd7efab; stroke-width: 1; }
.segment {
  fill: var(--ring-fill);
  fill-opacity: .86;
  stroke: var(--ring-edge);
  stroke-width: .7;
  cursor: crosshair;
  touch-action: none;
}
.segment.active { fill: var(--ring-on); stroke: var(--ring-color); stroke-opacity: .95; stroke-width: 1; }
.segment.repeated { fill: #44988d; stroke: #b0f7e8; stroke-width: .75; }
.segment.active.repeated { fill: #a4eee3; stroke: #dcfff8; }
.ring-d1 { --ring-color: #ffdda2; --ring-edge: #a78b655e; --ring-fill: #423442; --ring-on: #92704c; }
.ring-nakshatra { --ring-color: #c9caff; --ring-edge: #9093dc6b; --ring-fill: #302b58; --ring-on: #535aa1; }
.ring-navamsha { --ring-color: #a6eee4; --ring-edge: #72bfb183; --ring-fill: #234a4d; --ring-on: #53a59c; }
.ring-cycle { --ring-color: #e4caff; --ring-edge: #b38bd861; --ring-fill: #3d2b53; --ring-on: #694b89; }
.ring-label { fill: var(--ring-color); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.ring-d1 .ring-label { font-size: 24px; font-family: "Apple Symbols", "Segoe UI Symbol", sans-serif; }
.ring-nakshatra .ring-label, .ring-cycle .ring-label { font-size: 10.5px; font-weight: 620; }
.ring[hidden] { display: none; }
.wheel-index { fill: var(--muted); text-anchor: middle; dominant-baseline: central; font-size: 8px; }
.wheel-axis { stroke: #f8eaff; stroke-opacity: .82; stroke-width: 1.15; pointer-events: none; }
.wheel-axis-point { fill: #fff0d4; stroke: #211a2c; stroke-width: 1.1; pointer-events: none; }
.hub { fill: #181522; stroke: #6b547a; stroke-width: 1; }
.hub-ornament { fill: none; stroke: #9c81b147; stroke-width: .7; }
.hub-label { fill: var(--muted); font-size: 9px; font-weight: 700; text-anchor: middle; }
.hub-sign { font-size: 31px; text-anchor: middle; font-family: "Apple Symbols", "Segoe UI Symbol", sans-serif; }
.hub-name { fill: var(--ink); font-size: 13px; text-anchor: middle; font-weight: 630; }
.hub-degree { fill: var(--secondary); font-size: 11px; text-anchor: middle; font-variant-numeric: tabular-nums; }
.hub-arrow { fill: var(--muted); font-size: 15px; text-anchor: middle; }
.gesture { margin-top: -3px; font-size: .81rem; color: var(--muted); text-align: center; }
.console { min-width: 0; padding: 27px 26px 22px; border-left: 1px solid var(--line); background: linear-gradient(160deg, #232031, #191822 65%); }
.console h2 { font-size: 1.55rem; letter-spacing: -.035em; margin-bottom: 17px; }
.d1-slider-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: .8rem; color: var(--secondary); }
.d1-slider-label output { color: var(--gold); font-variant-numeric: tabular-nums; font-size: 1.13rem; }
input[type="range"] { min-width: 0; accent-color: var(--gold); margin: 0; cursor: pointer; }
.wide-range { width: 100%; display: block; height: 28px; }
.scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .65rem; }
.position-form { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, minmax(62px, .48fr)); gap: 8px 9px; }
.position-form label { display: grid; min-width: 0; gap: 6px; color: var(--secondary); font-size: .75rem; }
select, input[type="number"], button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid #51475f;
  border-radius: 8px;
  padding: 7px 9px;
  min-height: 38px;
  min-width: 0;
}
select { overflow: hidden; text-overflow: ellipsis; }
.position-form select, .position-form input { width: 100%; font-size: 16px; }
button { cursor: pointer; }
button:hover { background: #332c40; border-color: #867294; }
.apply { grid-column: 1 / -1; color: var(--secondary); font-size: .8rem; min-height: 36px; }
.navigation { margin-top: 11px; display: grid; grid-template-columns: 45px 1fr 45px; gap: 8px; }
.navigation button { min-height: 42px; }
.navigation button:first-child, .navigation button:last-child, .cycle-navigation button { font-size: 1.5rem; line-height: .9; }
.play { background: #e6ca99; color: #251b29; border-color: #edcd94; font-weight: 680; font-size: .86rem; }
.play:hover { background: #f6deb1; border-color: #f6deb1; }
#play-icon { font-size: .78em; margin-right: 2px; }
.speed-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 52px; align-items: center; gap: 9px; margin-top: 11px; min-height: 24px; font-size: .77rem; color: var(--secondary); }
.speed-row output { text-align: right; font-variant-numeric: tabular-nums; }
.layers { display: flow-root; padding: 0; margin: 15px 0 0; min-width: 0; border: 0; border-top: 1px solid var(--line); }
.layers legend { padding: 0 8px 0 0; color: var(--ink); font-size: .86rem; font-weight: 640; }
.layer { min-height: 35px; display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 9px; color: var(--secondary); cursor: pointer; font-size: .81rem; }
.layer small { color: var(--muted); font-size: .69rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 9px color-mix(in srgb, var(--accent), transparent 55%); }
.d1 { --accent: var(--gold); }
.nakshatra { --accent: var(--indigo); }
.navamsha { --accent: var(--teal); }
.cycle { --accent: var(--lilac); }
.layer input {
  appearance: none;
  width: 31px;
  height: 18px;
  border-radius: 999px;
  margin: 0;
  border: 1px solid #73667e;
  background: #2e2939;
  display: grid;
  align-items: center;
  padding: 2px;
  cursor: pointer;
}
.layer input::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--secondary); }
.layer input:checked { background: color-mix(in srgb, var(--accent), #1c1727 76%); border-color: color-mix(in srgb, var(--accent), #1c1727 42%); }
.layer input:checked::before { background: var(--accent); justify-self: end; }
.repeat { display: flex; align-items: center; gap: 8px; color: var(--secondary); min-height: 34px; cursor: pointer; font-size: .79rem; }
.repeat input { accent-color: var(--teal); margin: 0; width: 16px; height: 16px; flex: none; }
.repeat small { margin-left: 4px; color: var(--teal); }
.readout, .details { margin-top: 31px; }
.readout h2, .details h2 { font-size: clamp(1.48rem, 3.65vw, 2rem); letter-spacing: -.03em; margin-bottom: 13px; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.metric { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 13px 11px 12px; background: #1a1924; font-variant-numeric: tabular-nums; }
.metric dt { color: var(--accent, var(--secondary)); font-size: .73rem; margin-bottom: 6px; }
.metric dd { font-size: clamp(.88rem, 1.45vw, 1.05rem); font-weight: 650; overflow-wrap: anywhere; }
.metric .metric-detail { margin-top: 4px; font-size: .72rem; font-weight: 400; color: var(--secondary); }
.detail-panel { margin-top: 10px; padding: 17px; background: #1a1924; border-radius: 13px; border: 1px solid var(--line); }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.detail-header h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 640; }
.detail-header p { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.tiles { display: grid; gap: 6px; }
.sign-tiles { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.pada-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cycle-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tile {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 3px;
  text-align: left;
  background: #211e2c;
  border-color: #3c3448;
  padding: 8px;
  overflow-wrap: anywhere;
}
.tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), #1c1727 84%);
}
.tile-symbol { color: var(--accent); font-size: 1.17rem; line-height: 1.15; }
.tile-ordinal, .tile-angle { color: var(--muted); font-size: .67rem; line-height: 1.35; }
.tile-name { font-size: .78rem; font-weight: 620; }
.cycle-navigation { display: flex; align-items: stretch; flex: none; gap: 5px; }
.cycle-navigation button { width: 38px; }
.cycle-navigation select { font-size: 16px; }
.principle { margin-top: 23px; border: 1px solid var(--line); background: #1a1924; border-radius: 13px; }
.principle summary { padding: 16px 17px; cursor: pointer; color: var(--ink); font-weight: 620; }
.principle summary::marker { color: var(--gold); }
.principle-body { padding: 0 17px 17px; max-width: 75ch; font-size: .9rem; line-height: 1.6; color: var(--secondary); }
.principle-body ul { padding-inline-start: 1.2rem; }
.formula { color: var(--gold); font: 1.12rem ui-monospace, Menlo, monospace; margin-block: 15px; }
.noscript { color: var(--gold); margin-top: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 980px) {
  .shell { width: calc(100% - 42px); }
  .console { padding-inline: 19px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sign-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 730px) {
  .shell { width: calc(100% - 28px); }
  .topbar-inner { min-height: 50px; }
  .top-link { font-size: .71rem; }
  .brand { gap: 6px; font-size: .85rem; }
  .brand img { width: 23px; height: 23px; }
  .intro { padding-block: 24px 17px; }
  h1 { font-size: clamp(2.52rem, 9.8vw, 4.5rem); }
  .intro p { margin-top: 9px; }
  .workspace { display: block; border-radius: 15px; }
  .observatory { padding: 4px 2px 13px; }
  .console { border-left: 0; border-top: 1px solid var(--line); padding: 18px 13px 14px; }
  .console h2 { margin-bottom: 13px; }
  .navigation button, .cycle-navigation button, .apply, .layer, .repeat { min-height: 44px; }
  .readout, .details { margin-top: 24px; }
  .metric { padding-inline: 8px; }
  .cycle-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pada-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-panel { padding: 12px; }
  .cycle-header { flex-wrap: wrap; }
  main.shell { padding-bottom: 36px; }
}
@media (max-width: 365px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { width: calc(100% - 20px); }
}
