:root {
  color-scheme: dark;
  --bg: #05080d;
  --bg-soft: #080d14;
  --panel: rgba(12, 18, 28, 0.88);
  --panel-strong: #0e151f;
  --surface: #121b27;
  --surface-2: #162130;
  --line: rgba(137, 164, 204, 0.22);
  --line-strong: rgba(216, 173, 88, 0.35);
  --text: #edf4ff;
  --muted: #91a3bb;
  --faint: #58687d;
  --blue: #6fa7ff;
  --cyan: #72e4ff;
  --gold: #d8ad58;
  --orange: #c66c36;
  --green: #72d59b;
  --violet: #a688ff;
  --rose: #e37a8e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(114, 228, 255, 0.08), transparent 28rem),
    radial-gradient(circle at 84% 12%, rgba(216, 173, 88, 0.08), transparent 26rem),
    linear-gradient(135deg, #05080d 0%, #081018 45%, #07080c 100%);
  color: var(--text);
  font-family: var(--font);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button,
a,
input,
textarea {
  outline-color: var(--cyan);
  outline-offset: 3px;
}

.app-shell {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(140px, 0.65fr);
  gap: 16px;
  align-items: center;
  min-height: 70px;
  padding: 10px 0 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(216, 173, 88, 0.56);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(216, 173, 88, 0.88) 0 3px, transparent 4px),
    conic-gradient(from 120deg, rgba(114, 228, 255, 0.92), rgba(216, 173, 88, 0.9), rgba(198, 108, 54, 0.8), rgba(114, 228, 255, 0.92));
  box-shadow: 0 0 34px rgba(216, 173, 88, 0.16);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(5, 8, 13, 0.9);
  border-radius: 50%;
  background: var(--bg);
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 1.05rem;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.topnav {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 13, 20, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.nav-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.nav-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-button.is-active {
  background: rgba(216, 173, 88, 0.16);
  color: #f3d99d;
}

.session-chip {
  justify-self: end;
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 21, 31, 0.7);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.session-chip span:first-child {
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.95rem;
}

main {
  min-height: calc(100vh - 138px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.practice-grid {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(420px, 1fr) minmax(300px, 360px);
  gap: 14px;
  min-height: calc(100vh - 160px);
}

.wide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 14px;
  min-height: calc(100vh - 160px);
}

.library-layout {
  min-height: calc(100vh - 160px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14, 21, 31, 0.91), rgba(8, 13, 20, 0.88));
  box-shadow: var(--shadow);
}

.practice-panel,
.insight-panel,
.map-detail,
.card-preview-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.panel-heading h1,
.panel-heading h2,
.library-heading h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  line-height: 1.08;
}

.panel-heading p,
.library-heading p,
.map-detail p,
.app-footer p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.section-number {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
}

.phase-stack {
  display: grid;
  gap: 8px;
}

.phase-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(137, 164, 204, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.phase-row:hover {
  border-color: rgba(137, 164, 204, 0.36);
}

.phase-row.is-active {
  border-color: rgba(216, 173, 88, 0.55);
  background: rgba(216, 173, 88, 0.08);
}

.phase-row strong,
.phase-row small {
  display: block;
  min-width: 0;
}

.phase-row strong {
  font-size: 0.88rem;
}

.phase-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.3;
}

.phase-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 18px currentColor;
}

.phase-inhale {
  color: var(--cyan);
  background: var(--cyan);
}

.phase-pause {
  color: var(--gold);
  background: var(--gold);
}

.phase-exhale {
  color: var(--orange);
  background: var(--orange);
}

.phase-rest {
  color: var(--green);
  background: var(--green);
}

.phase-count {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.86rem;
  text-align: right;
}

.control-group {
  margin-top: 18px;
}

.control-group label,
.note-label {
  display: block;
  margin-bottom: 8px;
  color: #d8e6f8;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 10px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

output {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: right;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.icon-action,
.choice-grid button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.primary-action {
  flex: 1;
  padding: 0 16px;
  background: linear-gradient(135deg, #e0b85f, #c66c36);
  color: #110b05;
  box-shadow: 0 14px 34px rgba(198, 108, 54, 0.22);
}

.primary-action:hover {
  filter: brightness(1.06);
}

.secondary-action {
  flex: 1;
  padding: 0 14px;
  border: 1px solid rgba(114, 228, 255, 0.3);
  background: rgba(114, 228, 255, 0.08);
  color: #bff3ff;
}

.secondary-action:hover {
  background: rgba(114, 228, 255, 0.14);
}

.icon-action {
  flex: 0 0 42px;
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.icon-action:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.icon-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.orbit-stage {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid rgba(137, 164, 204, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(137, 164, 204, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137, 164, 204, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 45%, rgba(114, 228, 255, 0.09), transparent 24rem),
    linear-gradient(180deg, #050a11 0%, #07101a 58%, #05080d 100%);
  background-size: 54px 54px, 54px 54px, auto, auto;
  box-shadow: var(--shadow), inset 0 0 70px rgba(0, 0, 0, 0.36);
}

#orbitCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-overlay {
  pointer-events: none;
  position: absolute;
  inset: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.phase-readout {
  width: min(420px, 100%);
  padding: 12px 14px;
  border-left: 2px solid var(--gold);
  background: linear-gradient(90deg, rgba(5, 8, 13, 0.68), rgba(5, 8, 13, 0));
}

.phase-readout span,
.prompt-meta span,
.microcopy {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.phase-readout strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: clamp(1.15rem, 2.4vw, 2rem);
  line-height: 1.05;
}

.cycle-meter {
  width: min(620px, 72%);
  height: 4px;
  overflow: hidden;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.cycle-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--orange), var(--green));
}

.polarity-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.polarity-button {
  min-height: 54px;
  padding: 9px;
  border: 1px solid rgba(137, 164, 204, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.polarity-button:hover {
  border-color: rgba(114, 228, 255, 0.35);
  color: var(--text);
}

.polarity-button.is-active {
  border-color: rgba(114, 228, 255, 0.48);
  background: rgba(114, 228, 255, 0.08);
  color: var(--text);
}

.polarity-button strong,
.polarity-button small {
  display: block;
}

.polarity-button strong {
  font-size: 0.8rem;
  line-height: 1.25;
}

.polarity-button small {
  margin-top: 4px;
  color: var(--faint);
  font-size: 0.68rem;
}

.prompt-card {
  margin: 16px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
}

.prompt-meta span:first-child {
  color: var(--cyan);
}

.prompt-card p {
  margin: 13px 0 0;
  color: #dce8f8;
  font-size: 1rem;
  line-height: 1.55;
}

textarea {
  width: 100%;
  min-height: 126px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 8, 13, 0.72);
  color: var(--text);
  line-height: 1.5;
}

textarea::placeholder {
  color: #65768b;
}

.map-panel,
.journal-panel {
  padding: 22px;
}

.mandala {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(137, 164, 204, 0.16);
  border-radius: var(--radius);
  background:
    radial-gradient(circle, transparent 0 10%, rgba(216, 173, 88, 0.12) 10.2% 10.7%, transparent 11% 24%, rgba(114, 228, 255, 0.12) 24.2% 24.6%, transparent 25% 42%, rgba(137, 164, 204, 0.12) 42.2% 42.6%, transparent 43%),
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(137, 164, 204, 0.22) 50%, transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), rgba(137, 164, 204, 0.22) 50%, transparent calc(50% + 1px)),
    radial-gradient(circle at center, #0d1824 0%, #070b12 72%);
}

.map-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 132px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid rgba(137, 164, 204, 0.18);
  border-radius: var(--radius);
  background: rgba(5, 8, 13, 0.78);
  color: var(--muted);
  cursor: pointer;
  transform: translate(-50%, -50%);
  text-align: center;
}

.map-node:hover,
.map-node.is-active {
  border-color: rgba(216, 173, 88, 0.58);
  color: var(--text);
}

.map-node.is-active {
  background: rgba(216, 173, 88, 0.12);
}

.map-node strong {
  display: block;
  font-size: 0.72rem;
  line-height: 1.25;
}

.map-node small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 0.64rem;
}

.map-detail h2,
.card-preview-panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 18px;
}

.choice-grid button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.choice-grid button:hover,
.choice-grid button.is-active {
  border-color: rgba(114, 228, 255, 0.46);
  background: rgba(114, 228, 255, 0.1);
}

.microcopy {
  margin-top: 18px;
  color: var(--green);
  text-transform: none;
  letter-spacing: 0;
}

.journal-list {
  display: grid;
  gap: 10px;
}

.empty-state,
.journal-entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  line-height: 1.6;
}

.journal-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
}

.journal-entry h3 {
  margin: 0 0 6px;
  font-size: 0.96rem;
}

.journal-entry p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.journal-entry time {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.entry-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-action {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.text-action:hover {
  color: var(--text);
  border-color: rgba(216, 173, 88, 0.45);
}

#cardCanvas {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  margin-top: 14px;
  border: 1px solid rgba(137, 164, 204, 0.22);
  border-radius: var(--radius);
  background: #070b12;
}

.library-heading {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.symbol-card {
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14, 21, 31, 0.9), rgba(8, 13, 20, 0.82));
}

.symbol-card strong {
  display: block;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.96rem;
}

.symbol-card h2 {
  margin: 16px 0 8px;
  font-size: 1rem;
}

.symbol-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.app-footer {
  padding: 18px 2px 0;
}

.app-footer p {
  max-width: 1060px;
  font-size: 0.76rem;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topnav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .session-chip {
    justify-self: start;
  }

  .practice-grid,
  .wide-layout {
    grid-template-columns: 1fr;
  }

  .practice-grid {
    min-height: auto;
  }

  .orbit-stage {
    order: -1;
    min-height: 560px;
  }

  .practice-panel,
  .insight-panel {
    display: grid;
    align-content: start;
  }

  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    gap: 10px;
    padding-bottom: 12px;
  }

  .brand small {
    white-space: normal;
  }

  .topnav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .nav-button {
    min-height: 38px;
    padding: 0 7px;
    font-size: 0.74rem;
  }

  .orbit-stage {
    min-height: 480px;
  }

  .stage-overlay {
    inset: 12px;
  }

  .cycle-meter {
    width: 100%;
  }

  .phase-readout {
    width: 100%;
  }

  .panel-heading,
  .library-heading {
    gap: 10px;
  }

  .practice-panel,
  .insight-panel,
  .map-panel,
  .journal-panel,
  .map-detail,
  .card-preview-panel {
    padding: 14px;
  }

  .polarity-list,
  .library-grid {
    grid-template-columns: 1fr;
  }

  .stacked-mobile {
    flex-direction: column;
  }

  .stacked-mobile > * {
    width: 100%;
  }

  .mandala {
    min-height: 560px;
  }

  .map-node {
    width: 112px;
  }

  .journal-entry {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
