:root {
  color-scheme: light;
  --ink: #222b28;
  --muted: #626b64;
  --paper: #f6f5ef;
  --card: #ffffff;
  --line: #dfe3d8;
  --lime: #d7f46a;
  --lime-hover: #c9e65d;
  --red: #c63f2c;
  --red-dark: #9f2e20;
  --green: #2f6a4d;
  --shadow: 0 16px 48px rgba(34, 43, 40, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

a { color: inherit; }

.topbar,
footer {
  width: min(72rem, calc(100% - 3rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 0;
}

.wordmark {
  color: var(--ink);
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 3rem;
  height: 3rem;
  flex: none;
}

.shell {
  display: grid;
  width: min(72rem, calc(100% - 3rem));
  min-height: calc(100vh - 10rem);
  margin: 0 auto;
  place-items: center;
  padding: 2.5rem 0 5rem;
}

.screen {
  width: min(100%, 52rem);
  padding: clamp(2rem, 5vw, 4.8rem);
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.screen[aria-busy="true"] { opacity: 0.72; }

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1,
h2 {
  max-width: 15ch;
  margin-bottom: 1rem;
  font-family: inherit;
  font-size: clamp(2.25rem, 7vw, 4.5rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.04;
}

h3 {
  margin-bottom: 0.55rem;
  font-size: 1.05rem;
}

p {
  line-height: 1.58;
}

.lede {
  max-width: 39rem;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.telegram-entry {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: clamp(1.25rem, 4vw, 2.25rem);
  align-items: center;
  margin-top: 2rem;
  padding: clamp(1.15rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: #f0f2e9;
}

.telegram-entry .qr {
  width: 9.5rem;
  height: 9.5rem;
}

.telegram-entry__body > p {
  margin-bottom: 1rem;
  color: var(--muted);
}

.waiting {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin: 1rem 0 0;
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 750;
}

.waiting::before {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0.3rem rgba(47, 106, 77, 0.1);
  content: "";
}

.agent-panel {
  margin-top: 2rem;
  padding: clamp(1.15rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: #f0f2e9;
}

.agent-details {
  display: grid;
  grid-template-columns: minmax(7rem, 0.38fr) 1fr;
  margin: 0;
}

.agent-details dt,
.agent-details dd {
  margin: 0;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.agent-details dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.agent-details dd {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.agent-details dt:last-of-type,
.agent-details dd:last-of-type { border-bottom: 0; }

.state { color: var(--muted); }
.state--ready,
.state--running { color: var(--green); }
.state--error,
.state--blocked,
.state--quarantined { color: var(--red-dark); }
.state--resetting { color: var(--red-dark); }

.agent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.25rem;
}

.agent-management {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.agent-management p { margin-bottom: 0.85rem; }
.agent-control-error { color: var(--red-dark); margin-top: 1rem; }

.button.danger {
  color: #fff;
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.agent-confirm {
  width: min(32rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  margin: auto;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  color: var(--ink);
  background: var(--card);
}

.agent-confirm::backdrop { background: rgb(0 0 0 / 40%); }
.agent-confirm h3 { margin-bottom: 0.8rem; }

.agent-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
  margin: 2rem 0;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: #f0f2e9;
}

.agent-entry__body p {
  max-width: 31rem;
  margin-bottom: 1rem;
  color: var(--muted);
}

.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 1rem;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
}

.agent-status::before {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.registration,
.settings {
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}

.registration p,
.settings p,
.muted { color: var(--muted); }

.button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0.76rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  font: inherit;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover { transform: translateY(-1px); }

.button.primary {
  color: var(--ink);
  background: var(--lime);
}

.button.primary:hover { background: var(--lime-hover); }

.button.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: var(--card);
}

.button.ghost {
  color: var(--muted);
  background: transparent;
}

.button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.qr {
  display: grid;
  width: 8.5rem;
  height: 8.5rem;
  flex: none;
  place-items: center;
  padding: 0.45rem;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(23, 23, 18, 0.08);
}

.qr img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.registration-form {
  display: grid;
  gap: 0.8rem;
}

.registration-form .button { justify-self: start; }

.invite-form input {
  min-width: 0;
  flex: 1;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

.form-error { margin: 0.65rem 0 0; color: var(--red-dark) !important; }

.consent-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #f0f2e9;
  font-size: 0.88rem;
  line-height: 1.42;
}

.consent-check input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.2rem 0 0;
  accent-color: var(--green);
}

.policy-note {
  margin: 0;
  font-size: 0.82rem;
}

.legal-link {
  color: var(--green);
  font-weight: 700;
  text-underline-offset: 0.18em;
}

.actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.handoff {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin: 2rem 0 1rem;
}

.loading {
  display: flex;
  min-height: 8rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.loading i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1s infinite ease-in-out;
}

.loading i:nth-child(2) { animation-delay: 120ms; }
.loading i:nth-child(3) { animation-delay: 240ms; }

footer {
  display: flex;
  gap: 1.25rem;
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.legal-shell {
  width: min(48rem, calc(100% - 3rem));
  margin: 2rem auto 6rem;
}

.legal-document {
  padding: clamp(1.5rem, 5vw, 3.5rem);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

.legal-document h1 {
  max-width: none;
  font-size: clamp(2rem, 6vw, 3.5rem);
  hyphens: auto;
  overflow-wrap: anywhere;
}

.legal-document h2 {
  max-width: none;
  margin: 2rem 0 0.7rem;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.legal-document p,
.legal-document li {
  line-height: 1.62;
}

.legal-document p { margin-bottom: 1rem; }

.legal-document ol,
.legal-document ul {
  margin: 0 0 1.5rem;
  padding-left: 1.4rem;
}

.legal-document li { padding-left: 0.25rem; }
.legal-document li + li { margin-top: 0.8rem; }

.legal-document a {
  color: var(--green);
  overflow-wrap: anywhere;
  text-underline-offset: 0.16em;
}

.legal-table-wrap { margin: 0 0 1.5rem; }

.processors-table {
  display: block;
  width: 100%;
  border: 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.processors-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.processors-table tbody {
  display: grid;
  gap: 0.8rem;
}

.processors-table tr {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: #f0f2e9;
}

.processors-table td {
  display: grid;
  grid-template-columns: minmax(6.5rem, 0.32fr) 1fr;
  gap: 0.75rem;
  padding: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.processors-table td::before {
  color: var(--muted);
  content: attr(data-label);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.processors-table td[data-empty="true"] { display: none; }
.legal-version { margin-top: 2.5rem; color: var(--muted); font-size: 0.85rem; }

@keyframes pulse {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-0.2rem); }
}

@media (max-width: 42rem) {
  .topbar,
  footer,
  .shell { width: min(100% - 1.25rem, 72rem); }

  .topbar { padding: 0.55rem 0; }

  .shell {
    min-height: auto;
    padding: 0.25rem 0 2rem;
  }

  .screen {
    padding: 1rem 1.15rem;
    border-radius: 1.35rem;
  }

  h2 {
    margin-bottom: 0.7rem;
    font-size: clamp(2rem, 9vw, 2.3rem);
  }

  .eyebrow { margin-bottom: 0.5rem; }

  .lede {
    margin-bottom: 0.9rem;
    font-size: 1rem;
    line-height: 1.38;
  }

  .telegram-entry {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    margin-top: 1.15rem;
    padding: 1rem;
  }

  .telegram-entry__body { order: -1; }
  .telegram-entry__body > p { margin-bottom: 0.9rem; }
  .telegram-entry__body .button { width: 100%; }
  .telegram-entry .qr {
    width: 8rem;
    height: 8rem;
    justify-self: center;
  }

  .waiting { margin-bottom: 0.25rem; }

  .agent-panel { margin-top: 1.15rem; padding: 1rem; }
  .agent-details { grid-template-columns: 1fr; }
  .agent-details dt { padding-bottom: 0.2rem; border-bottom: 0; }
  .agent-details dd { padding-top: 0; }
  .agent-actions { flex-direction: column; }
  .agent-actions .button { width: 100%; }

  .agent-entry {
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0.9rem 0;
    padding: 1rem;
  }

  .agent-entry__body p,
  .agent-status { display: none; }
  .agent-entry .qr { display: none; }
  .agent-entry .button { width: 100%; }
  .registration { padding-top: 1rem; }
  .registration p { margin-bottom: 0.8rem; }
  .registration-form { gap: 0.6rem; }
  .registration-form .button { width: 100%; }
  .consent-check {
    gap: 0.5rem;
    padding: 0.65rem;
    font-size: 0.78rem;
    line-height: 1.3;
  }
  .button { min-height: 2.75rem; }
  .handoff { flex-direction: column; align-items: stretch; }
  .handoff .qr { align-self: center; }
  .handoff .button { width: 100%; }
  .actions { flex-direction: column-reverse; }
  .actions .button { width: 100%; }
  footer { flex-wrap: wrap; }

  .legal-shell {
    width: min(100% - 1.25rem, 48rem);
    margin-top: 1.25rem;
  }

  .legal-document { padding: 1.45rem; }

  .legal-document h1 {
    font-size: clamp(1.75rem, 8vw, 2.1rem);
  }

  .legal-document h2 {
    margin-top: 1.6rem;
    font-size: 1.05rem;
  }

  .processors-table td {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.connect-card {
  width: min(100%, 34rem);
  margin: 0 auto;
}

.connect-card h1 {
  font-size: clamp(1.7rem, 5vw, 2.35rem);
  letter-spacing: -0.02em;
  line-height: 1.14;
  overflow-wrap: anywhere;
}

.connect-card .lede {
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

.connect-card .loading { min-height: 6rem; }

.connect-hint {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: #f0f2e9;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.connect-form {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0;
}

.connect-field {
  display: grid;
  gap: 0.35rem;
}

.connect-field label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.connect-field input {
  width: 100%;
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: var(--ink);
  background: var(--card);
  font: inherit;
}

.connect-field input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.connect-form .button { justify-self: start; }
.connect-error { margin: 0; color: var(--red-dark); }

@media (max-width: 42rem) {
  .connect-card h1 { font-size: clamp(1.5rem, 7vw, 1.95rem); }
  .connect-card .lede { margin-bottom: 1.1rem; }
  .connect-form { gap: 0.85rem; }
  .connect-form .button { width: 100%; }
}
