:root {
  --paper: #0f1512;
  --surface: #17211d;
  --surface-strong: #22342d;
  --ink: #f3f0e8;
  --muted: #aab8af;
  --line: #34463d;
  --green: #9dc8aa;
  --green-strong: #244f42;
  --sage: #789b7b;
  --gold: #d5ad58;
  --terracotta: #dfa079;
  --cream: #fff3d4;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.36);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

[data-theme="light"] {
  --paper: #fbf8f1;
  --surface: #fffdf8;
  --surface-strong: #f2eadb;
  --ink: #1f2a24;
  --muted: #6c7569;
  --line: #ded4c2;
  --green: #245447;
  --green-strong: #245447;
  --sage: #8baa80;
  --gold: #c29a43;
  --terracotta: #a96144;
  --cream: #fff8e8;
  --shadow: 0 16px 40px rgba(36, 84, 71, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(157, 200, 170, 0.18), transparent 340px),
    linear-gradient(180deg, rgba(213, 173, 88, 0.08), transparent 320px),
    var(--paper);
}

[data-theme="light"] body {
  background:
    linear-gradient(180deg, rgba(139, 170, 128, 0.18), transparent 280px),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.topbar,
.panel-heading,
.metric-top,
.timer-card,
.timeline-item,
.task-row,
.habit-row,
.focus-strip,
.tabs {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--terracotta);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  font-size: 1.85rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.focus-strip {
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  margin-bottom: 14px;
  color: var(--cream);
  background: linear-gradient(135deg, #182a24, #244f42 58%, #7b5d25);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

[data-theme="light"] .focus-strip {
  background: linear-gradient(135deg, #245447, #496f50 60%, #9a7332);
}

.focus-strip .section-kicker {
  color: #f1d59b;
}

.score-pill {
  min-width: 88px;
  min-height: 76px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 248, 232, 0.32);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
}

.score-pill span {
  font-size: 1.35rem;
  font-weight: 800;
}

.score-pill small {
  display: block;
  margin-top: -10px;
  color: rgba(255, 248, 232, 0.8);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 12px;
  background: linear-gradient(180deg, var(--paper) 70%, rgba(15, 21, 18, 0));
}

[data-theme="light"] .tabs {
  background: linear-gradient(180deg, var(--paper) 70%, rgba(251, 248, 241, 0));
}

.tab {
  min-width: 112px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}

.tab.active {
  color: var(--cream);
  border-color: var(--green-strong);
  background: var(--green-strong);
}

.tab svg,
button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 164px;
  padding: 13px;
}

.metric-top {
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 14px 0 10px;
  font-size: 1.45rem;
}

progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
}

progress::-webkit-progress-bar {
  background: var(--surface-strong);
}

progress::-webkit-progress-value {
  background: var(--green);
  border-radius: 999px;
}

.stepper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
}

.stepper button,
.text-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--green);
  background: var(--surface-strong);
  font-weight: 800;
}

[data-theme="light"] .stepper button,
[data-theme="light"] .text-button {
  background: var(--cream);
}

.panel {
  padding: 16px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading > span {
  color: var(--green);
  font-weight: 800;
}

.timer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.timer-card {
  justify-content: space-between;
  gap: 12px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.timer-card p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.timer-card strong {
  font-size: 1.7rem;
}

.timer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 142px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  color: #fdf8ec;
  background: var(--green-strong);
}

.icon-button.quiet {
  color: var(--green);
  border-color: var(--line);
  background: var(--surface);
}

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

.timeline-item {
  gap: 10px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.timeline-time {
  width: 92px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
}

.timeline-title {
  flex: 1;
  min-width: 0;
}

.timeline-title strong,
.timeline-title span {
  display: block;
}

.timeline-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.85rem;
}

input[type="checkbox"] {
  width: 21px;
  height: 21px;
  accent-color: var(--green-strong);
}

.task-list,
.habit-list,
.journal-grid,
.settings-grid,
.history-stats,
.history-list {
  display: grid;
  gap: 10px;
}

.task-row,
.habit-row {
  gap: 10px;
  align-items: flex-start;
  min-height: 52px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.task-row input[type="checkbox"] {
  margin-top: 9px;
}

.task-row textarea {
  flex: 1;
  min-width: 0;
  height: auto;
  min-height: 60px;
  margin-top: 0;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  overflow: hidden;
  line-height: 1.35;
  font-weight: 800;
}

.habit-row span {
  flex: 1;
}

label,
.field-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input[type="time"],
input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  outline: 0;
}

input[type="time"],
input[type="password"],
input[type="text"] {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 86px;
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.45;
}

textarea:focus,
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 84, 71, 0.13);
}

.primary-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  color: #fdf8ec;
  background: var(--green-strong);
  font-weight: 800;
}

.coach-note {
  margin-top: 12px;
  padding: 13px;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(213, 173, 88, 0.13);
  line-height: 1.5;
  white-space: pre-wrap;
}

[data-theme="light"] .coach-note {
  background: #fff4d8;
}

.small-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
}

.status-note {
  min-height: 20px;
  margin-top: 10px;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 800;
}

.history-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.history-stat,
.history-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-stat {
  min-height: 86px;
  padding: 12px;
}

.history-stat span,
.history-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.history-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
}

.history-card {
  padding: 12px;
}

.history-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-card h3 {
  margin: 0;
  font-size: 1rem;
}

.history-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.history-metrics div {
  min-height: 58px;
  padding: 9px;
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.history-metrics strong {
  display: block;
  margin-top: 4px;
}

.deploy-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.complete-text {
  color: var(--muted);
  text-decoration: line-through;
}

@media (min-width: 780px) {
  .app-shell {
    padding-top: 28px;
  }

  .view.active {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  #dashboardView .metric-grid,
  #dashboardView .bible-panel {
    grid-column: 1 / -1;
  }

  #reflectView .panel:first-child {
    grid-column: span 1;
  }
}

@media (max-width: 620px) {
  .metric-grid,
  .timer-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 142px;
  }

  .focus-strip {
    align-items: stretch;
  }

  .timeline-item {
    align-items: flex-start;
  }

  .timeline-time {
    width: 76px;
  }

  .history-stats,
  .history-metrics {
    grid-template-columns: 1fr 1fr;
  }
}
