:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --rail: #101419;
  --panel: #151a20;
  --panel-2: #1b222a;
  --ink: #eef4f8;
  --muted: #94a3b8;
  --line: #2a3440;
  --accent: #24c8a0;
  --accent-2: #4aa3ff;
  --warn: #f7b955;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(11, 13, 16, 0.92);
}

.login-screen.hidden { display: none; }

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #ff9b9b;
  font-size: 13px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.link-button.active,
.link-button:hover {
  color: var(--accent);
}

.auth-reset-fields {
  display: grid;
  gap: 10px;
}

.rail {
  min-height: 100vh;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: var(--rail);
}

.brand {
  display: grid;
  gap: 2px;
  margin-bottom: 26px;
}

.brand strong {
  font-size: 22px;
  letter-spacing: 0;
}

.brand span {
  color: var(--accent);
  font-size: 13px;
}

.nav {
  width: 100%;
  display: block;
  margin: 4px 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.nav.active,
.nav:hover {
  color: #ffffff;
  border-color: var(--line);
  background: #1b232c;
}

main {
  padding: 28px;
  max-width: 1440px;
  width: 100%;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 { font-size: 30px; }
h2 { font-size: 17px; margin-bottom: 12px; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}

.ghost-button {
  min-height: 40px;
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.view { display: none; }
.view.active { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric,
.columns > section,
.item,
.panel-form,
.derived-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric { padding: 16px; }

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.columns {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
}

.columns.spaced { margin-top: 16px; }

.onboarding-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.chat-panel {
  display: grid;
  gap: 14px;
  min-height: 620px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.progress-head strong {
  font-size: 24px;
  color: var(--accent);
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #0f141a;
  border: 1px solid var(--line);
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease;
}

.chat-hint {
  margin: 0;
  color: var(--muted);
}

.chat-thread {
  min-height: 360px;
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f141a;
}

.chat-bubble {
  max-width: min(680px, 86%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.chat-bubble.user {
  align-self: flex-end;
  background: #17352f;
  border-color: #246b5d;
}

.chat-bubble.assistant {
  align-self: flex-start;
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.columns > section,
.panel-form,
.derived-panel {
  padding: 16px;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li,
.item {
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.list li:first-child,
.item:first-child { border-top: 0; }

.stack {
  display: grid;
  gap: 10px;
}

.item {
  padding: 13px 14px;
  background: var(--panel-2);
}

.item .meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.check-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--accent);
}

.check-row span {
  display: grid;
}

.inline-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 16px;
}

.photo-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.panel-form,
.goal-form {
  display: grid;
  gap: 18px;
}

dialog {
  max-width: 420px;
  width: calc(100% - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.7); }

.dialog-body {
  display: grid;
  gap: 14px;
}

.pairing-code {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f141a;
  font-size: 30px;
  letter-spacing: 6px;
  text-align: center;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: #0f141a;
  color: var(--ink);
}

textarea { resize: vertical; }

button {
  color: #06110e;
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button.primary {
  justify-self: start;
  min-width: 180px;
}

.goal-form {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  .rail {
    min-height: auto;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 12px;
  }
  .brand { margin: 0 12px 0 0; min-width: 116px; }
  .nav { width: auto; white-space: nowrap; }
  main { padding: 18px; }
  .metric-grid,
  .columns,
  .onboarding-shell,
  .inline-form,
  .photo-form,
  .chat-input,
  .settings-grid,
  .form-grid.two,
  .form-grid.four {
    grid-template-columns: 1fr;
  }
}
