:root {
  color-scheme: light;
  --canvas: #f4f2ec;
  --surface: #fffdf8;
  --surface-2: #ece9e1;
  --ink: #191919;
  --muted: #68665f;
  --line: #c9c5ba;
  --line-strong: #242424;
  --accent: #ff5c35;
  --accent-ink: #70210f;
  --accent-soft: #ffe2d9;
  --violet: #6757d9;
  --success: #08745a;
  --success-soft: #dff4eb;
  --danger: #a22b27;
  --danger-soft: #f7dfdd;
  --warning: #8f5500;
  --warning-soft: #f8e7bc;
  --radius: 22px 5px 22px 5px;
  --radius-small: 10px 3px 10px 3px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #121211;
  --surface: #1a1a18;
  --surface-2: #25241f;
  --ink: #f5f1e7;
  --muted: #aaa69c;
  --line: #3e3c36;
  --line-strong: #f5f1e7;
  --accent: #ff7757;
  --accent-ink: #ffd9cf;
  --accent-soft: #472319;
  --violet: #9d91ff;
  --success: #62d0ac;
  --success-soft: #143a30;
  --danger: #ff9b96;
  --danger-soft: #45201f;
  --warning: #f0bd68;
  --warning-soft: #493716;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --canvas: #121211;
    --surface: #1a1a18;
    --surface-2: #25241f;
    --ink: #f5f1e7;
    --muted: #aaa69c;
    --line: #3e3c36;
    --line-strong: #f5f1e7;
    --accent: #ff7757;
    --accent-ink: #ffd9cf;
    --accent-soft: #472319;
    --violet: #9d91ff;
    --success: #62d0ac;
    --success-soft: #143a30;
    --danger: #ff9b96;
    --danger-soft: #45201f;
    --warning: #f0bd68;
    --warning-soft: #493716;
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--canvas);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  color: var(--ink);
  font: 16px/1.55 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: color-mix(in srgb, var(--canvas) 88%, transparent); }
a { color: var(--violet); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.page-stack { display: grid; gap: 24px; padding-block: 46px 68px; }

.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--line-strong); backdrop-filter: blur(14px); }
.nav-row { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { color: var(--ink); font-size: 1rem; font-weight: 850; text-decoration: none; letter-spacing: -0.04em; }
.brand-punctuation { color: var(--accent); }
.nav-actions, .account { display: flex; align-items: center; gap: 11px; }
.account form { margin: 0; }
.signed-in-label { color: var(--muted); font-size: 0.82rem; }
.signed-in-label strong { color: var(--ink); }
.avatar { width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.avatar-small { width: 28px; height: 28px; }
.theme-toggle { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.15rem; }
.theme-toggle:hover { border-color: var(--line-strong); background: var(--accent-soft); }
.nav-link { font-weight: 700; text-decoration: none; }

.card { position: relative; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: clamp(22px, 4vw, 38px); }
.signature-card::before { content: ""; position: absolute; width: 82px; height: 9px; top: -1px; left: 34px; background: var(--accent); }
.hero { overflow: hidden; padding-block: clamp(48px, 9vw, 96px); }
.hero::after { content: "//"; position: absolute; right: clamp(20px, 7vw, 90px); top: 22px; color: var(--accent); font: 900 clamp(4rem, 12vw, 10rem)/1 ui-monospace, monospace; opacity: 0.13; pointer-events: none; }
.compact-hero { padding: 22px 0 6px; overflow: visible; }
.compact-hero::after { display: none; }
.login-card { width: min(100%, 800px); margin: 26px auto; text-align: center; }
.hero h1, .dashboard-intro h1, .acceptance-complete h1 { max-width: 780px; margin: 8px 0 18px; font-size: clamp(2.4rem, 7vw, 4.6rem); line-height: 0.98; letter-spacing: -0.065em; }
.login-card h1, .login-card .lead { margin-inline: auto; }
.lead { max-width: 720px; margin: 0; color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.18rem); }
.eyebrow { color: var(--accent); font: 800 0.73rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.12em; text-transform: uppercase; }
h2 { margin: 5px 0 0; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.15; letter-spacing: -0.04em; }
h3 { margin: 0; font-size: 1rem; }
.muted, .privacy-note { color: var(--muted); }
.privacy-note { margin: 18px 0; font-size: 0.85rem; }
.site-footer { border-top: 1px solid var(--line-strong); padding: 25px 0; background: var(--surface); color: var(--muted); font-size: 0.82rem; }

.button-row, .inline-actions, .form-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.button-row { margin-top: 30px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-small); padding: 10px 17px; cursor: pointer; font-weight: 760; line-height: 1.2; text-decoration: none; transition: color 120ms, background 120ms, transform 120ms; }
.button:hover:not(:disabled) { transform: translate(-2px, -2px); }
.button:disabled { opacity: 0.46; cursor: not-allowed; }
.button-primary { background: var(--ink); color: var(--surface); }
.button-primary:hover:not(:disabled) { background: var(--accent); color: #161616; }
.button-secondary { background: var(--surface); color: var(--ink); }
.button-secondary:hover:not(:disabled) { background: var(--accent-soft); }
.button-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.button-small { min-height: 36px; padding: 7px 11px; font-size: 0.79rem; }
.button-wide { width: 100%; min-height: 52px; }
.github-button { margin-top: 30px; }

.notice { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border: 1px solid currentColor; border-radius: var(--radius-small); padding: 14px 16px; }
.notice h2 { margin-top: 0; }.notice p:last-child { margin-bottom: 0; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-success { background: var(--success-soft); color: var(--success); }
.compact-notice { margin: -8px 0 20px; font-size: 0.84rem; }
.admin-auth-error { justify-content: space-between; margin: 0; }
.loading-state, .empty-state { padding: 27px; border: 1px dashed var(--line-strong); border-radius: var(--radius-small); color: var(--muted); text-align: center; }
.acceptance-complete { max-width: 760px; margin-inline: auto; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.terms-card { padding-bottom: 0; overflow: hidden; }
.terms { max-height: 60vh; overflow: auto; margin-inline: clamp(-38px, -4vw, -22px); padding: 30px clamp(22px, 4vw, 38px) 42px; border-top: 1px solid var(--line); color: var(--muted); overscroll-behavior: contain; }
.terms h1, .terms h2, .terms h3 { color: var(--ink); line-height: 1.25; }
.terms pre { overflow: auto; }
.hash, .compact-code, .link-code { font: 0.76rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.hash { max-width: 280px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.link-code { flex: 1 1 320px; padding: 9px 11px; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 16px; font-weight: 800; font-size: 1.1rem; }
.check-row { display: flex; align-items: flex-start; gap: 13px; margin-top: 10px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-small); cursor: pointer; }
.check-row:hover { border-color: var(--line-strong); }
.check-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check-row input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: 0 0 auto; }

.dashboard-intro { display: flex; justify-content: space-between; align-items: end; gap: 30px; padding: 10px 2px; }
.dashboard-intro h1 { font-size: clamp(2.2rem, 6vw, 4rem); }
.dashboard-tabs { display: flex; align-items: end; gap: 4px; border-bottom: 1px solid var(--line-strong); }
.dashboard-tab { min-height: 46px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 10px 18px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 800; }
.dashboard-tab:hover { color: var(--ink); background: var(--surface-2); }
.dashboard-tab.is-active { margin-bottom: -1px; background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.tab-panel[hidden] { display: none; }
.search-field { width: min(100%, 290px); }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-small); padding: 9px 12px; background: var(--surface); color: var(--ink); }
input:focus, select:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.repo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.repo-card { --stripe: var(--accent); min-width: 0; display: flex; flex-direction: column; gap: 14px; min-height: 180px; padding: 19px; border: 1px solid var(--line); border-top: 5px solid var(--stripe); border-radius: var(--radius-small); background: var(--surface); color: var(--ink); text-decoration: none; transition: border 120ms, transform 120ms; }
.repo-card:nth-child(5n + 2) { --stripe: var(--violet); }.repo-card:nth-child(5n + 3) { --stripe: var(--success); }.repo-card:nth-child(5n + 4) { --stripe: var(--warning); }
.repo-card:hover { border-left-color: var(--line-strong); border-right-color: var(--line-strong); border-bottom-color: var(--line-strong); transform: translate(-3px, -3px); }
.repo-card-top { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.repo-card h3 { overflow-wrap: anywhere; font-size: 1.05rem; }
.repo-description { flex: 1; margin: 0; color: var(--muted); font-size: 0.89rem; }
.repo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 0.74rem; }
.pill, .role-chip { display: inline-flex; align-items: center; width: fit-content; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; background: var(--surface-2); color: var(--muted); font-size: 0.68rem; font-weight: 800; text-transform: lowercase; }
.visibility-public { color: var(--success); }.visibility-internal { color: var(--violet); }.visibility-private { color: var(--warning); }
.permission { margin-left: auto; color: var(--violet); font-weight: 850; text-transform: uppercase; letter-spacing: 0.05em; }

.admin-stack { display: grid; gap: 24px; }
.form-grid { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) auto; align-items: end; gap: 14px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.subsection { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--line); }
.subsection > h3 { margin-bottom: 14px; font-size: 1rem; }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-small); }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
.data-table th { padding: 11px 14px; background: var(--surface-2); color: var(--muted); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; }
.data-table td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 0.84rem; }
.member-identity { display: flex; align-items: center; gap: 9px; }
.data-table select { min-width: 105px; min-height: 36px; padding-block: 5px; }
.status-pending { color: var(--warning); }.status-accepted { color: var(--violet); }.status-used { color: var(--success); }.status-failed { color: var(--danger); }
.hash-short { white-space: nowrap; }
.role-chip-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 260px; }
.role-chip-required { border-color: var(--accent); color: var(--accent); }

.roles-dialog { width: min(580px, calc(100% - 28px)); max-height: min(760px, calc(100vh - 40px)); padding: 30px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.roles-dialog::backdrop { background: rgba(0, 0, 0, 0.66); }
.dialog-close { position: absolute; top: 14px; right: 17px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.7rem; }
.roles-options { display: grid; gap: 8px; max-height: 430px; overflow-y: auto; margin: 22px 0; }
.role-option { display: flex; align-items: flex-start; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-small); cursor: pointer; }
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-option input { width: 19px; min-height: 19px; margin: 2px 0 0; accent-color: var(--accent); }
.role-option-copy { display: grid; gap: 2px; }.role-option-copy small { color: var(--muted); }
.dialog-actions { justify-content: flex-end; margin-top: 22px; }

.request-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr); gap: clamp(32px, 7vw, 80px); align-items: center; min-height: 510px; }
.request-copy h1 { margin: 8px 0 16px; font-size: clamp(2.5rem, 6vw, 4.2rem); line-height: 0.98; letter-spacing: -0.06em; }
.org-preview { display: inline-flex; gap: 7px; margin-top: 28px; font-weight: 800; text-decoration: none; }
.request-form-wrap { padding: 24px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.request-form { display: grid; gap: 18px; }
.request-form label { display: grid; gap: 7px; color: var(--muted); font-size: 0.8rem; font-weight: 800; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .repo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr 1fr; }.form-actions { grid-column: 1 / -1; }
  .request-layout { grid-template-columns: 1fr; min-height: auto; }
}

@media (max-width: 660px) {
  .shell { width: min(100% - 24px, 1180px); }
  .page-stack { padding-block: 28px 48px; gap: 16px; }
  .site-header { position: static; }.nav-row { min-height: 64px; }
  .signed-in-label, .account-name { display: none; }.nav-actions { gap: 7px; }
  .card { border-radius: 16px 3px 16px 3px; padding: 20px; }
  .hero { padding-block: 42px; }.hero h1 { font-size: clamp(2.25rem, 12vw, 3.2rem); }.hero::after { right: 10px; }
  .button-row, .button-row .button { width: 100%; }
  .dashboard-intro, .section-heading { align-items: flex-start; flex-direction: column; }.section-heading { gap: 14px; }
  .dashboard-tabs { overflow: visible; }.dashboard-tab { flex: 1 1 0; padding-inline: 10px; }
  .search-field { width: 100%; }.repo-grid { grid-template-columns: 1fr; }.repo-card { min-height: 150px; }
  .form-grid { grid-template-columns: 1fr; }.form-actions { grid-column: auto; }.form-actions .button { flex: 1 1 100%; }
  .hash { max-width: 100%; }.terms { max-height: 65vh; margin-inline: -20px; padding-inline: 20px; }
  .acceptance-card .button { white-space: normal; }.data-table { min-width: 700px; }
  .request-form-wrap { padding: 18px; }.site-footer { text-align: center; }
  .roles-dialog { padding: 24px 18px; }.dialog-actions .button { flex: 1; }
}

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