:root {
  color-scheme: dark;
  --legal-bg: #101914;
  --legal-panel: #18251d;
  --legal-panel-soft: #1e2d23;
  --legal-ink: #f4f1e8;
  --legal-muted: #aeb9af;
  --legal-line: rgba(244, 241, 232, 0.14);
  --legal-moss: #a9c98e;
  --legal-gold: #e9d59a;
  --legal-danger: #e7a29a;
  --legal-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

html[data-arbsoul-theme="light"] {
  color-scheme: light;
  --legal-bg: #f3efe5;
  --legal-panel: #fffdf7;
  --legal-panel-soft: #eee7da;
  --legal-ink: #1a2b20;
  --legal-muted: #667269;
  --legal-line: rgba(26, 43, 32, 0.14);
  --legal-moss: #476c42;
  --legal-gold: #7b5a22;
  --legal-danger: #9c3e38;
  --legal-shadow: 0 24px 70px rgba(51, 43, 29, 0.12);
}

* {
  box-sizing: border-box;
}

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

body.legal-page {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% -8%, rgba(169, 201, 142, 0.17), transparent 28rem),
    radial-gradient(circle at 96% 10%, rgba(233, 213, 154, 0.09), transparent 24rem),
    var(--legal-bg);
  color: var(--legal-ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

.legal-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 64px;
}

.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  padding: 8px 0 20px;
  border-bottom: 1px solid var(--legal-line);
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.legal-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.legal-brand span {
  display: grid;
  gap: 1px;
}

.legal-brand strong {
  font: 900 1.06rem/1 "Avenir Next", sans-serif;
  letter-spacing: -0.025em;
}

.legal-brand small {
  color: var(--legal-muted);
  font: 800 0.64rem/1.1 "Avenir Next", sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.legal-header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.arbsoul-page-preferences {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.arbsoul-page-language {
  position: relative;
}

.arbsoul-page-language > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.arbsoul-page-language select,
.arbsoul-page-theme {
  min-height: 38px;
  border: 1px solid var(--legal-line);
  border-radius: 999px;
  background: rgba(244, 241, 232, 0.06);
  color: var(--legal-ink);
  font: 900 0.67rem/1 "Avenir Next", sans-serif;
  letter-spacing: 0.045em;
}

.arbsoul-page-language select {
  max-width: 104px;
  padding: 0 28px 0 12px;
}

.arbsoul-page-theme {
  padding: 0 13px;
  cursor: pointer;
}

html[data-arbsoul-theme="light"] body.legal-page {
  background:
    radial-gradient(circle at 10% -8%, rgba(71, 108, 66, 0.13), transparent 28rem),
    radial-gradient(circle at 96% 10%, rgba(123, 90, 34, 0.08), transparent 24rem),
    var(--legal-bg);
}

html[data-arbsoul-theme="light"] .legal-content,
html[data-arbsoul-theme="light"] .feedback-card,
html[data-arbsoul-theme="light"] .account-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.72), transparent), var(--legal-panel);
}

html[data-arbsoul-theme="light"] .legal-section p,
html[data-arbsoul-theme="light"] .legal-section li,
html[data-arbsoul-theme="light"] .account-card p {
  color: #465249;
}

html[data-arbsoul-theme="light"] .legal-callout {
  color: #344a35;
}

html[data-arbsoul-theme="light"] .feedback-field > span,
html[data-arbsoul-theme="light"] .feedback-field legend {
  color: #263b2c;
}

html[data-arbsoul-theme="light"] .feedback-field input,
html[data-arbsoul-theme="light"] .feedback-field select,
html[data-arbsoul-theme="light"] .feedback-field textarea {
  border-color: rgba(26, 43, 32, 0.18);
  background: #f8f4eb;
}

.beta-chip,
.legal-link-button,
.legal-button {
  border-radius: 999px;
  font: 900 0.7rem/1 "Avenir Next", sans-serif;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.beta-chip {
  display: inline-flex;
  padding: 9px 12px;
  background: rgba(169, 201, 142, 0.14);
  color: #dff0cf;
  border: 1px solid rgba(169, 201, 142, 0.28);
}

.legal-link-button,
.legal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--legal-line);
  background: rgba(244, 241, 232, 0.06);
  color: var(--legal-ink);
  text-decoration: none;
  cursor: pointer;
}

.legal-link-button:hover,
.legal-button:hover {
  border-color: rgba(233, 213, 154, 0.42);
  background: rgba(233, 213, 154, 0.1);
}

.legal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.75fr);
  gap: 32px;
  align-items: end;
  padding: 62px 0 44px;
}

.legal-eyebrow {
  margin: 0 0 12px;
  color: var(--legal-moss);
  font: 900 0.72rem/1.1 "Avenir Next", sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.legal-hero h1 {
  max-width: 760px;
  margin: 0;
  font: 600 clamp(2.7rem, 7vw, 5.6rem)/0.92 Georgia, serif;
  letter-spacing: -0.065em;
}

.legal-hero-copy {
  margin: 0;
  color: var(--legal-muted);
  font-size: 1rem;
  line-height: 1.65;
}

.legal-hero-copy strong {
  display: block;
  margin-bottom: 8px;
  color: var(--legal-gold);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legal-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}

.legal-toc {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--legal-line);
  border-radius: 18px;
  background: rgba(24, 37, 29, 0.78);
}

.legal-toc strong {
  margin: 2px 8px 8px;
  color: var(--legal-muted);
  font-size: 0.67rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legal-toc a {
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--legal-ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.legal-toc a:hover {
  background: rgba(169, 201, 142, 0.1);
}

.legal-content,
.feedback-card,
.account-card {
  min-width: 0;
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid var(--legal-line);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.028), transparent), var(--legal-panel);
  box-shadow: var(--legal-shadow);
}

.legal-section + .legal-section {
  margin-top: 38px;
  padding-top: 38px;
  border-top: 1px solid var(--legal-line);
}

.legal-section h2,
.feedback-card h2,
.account-card h2 {
  margin: 0 0 14px;
  color: var(--legal-gold);
  font: 600 clamp(1.45rem, 3vw, 2rem)/1.05 Georgia, serif;
  letter-spacing: -0.035em;
}

.legal-section h3 {
  margin: 24px 0 8px;
  font-size: 1rem;
}

.legal-section p,
.legal-section li,
.account-card p {
  color: #d1d8d1;
  line-height: 1.68;
}

.legal-section ul {
  display: grid;
  gap: 8px;
  padding-left: 21px;
}

.legal-callout {
  margin: 0 0 28px;
  padding: 18px 20px;
  border-left: 4px solid var(--legal-moss);
  border-radius: 0 14px 14px 0;
  background: rgba(169, 201, 142, 0.08);
  color: #dce9d3;
  line-height: 1.55;
}

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--legal-line);
  color: var(--legal-muted);
  font-size: 0.76rem;
}

.legal-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.legal-footer a,
.legal-section a,
.account-card a {
  color: var(--legal-gold);
  font-weight: 800;
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.feedback-field {
  display: grid;
  gap: 8px;
}

.feedback-field.is-wide {
  grid-column: 1 / -1;
}

.feedback-field > span,
.feedback-field legend {
  color: #e6ece5;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.045em;
}

.feedback-field small {
  color: var(--legal-muted);
  line-height: 1.4;
}

.feedback-field input,
.feedback-field select,
.feedback-field textarea {
  width: 100%;
  border: 1px solid rgba(244, 241, 232, 0.17);
  border-radius: 12px;
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--legal-ink);
  font: 700 0.92rem/1.4 "Avenir Next", sans-serif;
  outline: none;
}

.feedback-field textarea {
  min-height: 120px;
  resize: vertical;
}

.feedback-field input:focus,
.feedback-field select:focus,
.feedback-field textarea:focus {
  border-color: var(--legal-gold);
  box-shadow: 0 0 0 4px rgba(233, 213, 154, 0.1);
}

.feedback-diagnostics {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border: 1px solid var(--legal-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
}

.feedback-diagnostics summary {
  color: var(--legal-muted);
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
}

.feedback-diagnostics pre {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: #c8d4c8;
  font: 650 0.7rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.feedback-consent,
.account-confirmation {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 15px;
  border: 1px solid var(--legal-line);
  border-radius: 13px;
  background: rgba(169, 201, 142, 0.07);
  color: #d9e2d9;
  font-size: 0.8rem;
  line-height: 1.5;
}

.feedback-consent input,
.account-confirmation input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--legal-moss);
}

.feedback-actions,
.account-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 8px;
}

#thanks-receipt {
  display: grid;
  gap: 5px;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid rgba(169, 201, 142, 0.32);
  border-radius: 14px;
  background: rgba(169, 201, 142, 0.08);
}

#thanks-receipt[hidden] {
  display: none;
}

#thanks-receipt p,
#thanks-receipt span {
  margin: 0;
  color: var(--legal-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

#thanks-receipt strong {
  color: var(--legal-gold);
  font: 850 1.08rem/1.2 "Avenir Next", sans-serif;
  letter-spacing: 0.04em;
}

.legal-button.is-primary {
  min-height: 46px;
  padding: 0 22px;
  border-color: transparent;
  background: var(--legal-gold);
  color: #172119;
}

.legal-button.is-danger {
  border-color: rgba(231, 162, 154, 0.38);
  background: rgba(172, 66, 56, 0.18);
  color: #ffd9d4;
}

.legal-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback-status,
.account-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--legal-moss);
  font-weight: 800;
}

.account-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 28px;
}

.account-summary div {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--legal-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.account-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--legal-muted);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.account-summary strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-danger {
  margin-top: 34px;
  padding-top: 30px;
  border-top: 1px solid rgba(231, 162, 154, 0.26);
}

.account-integration {
  margin-top: 34px;
  padding-top: 30px;
  border-top: 1px solid var(--legal-line);
}

.account-integration-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
}

.account-integration-head h2 {
  margin-bottom: 8px;
}

.account-integration-head p,
.account-jobber-handoff p {
  margin: 0;
}

.account-integration-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--legal-muted);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.account-connection-state {
  padding: 8px 11px;
  border: 1px solid var(--legal-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--legal-muted);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.account-connection-state.is-connected {
  border-color: rgba(169, 201, 142, 0.4);
  background: rgba(169, 201, 142, 0.12);
  color: #dceccf;
}

.account-connection-state.is-warning {
  border-color: rgba(233, 213, 154, 0.46);
  background: rgba(233, 213, 154, 0.1);
  color: var(--legal-gold);
}

.account-workspace-field {
  margin-top: 22px;
}

.account-integration-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.account-integration-summary div {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--legal-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.03);
}

.account-integration-summary span {
  display: block;
  margin-bottom: 5px;
  color: var(--legal-muted);
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-integration-summary strong {
  display: block;
  overflow: hidden;
  color: var(--legal-ink);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-integration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.legal-button.is-danger-secondary {
  border-color: rgba(231, 162, 154, 0.28);
  color: #f1c5c0;
}

.account-jobber-handoff {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid rgba(169, 201, 142, 0.26);
  border-radius: 17px;
  background: rgba(169, 201, 142, 0.055);
}

.account-jobber-handoff h3 {
  margin: 0 0 5px;
  color: var(--legal-ink);
  font-size: 1rem;
}

.account-jobber-handoff .account-integration-actions {
  margin-top: 0;
}

.account-jobber-link {
  width: fit-content;
  color: var(--legal-gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.account-status.is-error {
  color: #e7a29a;
}

.account-danger h2 {
  color: var(--legal-danger);
}

.account-owned-workspaces {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.account-owned-workspaces li {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(231, 162, 154, 0.08);
  color: #f0cfcb;
  font-size: 0.82rem;
  font-weight: 800;
}

@media (max-width: 760px) {
  .legal-shell {
    width: min(100% - 22px, 680px);
    padding-top: 10px;
  }

  .legal-header {
    align-items: flex-start;
    padding-bottom: 12px;
  }

  .legal-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .arbsoul-page-preferences {
    order: 2;
  }

  .arbsoul-page-theme {
    max-width: 140px;
    padding-inline: 10px;
    font-size: 0.62rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .legal-header-actions .beta-chip {
    display: none;
  }

  .legal-hero {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 42px 4px 28px;
  }

  .legal-layout {
    grid-template-columns: 1fr;
  }

  .legal-toc {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legal-toc strong {
    grid-column: 1 / -1;
  }

  .legal-content,
  .feedback-card,
  .account-card {
    padding: 22px;
    border-radius: 20px;
  }

  .feedback-grid,
  .account-summary {
    grid-template-columns: 1fr;
  }

  .feedback-field.is-wide,
  .feedback-diagnostics,
  .feedback-consent,
  .feedback-actions {
    grid-column: 1;
  }

  .feedback-actions,
  .account-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .legal-button {
    width: 100%;
  }

  .account-integration-head {
    grid-template-columns: 1fr;
  }

  .account-connection-state {
    width: fit-content;
  }

  .account-integration-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-integration-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
