:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #202323;
  --muted: #69706d;
  --line: #d9d4ca;
  --panel: #fffdf8;
  --accent: #276b5f;
  --accent-2: #c74e32;
  --accent-3: #2f5f98;
  --soft: #e8eee7;
  --shadow: 0 18px 50px rgba(43, 39, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
textarea,
input {
  font: inherit;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #173f39;
}

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

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin-bottom: 18px;
}

.auth-card input,
.tool-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.auth-card .primary {
  width: 100%;
  margin-top: 16px;
}

.auth-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--accent-2);
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.mobile-nav {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 32px;
  background: #173f39;
  color: #fffdf8;
}

.eyebrow,
.today {
  margin: 0 0 8px;
  color: #d7b76d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 0.98;
  letter-spacing: 0;
}

.lead {
  color: rgba(255, 253, 248, 0.78);
  line-height: 1.55;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-btn,
.ghost,
.primary,
.secondary {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-btn {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fffdf8;
  text-align: left;
}

.nav-btn.active,
.nav-btn:hover {
  background: #fffdf8;
  color: #173f39;
}

.score-panel {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.score-panel span {
  color: rgba(255, 253, 248, 0.75);
}

.score-panel strong {
  display: block;
  margin: 8px 0 12px;
  font-size: 34px;
}

.usage-line {
  margin: 10px 0 0;
  color: rgba(255, 253, 248, 0.75);
  font-size: 12px;
}

.usage-line b {
  color: #fffdf8;
}

.meter {
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 99px;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: #d7b76d;
  transition: width 0.2s ease;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0;
}

.ghost {
  padding: 0 16px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.panel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel.active {
  display: block;
}

.section-intro {
  max-width: 760px;
  margin-bottom: 24px;
}

.section-intro h3 {
  margin-bottom: 8px;
  font-size: 24px;
}

.section-intro p,
label {
  color: var(--muted);
  line-height: 1.5;
}

.truth-box {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #d9b15e;
  border-radius: 8px;
  background: #fff6df;
}

.truth-box.compact {
  margin-top: -8px;
}

.truth-box strong {
  display: block;
  margin-bottom: 4px;
  color: #5f4613;
}

.truth-box p {
  margin: 0;
  color: #3b3526;
  line-height: 1.45;
}

.question-grid,
.weeks,
.review-grid,
.checkin-grid,
.goal-grid,
.decision-grid,
.focus-grid,
.daily-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.decision-panel,
.focus-panel {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.focus-grid input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.focus-timer {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f1;
  color: #173f39;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.daily-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.daily-metrics input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.coach-shell {
  display: grid;
  gap: 14px;
}

.coach-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
  max-height: 52vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f5ef;
}

.message {
  max-width: min(760px, 92%);
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.usage-meta {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.message.user .usage-meta {
  color: rgba(255, 255, 255, 0.72);
}

.message.coach {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-3);
  cursor: pointer;
  font-weight: 750;
}

.deep-button {
  min-height: 48px;
  border: 1px solid #d9b15e;
  border-radius: 8px;
  background: #2f5f98;
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.deep-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.voice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.voice-toggle {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.voice-toggle input {
  margin-right: 8px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: end;
}

.chat-form textarea {
  min-height: 82px;
}

.knowledge-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.knowledge-strip span {
  padding: 8px 10px;
  border-radius: 8px;
  background: #e9eef1;
  color: #33444c;
  font-size: 13px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 750;
}

textarea {
  min-height: 130px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 107, 95, 0.16);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.primary,
.secondary {
  padding: 0 18px;
  font-weight: 850;
}

.primary {
  background: var(--accent);
  color: #fff;
}

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

.primary:hover,
.secondary:hover,
.ghost:hover {
  transform: translateY(-1px);
}

.vector-list {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.vector-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(4, minmax(76px, 116px)) 42px;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.vector-item input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.vector-item label {
  gap: 5px;
  font-size: 12px;
}

.remove {
  min-height: 40px;
  border: 1px solid #efc5bc;
  background: #fff4f0;
  color: var(--accent-2);
  border-radius: 8px;
  cursor: pointer;
}

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

.check {
  display: flex;
  align-items: center;
  min-height: 62px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.check input {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  accent-color: var(--accent);
}

.wide-label {
  margin-top: 18px;
}

.review-grid article {
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-grid h4 {
  margin-bottom: 10px;
  color: var(--accent-3);
}

.review-grid p,
.review-grid li {
  color: var(--ink);
  line-height: 1.55;
}

.export-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.daily-history,
.weekly-output,
.search-results,
.insights-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.history-item,
.weekly-card,
.search-item,
.insight-item,
.tool-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history-item h4,
.weekly-card h4 {
  margin-bottom: 6px;
  color: var(--accent-3);
}

.history-item p,
.weekly-card p,
.search-item p,
.insight-item p,
.tool-card p {
  margin-bottom: 0;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.neuro-hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.neuro-status-card {
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.neuro-status-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.neuro-status-card strong {
  display: block;
  margin: 10px 0;
  color: var(--accent);
  font-size: 26px;
  line-height: 1.1;
}

.neuro-status-card p {
  color: var(--ink);
  line-height: 1.5;
}

.neuro-bars,
.learning-loop {
  display: grid;
  gap: 10px;
}

.neuro-bar {
  display: grid;
  gap: 6px;
}

.neuro-bar div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e5e0d7;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.loop-step {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.loop-step h4 {
  margin-bottom: 6px;
  color: var(--accent-3);
}

.loop-step p {
  margin-bottom: 0;
}

.tool-card h4 {
  margin-bottom: 12px;
  color: var(--accent-3);
}

.tool-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stack-actions,
.reminder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent);
  cursor: pointer;
  font-weight: 850;
}

.file-button input {
  display: none;
}

canvas {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

pre {
  overflow: auto;
  min-height: 150px;
  margin: 14px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1d2321;
  color: #f8f3e8;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  body {
    padding-bottom: 78px;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: auto;
    padding: 16px 20px;
  }

  .sidebar h1 {
    margin-bottom: 6px;
    font-size: 28px;
    line-height: 1.05;
  }

  .sidebar .lead,
  .sidebar .nav {
    display: none;
  }

  .score-panel {
    margin-top: 0;
    padding: 10px 12px;
  }

  .score-panel strong {
    display: inline;
    margin: 0 0 0 8px;
    font-size: 18px;
  }

  .score-panel .meter {
    margin-top: 8px;
  }

  .usage-line {
    margin-top: 6px;
  }

  .mobile-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(23, 63, 57, 0.18);
    border-radius: 12px;
    background: rgba(255, 253, 248, 0.94);
    box-shadow: 0 14px 34px rgba(32, 35, 35, 0.2);
    backdrop-filter: blur(14px);
  }

  .mobile-nav-btn {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 850;
  }

  .mobile-nav-btn.active {
    background: var(--accent);
    color: #fff;
  }

  .question-grid,
  .weeks,
  .review-grid,
  .checkin-grid,
  .goal-grid,
  .decision-grid,
  .focus-grid,
  .daily-metrics,
  .neuro-hero,
  .tool-grid,
  .protocol-grid {
    grid-template-columns: 1fr;
  }

  .vector-item {
    grid-template-columns: 1fr 1fr;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .remove {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  body {
    background: var(--panel);
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  .workspace {
    padding-bottom: 10px;
  }

  .panel {
    min-height: calc(100vh - 190px);
    padding: 16px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: row;
    margin-bottom: 14px;
  }

  .topbar h2 {
    font-size: 22px;
    line-height: 1.12;
  }

  .today {
    margin-bottom: 5px;
    font-size: 11px;
  }

  .ghost {
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .section-intro {
    margin-bottom: 16px;
  }

  .section-intro h3 {
    font-size: 20px;
    line-height: 1.15;
  }

  .section-intro p {
    font-size: 14px;
  }

  textarea,
  .chat-form textarea {
    min-height: 112px;
    font-size: 16px;
  }

  .daily-metrics input {
    min-height: 46px;
    font-size: 16px;
  }

  .primary,
  .secondary,
  .deep-button,
  .file-button {
    width: 100%;
    min-height: 48px;
  }

  .actions {
    flex-direction: column;
    justify-content: stretch;
  }

  .vector-item {
    grid-template-columns: 1fr;
  }

  .vector-item input {
    min-height: 46px;
    font-size: 16px;
  }

  .coach-thread {
    min-height: calc(100vh - 420px);
    max-height: calc(100vh - 330px);
    padding: 10px;
  }

  .message {
    max-width: 96%;
    padding: 12px;
    font-size: 15px;
  }

  .prompt-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .prompt-chip {
    min-height: 42px;
    padding: 0 8px;
    font-size: 12px;
  }

  .chat-form {
    gap: 8px;
  }

  .knowledge-strip {
    display: none;
  }

  .voice-row,
  .stack-actions,
  .reminder-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .check {
    min-height: 54px;
    padding: 12px;
  }

  .review-grid article {
    min-height: 0;
    padding: 14px;
  }

  pre {
    max-height: 280px;
    font-size: 12px;
  }
}
