:root {
  color-scheme: light;
  --ink: #14201b;
  --muted: #617068;
  --line: #dfe6e1;
  --paper: #fffdf9;
  --wash: #f1f5f1;
  --green: #12372b;
  --green-2: #1f5b46;
  --amber: #b85d25;
  --amber-dark: #813b19;
  --red: #9c3427;
  --shadow: 0 18px 55px rgb(20 32 27 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--wash); color: var(--ink); }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, #fbfcf9 0, var(--wash) 520px); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgb(184 93 37 / 32%);
  outline-offset: 2px;
}

.skip-link {
  position: fixed; left: 16px; top: 10px; z-index: 20; padding: 10px 14px; border-radius: 10px;
  background: var(--ink); color: white; transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px;
  padding: 12px clamp(18px, 4vw, 64px); border-bottom: 1px solid var(--line); background: rgb(255 253 249 / 90%);
  backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10;
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font: 750 21px/1 Georgia, serif; text-decoration: none; }
.mark { display: inline-flex; gap: 3px; align-items: end; width: 24px; height: 24px; }
.mark i { width: 6px; border-radius: 8px; background: var(--green); }
.mark i:nth-child(1) { height: 13px; }.mark i:nth-child(2) { height: 22px; }.mark i:nth-child(3) { height: 17px; }
.topbar-title { text-align: center; }
.topbar-title span, .topbar-title small { display: block; }
.topbar-title span { font-weight: 720; }.topbar-title small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.back-link { justify-self: end; color: var(--green); font-weight: 700; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

main { width: min(1440px, 100%); margin: 0 auto; padding: clamp(28px, 5vw, 72px) clamp(18px, 4vw, 64px) 96px; }
.panel { border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.auth-panel { min-height: 180px; display: flex; align-items: center; gap: 20px; padding: 32px; }
.auth-panel h1 { margin: 0 0 8px; font: 600 clamp(24px, 4vw, 36px)/1.1 Georgia, serif; }
.auth-panel p { margin: 0; color: var(--muted); }
.auth-panel .button { margin-left: auto; }
.loader { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loader { animation: none; border-top-color: var(--line); } }

.message { position: sticky; top: 88px; z-index: 9; margin-bottom: 18px; padding: 14px 18px; border: 1px solid #a9cab9; border-radius: 14px; background: #e9f6ef; color: #184630; font-weight: 650; }
.message.error { border-color: #e3b1a9; background: #fff0ed; color: #7a2c20; }
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: clamp(28px, 5vw, 72px); align-items: end; padding: 14px 0 44px; }
.eyebrow { margin: 0 0 10px; color: var(--amber); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.hero h1 { max-width: 840px; margin: 0; font: 540 clamp(38px, 6vw, 74px)/.98 Georgia, serif; letter-spacing: -.035em; }
.hero > div > p:last-child { max-width: 750px; margin: 24px 0 0; color: var(--muted); font-size: clamp(16px, 2vw, 20px); line-height: 1.55; }
.hero-rule { display: flex; gap: 14px; padding: 22px; border-left: 3px solid var(--amber); background: rgb(255 253 249 / 72%); }
.hero-rule > span { display: grid; place-items: center; flex: 0 0 32px; height: 32px; border-radius: 50%; background: var(--green); color: white; font-weight: 800; }
.hero-rule p { margin: 0; color: var(--muted); line-height: 1.5; }.hero-rule strong { color: var(--ink); }

.connection-grid { display: grid; grid-template-columns: 1fr 1fr 1.05fr; gap: 18px; }
.connection-grid .panel, .builder, .guardrails, .request-list-panel, .request-detail { padding: clamp(20px, 3vw, 30px); }
.panel-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.panel-heading.compact { align-items: center; }
h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0; font: 590 27px/1.12 Georgia, serif; }
h3 { margin: 0; font-size: 14px; }
.muted { color: var(--muted); }
.state-pill { display: inline-flex; align-items: center; min-height: 29px; padding: 5px 10px; border: 1px solid #9fc8b3; border-radius: 999px; background: #edf8f1; color: #1d593f; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.state-pill.neutral { border-color: var(--line); background: #f5f7f5; color: var(--muted); }
.state-pill.locked, .state-pill.warning { border-color: #e3b58c; background: #fff3e7; color: var(--amber-dark); }
.state-pill.error { border-color: #e3b1a9; background: #fff0ed; color: #7a2c20; }

.facts { display: grid; gap: 1px; margin: 22px 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--line); }
.facts div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 11px 13px; background: var(--paper); }
.facts dt { color: var(--muted); font-size: 12px; }.facts dd { margin: 0; font-size: 13px; font-weight: 700; text-align: right; }
.scope-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.scope-columns h3 { margin-bottom: 10px; color: var(--muted); }
.scope-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.scope-list li { position: relative; padding-left: 18px; font-size: 12px; line-height: 1.35; }
.scope-list li::before { content: ""; position: absolute; left: 0; top: .42em; width: 7px; height: 7px; border-radius: 50%; background: #54a57a; }
#missing-scopes li::before { background: #d58a51; }
.write-card > p { color: var(--muted); line-height: 1.5; }
.owner-note { padding: 12px; border-radius: 12px; background: var(--wash); font-size: 12px; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 750; text-decoration: none; }
.button:disabled { cursor: not-allowed; opacity: .52; }
.button.primary { background: var(--green); color: white; }.button.primary:hover:not(:disabled) { background: var(--green-2); }
.button.secondary { border-color: #adc7b9; background: white; color: var(--green); }
.button.ghost { border-color: var(--line); background: transparent; color: var(--ink); }
.button.danger { background: var(--red); color: white; }.button.danger-outline { border-color: #dcada5; background: #fff7f5; color: var(--red); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.confirmation-box { margin-top: 18px; padding: 18px; border: 1px solid #e1af9f; border-radius: 15px; background: #fff7f3; }
.confirmation-box p { color: #67463b; font-size: 13px; line-height: 1.45; }
.confirmation-box label, .field > span, .action-form label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 780; }
input, textarea { width: 100%; min-height: 44px; padding: 11px 13px; border: 1px solid #bfcac3; border-radius: 11px; background: white; color: var(--ink); }
textarea { resize: vertical; line-height: 1.5; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 2px rgb(156 52 39 / 12%); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(270px, .65fr); gap: 18px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 24px; }
.field { display: block; }.field.span-2 { grid-column: span 2; }.field.span-4 { grid-column: span 4; }
.field small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.4; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.builder-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.snapshot { margin-top: 24px; padding: 18px; border: 1px dashed #aebcb4; border-radius: 16px; background: var(--wash); }
.snapshot dl { margin-bottom: 0; }.snapshot table, .price-table { width: 100%; margin-top: 14px; border-collapse: collapse; font-size: 12px; }
.snapshot th, .snapshot td, .price-table th, .price-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.snapshot th, .price-table th { color: var(--muted); font-weight: 700; }
.gid { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; word-break: break-all; }
.guardrails { background: var(--green); color: white; }
.guardrails .eyebrow { color: #efad75; }.guardrails h2 { font-size: 31px; }
.guardrails ol { display: grid; gap: 4px; margin: 24px 0 0; padding: 0; list-style: none; }
.guardrails li { display: flex; gap: 13px; padding: 15px 0; border-top: 1px solid rgb(255 255 255 / 16%); }
.guardrails li > span { display: grid; place-items: center; flex: 0 0 29px; height: 29px; border: 1px solid rgb(255 255 255 / 35%); border-radius: 50%; font-size: 12px; }
.guardrails p { margin: 5px 0 0; color: rgb(255 255 255 / 70%); font-size: 12px; line-height: 1.45; }

.requests-section { margin-top: clamp(38px, 7vw, 80px); }
.section-heading { align-items: end; margin-bottom: 16px; }.section-heading h2 { font-size: clamp(30px, 4vw, 45px); }
.requests-grid { display: grid; grid-template-columns: minmax(270px, .65fr) minmax(0, 1.35fr); gap: 18px; align-items: start; }
.request-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.request-choice { width: 100%; min-height: 68px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); text-align: left; cursor: pointer; }
.request-choice:hover, .request-choice[aria-current="true"] { border-color: #87aa98; background: #f1f8f4; }
.request-choice strong, .request-choice small { display: block; }.request-choice small { margin-top: 4px; color: var(--muted); }
.empty { margin: 0; color: var(--muted); }
.request-detail > h2 { margin-bottom: 8px; }.detail-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 20px; }
.detail-meta span { padding: 5px 8px; border-radius: 8px; background: var(--wash); color: var(--muted); font-size: 11px; }
.change-summary { display: grid; gap: 10px; margin-top: 18px; }
.change-summary > div { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.change-summary small, .change-summary strong { display: block; }.change-summary small { color: var(--muted); margin-bottom: 4px; }
.action-zone { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.action-zone h3 { margin-bottom: 12px; }.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action-form { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fafbf9; }
.action-form textarea { min-height: 74px; margin-bottom: 10px; }.action-form .button { width: 100%; }
.manual-form { grid-column: 1 / -1; }.manual-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 960px) {
  .connection-grid { grid-template-columns: 1fr 1fr; }.write-card { grid-column: 1 / -1; }
  .workspace-grid, .requests-grid { grid-template-columns: 1fr; }.guardrails ol { grid-template-columns: 1fr 1fr; }.guardrails li { padding-right: 12px; }
}

@media (max-width: 680px) {
  .topbar { grid-template-columns: auto 1fr; }.topbar-title { text-align: left; }.back-link { grid-column: 1 / -1; justify-self: stretch; min-height: 44px; display: flex; align-items: center; }
  .hero { grid-template-columns: 1fr; }.connection-grid { grid-template-columns: 1fr; }.write-card { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }.field.span-2, .field.span-4 { grid-column: auto; }
  .guardrails ol { grid-template-columns: 1fr; }.action-grid, .manual-fields { grid-template-columns: 1fr; }.manual-form { grid-column: auto; }
}

@media (max-width: 430px) {
  main { padding: 28px 14px 72px; }.topbar { padding-inline: 14px; gap: 12px; }.topbar-title small { display: none; }
  .panel { border-radius: 17px; }.connection-grid .panel, .builder, .guardrails, .request-list-panel, .request-detail { padding: 18px; }
  .hero h1 { font-size: 39px; }.hero-rule { padding: 17px; }.panel-heading { align-items: flex-start; flex-direction: column; }
  .facts div { grid-template-columns: 1fr; gap: 3px; }.facts dd { text-align: left; }.scope-columns { grid-template-columns: 1fr; }
  .builder-actions, .button-row { display: grid; grid-template-columns: 1fr; }.button { width: 100%; }
  .section-heading { align-items: stretch; flex-direction: column; }.section-heading .button { width: 100%; }
  .snapshot { overflow-x: auto; }.snapshot table, .price-table { min-width: 520px; }
}

@media (max-width: 390px) {
  .topbar-title span { font-size: 14px; }.wordmark { font-size: 18px; }.hero h1 { font-size: 35px; }
  .hero > div > p:last-child { font-size: 16px; }.request-choice { grid-template-columns: 1fr; }.request-choice .state-pill { justify-self: start; }
}
