:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #eeebe4;
  --ink: #151917;
  --muted: #6c716a;
  --line: #ddd7cd;
  --green: #2f6f4e;
  --blue: #2f5f8c;
  --amber: #9b6425;
  --red: #a33b32;
  --mint: #dff4e4;
  --paper: #fbfaf7;
  --shadow: 0 12px 36px rgba(30, 32, 27, 0.09);
  --bottom-nav-clearance: calc(138px + env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

button:disabled {
  opacity: 0.62;
}

h1,
h2,
h3,
p {
  margin: 0;
  overflow-wrap: break-word;
}

.app-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 14px var(--bottom-nav-clearance);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -14px 8px;
  padding: 9px 14px 10px;
  border-bottom: 1px solid rgba(221, 215, 205, 0.82);
  background: rgba(247, 245, 239, 0.96);
  backdrop-filter: blur(16px);
}

.kicker {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-size: 1.15rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.42rem;
  line-height: 1.12;
}

h3 {
  font-size: 1rem;
  line-height: 1.18;
}

.run-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(47, 111, 78, 0.26);
  border-radius: 999px;
  background: var(--mint);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 850;
}

.screen {
  display: none;
  min-height: calc(100svh - 128px);
  padding: 8px 0 18px;
}

.screen.is-visible {
  display: block;
}

.project-hero {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid rgba(21, 25, 23, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(47, 111, 78, 0.12), transparent 42%),
    linear-gradient(24deg, rgba(47, 95, 140, 0.13), transparent 48%),
    var(--surface);
  box-shadow: var(--shadow);
}

.project-hero h2 {
  font-size: 1.8rem;
  line-height: 1.03;
}

.project-hero p:not(.kicker),
.task-row p,
.goal-chip span,
.agent-card p,
.finding p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.42;
}

.hero-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  margin-top: 4px;
}

.hero-metrics div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.hero-metrics span,
.decision-panel span,
.confidence-panel span,
.finding span,
.step-head span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-metrics strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-panel {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.primary-action,
.bottom-cta {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
  font-weight: 900;
}

.primary-action {
  min-height: 54px;
}

.quiet-action,
.secondary-action,
.icon-button {
  font-weight: 850;
}

.live-status {
  display: grid;
  gap: 4px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid rgba(47, 95, 140, 0.22);
  border-radius: 8px;
  background: #edf3f8;
}

.live-status span {
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.live-status strong {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.28;
}

.section-title {
  display: grid;
  gap: 6px;
  margin: 12px 0 14px;
}

.today-list,
.choice-list,
.connector-list,
.agent-list,
.finding-list,
.file-list {
  display: grid;
  gap: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.is-hot {
  background: var(--red);
}

.status-dot.is-warm {
  background: var(--amber);
}

.step-head {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 2px 0 14px;
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.goal-chip {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 13px 14px;
  text-align: left;
}

.goal-chip.is-selected {
  border-color: rgba(47, 111, 78, 0.42);
  background: var(--mint);
}

.setup-form {
  display: grid;
  gap: 12px;
  margin: 16px 0 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.decision-panel {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #cad7de;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #f5f9fb;
}

.decision-panel strong {
  line-height: 1.34;
}

.bottom-cta {
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  margin-bottom: var(--bottom-nav-clearance);
  scroll-margin-bottom: var(--bottom-nav-clearance);
}

.connector {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 0 12px;
  text-align: left;
}

.source-icon,
.nav-icon {
  display: block;
  position: relative;
  width: 24px;
  height: 24px;
}

.source-icon::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.connector strong {
  color: var(--red);
  font-size: 0.86rem;
}

.connector.is-connected {
  border-color: rgba(47, 111, 78, 0.34);
  background: var(--mint);
}

.connector.is-connected strong {
  color: var(--green);
}

.upload-zone {
  display: grid;
  gap: 5px;
  margin-top: 14px;
  padding: 18px;
  border: 1px dashed #9c9181;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.oauth-panel,
.data-panel,
.confidence-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.oauth-panel[hidden] {
  display: none;
}

.data-panel[hidden] {
  display: none;
}

.oauth-panel {
  border-color: rgba(155, 100, 37, 0.35);
  background: #fff8ed;
}

.data-panel {
  border-color: rgba(47, 111, 78, 0.3);
  background: #f2fbf3;
}

.oauth-panel span,
.data-panel span {
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.data-panel span {
  color: var(--green);
}

.oauth-panel strong,
.data-panel strong {
  font-size: 1rem;
  line-height: 1.34;
}

.data-panel p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.38;
}

.oauth-panel a {
  color: var(--blue);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.confidence-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.confidence-grid p {
  display: grid;
  gap: 2px;
  padding: 10px 6px;
  background: var(--paper);
}

.confidence-grid strong {
  font-size: 1.22rem;
}

.file-list {
  margin-top: 12px;
}

.file-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.file-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-list strong {
  color: var(--green);
}

.file-list strong.is-invalid {
  color: var(--red);
}

.agent-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.agent-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #d6ff5a;
  font-size: 0.78rem;
  font-weight: 900;
}

.meter {
  height: 8px;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--surface-2);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.icon-button {
  grid-column: 1 / -1;
  width: 100%;
}

.finding {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.finding.critical {
  border-left: 5px solid var(--red);
}

.finding.important {
  border-left: 5px solid var(--amber);
}

.finding.later {
  border-left: 5px solid var(--blue);
}

.export-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.secondary-action {
  min-height: 48px;
}

.command-output {
  max-width: 100%;
  overflow-x: auto;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111410;
  color: #eef7e9;
  font-size: 0.78rem;
  line-height: 1.45;
}

.bottom-tabs {
  position: fixed;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  width: min(calc(100% - 20px), 680px);
  margin: 0 auto;
  padding: 7px 6px;
  border: 1px solid rgba(21, 25, 23, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 40px rgba(21, 20, 16, 0.18);
  backdrop-filter: blur(18px);
}

.tab {
  display: grid;
  gap: 2px;
  place-items: center;
  min-width: 0;
  min-height: 52px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active .nav-icon {
  background: var(--ink);
  color: var(--surface);
}

.nav-icon {
  width: 26px;
  height: 26px;
  border: 1px solid currentColor;
  border-radius: 8px;
}

.home-icon::before,
.setup-icon::before,
.data-icon::before,
.team-icon::before,
.review-icon::before {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
}

.home-icon::before {
  inset: 7px 6px 5px;
  border-top: 0;
}

.setup-icon::before {
  inset: 6px;
  border-radius: 50%;
}

.data-icon::before {
  right: 6px;
  bottom: 6px;
  left: 6px;
  height: 10px;
  border-top: 0;
}

.team-icon::before {
  inset: 5px 7px 7px;
  border-radius: 50%;
}

.review-icon::before {
  inset: 6px;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg);
}

@media (min-width: 720px) {
  .app-shell {
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-header {
    margin-right: -24px;
    margin-left: -24px;
    padding-right: 24px;
    padding-left: 24px;
  }

  .project-hero h2 {
    font-size: 2.2rem;
  }

  .choice-list,
  .agent-list,
  .finding-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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