:root {
  color-scheme: light;
  --bg: #f6f5ef;
  --surface: #ffffff;
  --surface-muted: #eeeee7;
  --text: #18211b;
  --muted: #687169;
  --line: #dcded7;
  --accent: #276749;
  --accent-strong: #1d5138;
  --accent-soft: #e4f0e8;
  --accent-faint: #f1f7f3;
  --danger: #a43d3d;
  --danger-soft: #fbecec;
  --warning-soft: #f8efd8;
  --shadow: 0 12px 32px rgba(31, 47, 37, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button,
summary,
.choice-option {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.choice-option:has(input:focus-visible) {
  outline: 3px solid rgba(39, 103, 73, 0.25);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.48;
  cursor: default;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  line-height: 1.4;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 103, 73, 0.1);
  outline: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

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

h1 {
  font-size: 19px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(25px, 7vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

h3 {
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 16px calc(112px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  margin: calc(-10px - var(--safe-top)) -16px 12px;
  padding: calc(10px + var(--safe-top)) 16px 8px;
  background: rgba(246, 245, 239, 0.92);
  border-bottom: 1px solid rgba(220, 222, 215, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand-lockup,
.section-heading,
.action-row,
.form-footer,
.attention-hero,
.guidance-card {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-copy {
  min-width: 0;
}

#connection-label {
  display: flex;
  align-items: center;
  max-width: min(60vw, 440px);
  margin-top: -1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #a2aaa4;
}

#connection-label.is-connected .connection-dot {
  background: #39a66f;
  box-shadow: 0 0 0 3px rgba(57, 166, 111, 0.13);
}

.icon-button,
.quiet-button,
.primary-button,
.secondary-button,
.danger-button,
.prompt-chip {
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
}

.icon-button svg,
.bottom-nav svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.icon-button:active,
.quiet-button:active,
.prompt-chip:active {
  background: var(--surface-muted);
}

.primary-button,
.secondary-button,
.danger-button,
.quiet-button {
  min-height: 50px;
  padding: 0 18px;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(39, 103, 73, 0.16);
}

.primary-button:active {
  background: var(--accent-strong);
}

.secondary-button,
.quiet-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  border: 1px solid #edc6c6;
  background: var(--danger-soft);
  color: var(--danger);
}

.panel,
.interaction,
.judgment-hero,
.guidance-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 1px 0 rgba(31, 47, 37, 0.03);
}

.panel,
.interaction,
.judgment-hero {
  padding: 18px;
}

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

label {
  color: var(--text);
}

.stack label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.pair-view {
  display: grid;
  width: min(520px, 100%);
  margin: 6vh auto 0;
  gap: 24px;
}

.pairing-progress {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pairing-progress h3 {
  font-size: 16px;
}

.pairing-progress p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.pairing-spinner {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pairing-spin 800ms linear infinite;
}

@keyframes pairing-spin {
  to { transform: rotate(360deg); }
}

.pair-intro {
  display: grid;
  gap: 10px;
}

.pair-intro > p:last-child,
.page-intro > p:last-child {
  max-width: 58ch;
  color: var(--muted);
}

.eyebrow,
.section-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form-note,
.meta,
.empty,
.context-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pair-view .primary-button,
.settings-actions button {
  width: 100%;
}

.app-view {
  animation: view-in 180ms ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.attention-hero {
  justify-content: space-between;
  gap: 16px;
  padding: 22px 4px 26px;
}

.attention-hero > div {
  display: grid;
  gap: 5px;
}

.attention-hero h2 {
  font-size: clamp(26px, 7.4vw, 38px);
}

#attention-summary {
  max-width: 48ch;
  color: var(--muted);
  font-size: 14px;
}

.hero-action {
  flex: 0 0 auto;
  min-height: 44px;
  padding-inline: 14px;
  color: var(--accent);
}

.content-section {
  margin-bottom: 28px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
}

.section-heading h2 {
  margin-top: 1px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.count-badge {
  display: grid;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.count-badge.has-items {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.inbox {
  display: grid;
  gap: 12px;
}

.interaction {
  display: grid;
  gap: 14px;
  overflow: hidden;
}

.interaction-header {
  display: grid;
  gap: 6px;
}

.interaction-tag-row,
.scope-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.tag,
.risk-tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

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

.risk-tag {
  background: var(--warning-soft);
  color: #755c20;
}

.context-details,
.reason-details,
.patch-details,
.settings-panel {
  overflow: hidden;
}

.context-details summary,
.reason-details summary,
.patch-details summary,
.settings-panel summary {
  cursor: pointer;
  list-style: none;
}

.context-details summary::-webkit-details-marker,
.reason-details summary::-webkit-details-marker,
.patch-details summary::-webkit-details-marker,
.settings-panel summary::-webkit-details-marker {
  display: none;
}

.context-details summary,
.reason-details summary,
.patch-details summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
}

.context-details[open] summary,
.reason-details[open] summary,
.patch-details[open] summary {
  margin-bottom: 9px;
}

.context-copy {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--accent-faint);
}

.response-form {
  display: grid;
  gap: 12px;
}

.choice-list {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 9px;
  border: 0;
}

.choice-option {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  min-height: 58px;
  padding: 12px;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.choice-option:active {
  transform: scale(0.992);
}

.choice-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-faint);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.choice-marker {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.choice-option:has(input:checked) .choice-marker {
  background: var(--accent);
  color: #fff;
}

.choice-copy {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
}

.custom-answer-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.reason-details textarea {
  min-height: 82px;
}

.response-form .primary-button {
  width: 100%;
}

.action-row {
  gap: 9px;
}

.action-row button {
  flex: 1;
}

.approval-details,
.patch-copy {
  display: grid;
  gap: 8px;
}

.scope-paths {
  overflow-wrap: anywhere;
}

pre.patch-body {
  max-height: 280px;
  margin: 0;
  padding: 13px;
  overflow: auto;
  border-radius: 12px;
  background: #202823;
  color: #eff6f1;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.empty-state {
  padding: 17px 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.page-intro {
  display: grid;
  gap: 8px;
  padding: 20px 4px 24px;
}

.direction-form {
  display: grid;
  gap: 14px;
}

.direction-label {
  font-size: 13px;
  font-weight: 800;
}

.direction-form textarea {
  min-height: 168px;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
  box-shadow: none;
  font-size: 18px;
  line-height: 1.5;
}

.direction-form textarea::placeholder {
  color: #9aa199;
}

.prompt-chips {
  display: flex;
  margin: 2px -4px 0;
  padding: 4px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.prompt-chips::-webkit-scrollbar {
  display: none;
}

.prompt-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
}

.form-footer {
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.form-footer .form-note {
  max-width: 40ch;
}

.form-footer .primary-button {
  flex: 0 0 auto;
}

.guidance-card {
  margin-top: 14px;
  padding: 16px;
  align-items: flex-start;
  gap: 13px;
  background: var(--accent-faint);
}

.guidance-card h3 {
  font-size: 15px;
}

.guidance-card p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.guidance-icon {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
}

.judgment-content {
  display: grid;
  gap: 14px;
}

.judgment-hero {
  display: grid;
  gap: 14px;
}

.trust-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.trust-value {
  font-size: 42px;
  font-weight: 780;
  letter-spacing: -0.045em;
  line-height: 1;
}

.trust-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.metric-card {
  min-height: 91px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.metric-value {
  display: block;
  font-size: 24px;
  font-weight: 780;
  letter-spacing: -0.03em;
}

.metric-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settings-panel {
  margin-top: 22px;
}

.settings-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.settings-panel > summary > span:first-child {
  display: grid;
  gap: 1px;
}

.settings-panel .disclosure-icon {
  color: var(--muted);
  font-size: 22px;
  transition: transform 120ms ease;
}

.settings-panel[open] .disclosure-icon {
  transform: rotate(180deg);
}

.settings-actions {
  display: grid;
  margin-top: 16px;
  padding-top: 16px;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  padding: max(18px, var(--safe-top)) 16px max(18px, var(--safe-bottom));
  place-items: end center;
  background: rgba(15, 24, 18, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.install-dialog {
  display: grid;
  width: min(520px, 100%);
  padding: 22px;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 24, 18, 0.25);
  animation: install-in 180ms ease-out;
}

@keyframes install-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.install-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--text);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.install-copy {
  display: grid;
  gap: 8px;
}

.install-copy h2 {
  font-size: 26px;
}

.install-copy > p:last-of-type,
.install-steps {
  color: var(--muted);
  font-size: 14px;
}

.install-steps {
  display: grid;
  margin: 4px 0 0;
  padding-left: 22px;
  gap: 7px;
}

.install-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 9px;
}

.install-actions button {
  width: 100%;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(760px, 100%);
  min-height: calc(72px + var(--safe-bottom));
  margin: 0 auto;
  padding: 7px 18px var(--safe-bottom);
  border-top: 1px solid rgba(220, 222, 215, 0.9);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -10px 30px rgba(31, 47, 37, 0.05);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  min-width: 0;
  min-height: 58px;
  padding: 3px 6px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.nav-item[aria-current="page"] {
  color: var(--accent);
}

.nav-icon-wrap {
  position: relative;
  display: grid;
  width: 34px;
  height: 30px;
  place-items: center;
  border-radius: 12px;
}

.nav-item[aria-current="page"] .nav-icon-wrap:not(.nav-icon-accent) {
  background: var(--accent-soft);
}

.nav-icon-accent {
  width: 38px;
  height: 34px;
  margin-top: -8px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 12px rgba(39, 103, 73, 0.2);
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -7px;
  display: grid;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 850;
}

.status-toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: calc(88px + var(--safe-bottom));
  left: 16px;
  display: block;
  width: fit-content;
  max-width: min(520px, calc(100% - 32px));
  min-height: 0;
  margin: 0 auto;
  padding: 11px 15px;
  border-radius: 14px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transition: opacity 120ms ease, transform 120ms ease;
}

.status-toast:empty {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
}

.status-toast.is-error {
  background: var(--danger);
}

.hidden,
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 13px;
  }

  .topbar {
    margin-inline: -13px;
    padding-inline: 13px;
  }

  .attention-hero {
    align-items: flex-start;
  }

  .hero-action {
    display: none;
  }

  .form-footer {
    display: grid;
    align-items: stretch;
  }

  .form-footer .primary-button {
    width: 100%;
  }

  .panel,
  .interaction,
  .judgment-hero {
    padding: 16px;
  }
}

@media (min-width: 660px) {
  .app-shell {
    padding-inline: 24px;
  }

  .topbar {
    margin-inline: -24px;
    padding-inline: 24px;
  }

  .metric-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
