:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: rgba(16, 19, 25, 0.82);
  --line: rgba(224, 197, 132, 0.44);
  --line-soft: rgba(255, 255, 255, 0.1);
  --text: #f6f2e8;
  --muted: #8d95a3;
  --subtle: #5c6470;
  --accent: #d8b66a;
  --blue: #8aa4ff;
  --red: #df837c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% -12%, rgba(138, 164, 255, 0.13), transparent 35%),
    linear-gradient(180deg, #0a0d12 0%, var(--bg) 44%, #050609 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(820px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 690px);
  gap: 5px;
  margin: 0 auto 14px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 17px;
  background: linear-gradient(180deg, rgba(21, 25, 33, 0.9), rgba(12, 15, 20, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 12px 32px rgba(0, 0, 0, 0.2);
}

.view-tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
  height: 48px;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.view-tab:hover:not(.is-active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.view-tab.is-active {
  color: var(--text);
  border-color: rgba(216, 182, 106, 0.34);
  background: linear-gradient(135deg, rgba(216, 182, 106, 0.2), rgba(216, 182, 106, 0.07));
  box-shadow: inset 0 1px 0 rgba(255, 235, 180, 0.09), 0 4px 16px rgba(0, 0, 0, 0.12);
}

.view-tab-icon {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(138, 164, 255, 0.18);
  border-radius: 10px;
  background: rgba(138, 164, 255, 0.08);
  color: var(--blue);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.view-tab.is-active .view-tab-icon {
  color: #f5dda0;
  border-color: rgba(216, 182, 106, 0.34);
  background: rgba(216, 182, 106, 0.14);
}

.view-tab-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.view-tab-copy strong {
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 880;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-tab-copy small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-tab.is-active .view-tab-copy small {
  color: rgba(244, 225, 173, 0.72);
}

.top-bar {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.top-bar[hidden], .mode-tabs[hidden], .timeline-panel[hidden], .birth-panel[hidden] { display: none; }

.birth-panel {
  width: min(690px, 100%);
  margin: 0 auto 8px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: rgba(16, 19, 25, 0.74);
}

.birth-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px 10px;
  align-items: end;
}

.birth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.birth-form input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  outline: none;
  background: rgba(7, 9, 13, 0.78);
  color: var(--text);
  color-scheme: dark;
  font-size: 13px;
}

.birth-form input:focus { border-color: var(--line); }
.birth-place { grid-column: 1 / 2; }
.birth-latitude { grid-column: 2 / 3; }
.birth-longitude { grid-column: 3 / 4; }
.birth-offset .field-hint {
  margin-top: -2px;
  color: var(--subtle);
  font-size: 10px;
}

.birth-submit {
  grid-column: 1 / -1;
  justify-self: end;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(216, 182, 106, 0.55);
  border-radius: 999px;
  background: var(--accent);
  color: #17140d;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.birth-status {
  margin: 9px 3px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dasha-panel { margin-top: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.dasha-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dasha-heading strong { color: var(--accent); font-size: 13px; }
.dasha-heading span { color: var(--muted); font-size: 11px; }
.dasha-results { display: grid; gap: 6px; }
.dasha-period { padding: 7px 9px; border-radius: 9px; background: rgba(255,255,255,.035); color: var(--text); font-size: 12px; }
.birth-submit:disabled { opacity: .65; cursor: wait; }

.icon-button, .date-button, .now-button, .lagna-picker select, .mode-tab {
  border: 1px solid var(--line-soft);
  background: rgba(19, 23, 30, 0.72);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.date-button {
  height: 38px;
  min-width: 0;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 760;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.lagna-picker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lagna-picker select {
  width: 48px;
  height: 34px;
  border-radius: 999px;
  color: var(--accent);
  font-weight: 850;
  text-align: center;
  outline: none;
}

.now-button {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: #17140d;
  background: var(--accent);
  border-color: rgba(216, 182, 106, 0.6);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.chart-stage {
  display: grid;
  place-items: center;
  min-height: min(86vw, 650px);
  padding: 10px 0 4px;
}

.chart-mount {
  display: grid;
  width: min(100%, 690px);
  aspect-ratio: 1;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01)),
    rgba(11, 14, 19, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: var(--shadow);
  padding: clamp(8px, 2vw, 18px);
}

.kundli-svg {
  display: block;
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.house-fill {
  fill: rgba(255, 255, 255, 0.005);
  stroke: none;
  transition: fill 190ms ease, filter 190ms ease;
}

.kundli-lines {
  stroke: var(--line);
  stroke-width: 0.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kundli-rashi-number {
  fill: rgba(216, 182, 106, 0.68);
  stroke: rgba(0, 0, 0, 0.75);
  stroke-width: 0.28;
  paint-order: stroke fill;
}

.kundli-planet-entry {
  cursor: pointer;
  pointer-events: all;
}

.kundli-planet-hit {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}

.kundli-planet-text {
  fill: #f6e7bd;
  stroke: #050609;
  stroke-width: 0.45;
  paint-order: stroke fill;
  cursor: pointer;
  pointer-events: all;
  transition: fill 180ms ease, filter 180ms ease;
}

.kundli-planet-text.is-selected {
  fill: #ffffff;
  filter: drop-shadow(0 0 2px rgba(216, 182, 106, 0.95));
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(13, 16, 22, 0.72);
}

.mode-tab {
  width: 36px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
  cursor: pointer;
}

.mode-tab.is-active {
  color: #14110a;
  background: var(--accent);
}

.drishti-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.draw-toggle {
  width: 36px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(19, 23, 30, 0.72);
  color: var(--muted);
  font-size: 17px;
  font-weight: 850;
  cursor: pointer;
}

.draw-toggle.is-active {
  color: #14110a;
  background: var(--blue);
  border-color: rgba(138, 164, 255, 0.55);
}

.drishti-toggle input {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line-soft);
  position: relative;
  cursor: pointer;
}

.drishti-toggle input::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #c4cad3;
  transition: transform 160ms ease, background 160ms ease;
}

.drishti-toggle input:checked::before {
  transform: translateX(18px);
  background: var(--blue);
}

.draw-toolbar {
  position: sticky;
  top: 8px;
  z-index: 8;
  display: flex;
  justify-content: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  width: min(690px, 100%);
  margin: -2px auto 8px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(18, 22, 29, 0.88);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
}

.draw-toolbar[hidden] { display: none; }
.draw-toolbar::-webkit-scrollbar { display: none; }

.draw-tool {
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  cursor: pointer;
}

.draw-tool.is-active {
  background: rgba(138, 164, 255, 0.18);
  color: #dce4ff;
}

.aspect-emoji {
  opacity: 0.9;
  pointer-events: none;
  stroke: rgba(5, 6, 9, 0.92);
  stroke-width: 0.32;
  paint-order: stroke fill;
  filter: drop-shadow(0 0 1.4px rgba(0, 0, 0, 0.8));
  transition: opacity 160ms ease, filter 160ms ease;
}

.annotation-layer {
  display: block;
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
  z-index: 2;
}

.annotation-layer.is-active {
  pointer-events: auto;
}

.annotation-stroke {
  fill: none;
  stroke: #f4e7bd;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.7));
}

.timeline.is-disabled {
  opacity: 0.54;
  pointer-events: none;
}

.timeline-panel {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 12px 0 14px;
}

.time-readout {
  text-align: center;
  margin-bottom: 8px;
}

.time-readout strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0;
}

.time-readout span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  position: relative;
  height: 84px;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.timeline:active { cursor: grabbing; }

.timeline-track {
  position: absolute;
  inset: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 42px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.13), transparent);
}

.playhead {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(216, 182, 106, 0.48);
  pointer-events: none;
}

.playhead::after {
  content: "";
  position: absolute;
  left: -4px;
  top: 38px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-tick, .event-marker {
  position: absolute;
  transform: translateX(-50%);
  border: 0;
  background: transparent;
  color: var(--subtle);
  cursor: pointer;
}

.timeline-tick {
  top: 34px;
  width: 1px;
  height: 16px;
  padding: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.13);
}

.timeline-tick span {
  position: absolute;
  top: 19px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 48px;
  color: #7d8490;
  font-size: 11px;
  font-weight: 720;
}

.event-marker {
  top: 7px;
  max-width: 72px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(138, 164, 255, 0.13);
  border: 1px solid rgba(138, 164, 255, 0.25);
  color: #cbd5ff;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.event-marker.station {
  background: rgba(223, 131, 124, 0.14);
  border-color: rgba(223, 131, 124, 0.26);
  color: #ffd0ca;
}

.event-marker.combustion {
  background: rgba(216, 182, 106, 0.13);
  border-color: rgba(216, 182, 106, 0.28);
  color: #f4e1ad;
}

.planet-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: 520px;
  margin: 0 auto;
  padding: 15px 44px 15px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(18, 22, 29, 0.9);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
}

.sheet-close {
  position: absolute;
  right: 10px;
  top: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
  cursor: pointer;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.sheet-head strong {
  font-size: 18px;
  letter-spacing: 0;
}

.sheet-head span, .sheet-meta {
  color: var(--muted);
  font-size: 13px;
}

.sheet-longitude {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 820;
}

.sheet-pill {
  display: inline-flex;
  margin-top: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(216, 182, 106, 0.13);
  color: #f2d895;
  font-size: 12px;
  font-weight: 820;
}

.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.engine-missing {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
}

.chart-placeholder {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 460px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .top-bar { grid-template-columns: 34px minmax(0, 1fr) 34px auto auto; gap: 6px; }
  .icon-button { width: 34px; height: 34px; }
  .date-button { height: 36px; font-size: 13px; padding: 0 8px; }
  .lagna-picker span { display: none; }
  .lagna-picker select { width: 44px; height: 32px; }
  .now-button { height: 32px; padding: 0 10px; font-size: 11px; }
  .chart-stage { min-height: calc(100vw - 20px); padding-top: 6px; }
  .chart-mount { border-radius: 18px; padding: 7px; }
  .planet-sheet { left: 10px; right: 10px; }
  .draw-toolbar { justify-content: flex-start; gap: 4px; }
  .draw-tool { height: 28px; padding: 0 9px; font-size: 11px; }
  .view-tabs { margin-bottom: 10px; }
  .view-tab { height: 44px; gap: 8px; padding: 4px 8px; }
  .view-tab-icon { flex-basis: 29px; width: 29px; height: 29px; border-radius: 9px; }
  .view-tab-copy strong { font-size: 11px; }
  .view-tab-copy small { font-size: 9px; }
  .birth-panel { padding: 10px; }
  .birth-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .birth-date, .birth-time, .birth-offset, .birth-place, .birth-latitude, .birth-longitude { grid-column: auto; }
  .birth-offset .field-hint { margin-top: -2px; }
  .birth-submit { grid-column: 1 / -1; justify-self: stretch; }
}

@media (min-width: 760px) {
  .app-shell { padding-top: 18px; }
  .control-strip, .timeline-panel { width: min(690px, 100%); margin-left: auto; margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
