:root {
  color-scheme: dark;
  --bg: #070806;
  --bg-elevated: #10110e;
  --bg-panel: #171814;
  --text: #f4f1ea;
  --muted: #aaa69a;
  --soft: #d7d1c4;
  --line: rgba(244, 241, 234, 0.12);
  --line-strong: rgba(244, 241, 234, 0.22);
  --accent: #d7b46a;
  --accent-2: #86b8a5;
  --danger: #df8f7f;
  --radius: 8px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
}

body {
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
  color: var(--text);
  font-family: var(--font-ui);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  padding: 16px;
  line-height: 1.55;
}

textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 56px);
  background: rgba(7, 8, 6, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand,
.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border: 1px solid var(--accent);
  transform: rotate(45deg);
}

.topnav {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link,
.button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  padding: 10px 14px;
}

.nav-link-primary,
.button-primary {
  border-color: rgba(215, 180, 106, 0.55);
  background: var(--accent);
  color: #17130a;
  font-weight: 700;
}

.button-secondary {
  color: var(--soft);
}

.view {
  padding: clamp(24px, 5vw, 72px);
}

.is-hidden {
  display: none !important;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 520px);
  gap: clamp(28px, 6vw, 80px);
  align-items: center;
  min-height: calc(100dvh - 140px);
}

.hero-copy h1,
.auth-panel h1,
.session-header h1 {
  max-width: 760px;
  font-family: var(--font-serif);
  font-size: clamp(44px, 7vw, 92px);
  line-height: 0.98;
  letter-spacing: 0;
}

.session-header h1 {
  font-size: clamp(28px, 4vw, 48px);
}

.hero-body,
.auth-panel p,
.microcopy {
  color: var(--muted);
  line-height: 1.65;
}

.hero-body {
  max-width: 660px;
  margin-top: 24px;
  font-size: 20px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.boundary-line {
  width: fit-content;
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--soft);
  padding: 10px 12px;
}

.entry-panel,
.auth-panel,
.session-form,
.result-panel,
.lens-panel,
.side-rail,
.steps-band article,
.boundary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
  box-shadow: var(--shadow);
}

.entry-panel,
.auth-panel,
.session-form,
.result-panel,
.lens-panel {
  padding: clamp(18px, 3vw, 28px);
}

.entry-panel label,
.session-form label {
  display: block;
  margin-bottom: 12px;
  color: var(--soft);
  font-weight: 700;
}

.entry-actions,
.auth-actions,
.form-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

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

.steps-band article {
  padding: 20px;
}

.steps-band span {
  color: var(--accent);
  font-family: var(--font-serif);
}

.steps-band h2 {
  margin-top: 12px;
  font-size: 18px;
}

.steps-band p {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.55;
}

.login-view {
  min-height: calc(100dvh - 80px);
  display: grid;
  place-items: center;
}

.auth-panel {
  max-width: 620px;
}

.auth-panel p {
  margin-top: 18px;
}

.app-view {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.side-rail,
.lens-panel {
  position: sticky;
  top: 88px;
}

.side-rail {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.rail-item {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 12px;
  text-align: left;
}

.rail-item.is-active {
  border-color: var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.session-column {
  display: grid;
  gap: 18px;
}

.session-header {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--accent-2);
  padding: 8px 10px;
  font-size: 13px;
}

.example-row,
.lens-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.example-chip,
.lens-option {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  color: var(--soft);
  padding: 8px 10px;
}

.lens-options {
  display: grid;
}

.lens-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.35;
}

.boundary-card {
  margin-top: 18px;
  padding: 16px;
}

.boundary-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.result-panel.is-empty,
.result-panel.is-loading,
.result-panel.is-error {
  color: var(--muted);
}

.empty-state,
.loading-stack {
  min-height: 180px;
  display: grid;
  align-content: center;
  gap: 12px;
}

.loading-stack p {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.result-panel.is-error {
  border-color: rgba(223, 143, 127, 0.4);
}

.map-artifact {
  display: grid;
  gap: 20px;
}

.artifact-header h2 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
}

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

.map-grid section,
.lens-readings section,
.closing-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  padding: 16px;
}

.map-grid .wide {
  grid-column: 1 / -1;
}

.map-grid h3,
.lens-readings h3 {
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 8px;
}

.map-grid p,
.lens-readings p,
.closing-block p {
  color: var(--soft);
  line-height: 1.6;
}

.lens-readings {
  display: grid;
  gap: 12px;
}

.lens-readings p + p,
.closing-block p + p {
  margin-top: 10px;
}

@media (max-width: 1040px) {
  .hero-grid,
  .app-view {
    grid-template-columns: 1fr;
  }

  .side-rail,
  .lens-panel {
    position: static;
  }

  .side-rail {
    display: flex;
    overflow-x: auto;
  }
}

@media (max-width: 720px) {
  .topbar,
  .session-header,
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav {
    justify-content: flex-start;
  }

  .view {
    padding: 18px;
  }

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

  .steps-band,
  .map-grid {
    grid-template-columns: 1fr;
  }
}
