:root {
  color-scheme: dark;
  color: #f3f5f5;
  background: #090b0c;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-synthesis: none;
  --bg: #090b0c;
  --surface: #111416;
  --surface-2: #171b1e;
  --line: #292f33;
  --line-strong: #3a4449;
  --text: #f3f5f5;
  --muted: #8c989d;
  --green: #68e0a0;
  --amber: #f0c36c;
  --red: #ff7b7b;
  --blue: #76b7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 84% -10%, rgba(104, 224, 160, .08), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input { font: inherit; }

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

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 1px solid var(--blue);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 68px;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid rgba(41, 47, 51, .88);
  background: rgba(9, 11, 12, .9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--text);
  font: 650 14px/1 ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
}

.brand-mark,
.preview-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(104, 224, 160, .45);
  border-radius: 8px;
  color: var(--green);
  background: rgba(104, 224, 160, .1);
  font-size: 13px;
  font-weight: 800;
}

.primary-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.nav-button {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 13px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.nav-button:hover { color: var(--text); }

.nav-button.is-active {
  border-color: var(--line);
  color: var(--green);
  background: var(--surface-2);
}

.account-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.account-label {
  max-width: 290px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 64px;
}

.hero { padding: clamp(60px, 9vw, 104px) 0 clamp(44px, 7vw, 76px); }

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

h1 {
  max-width: 820px;
  margin: 0;
  font: 600 clamp(38px, 6vw, 70px)/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -.05em;
}

.hero-copy {
  max-width: 660px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.7vw, 17px);
  line-height: 1.65;
}

.content-section {
  overflow: hidden;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(23, 27, 30, .94), rgba(14, 17, 18, .94));
  box-shadow: 0 14px 50px rgba(0, 0, 0, .18);
}

.content-section.is-hidden { display: none; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

h2 {
  margin: 0;
  font: 600 clamp(25px, 3vw, 36px)/1.1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -.035em;
}

.space-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.space-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  transition: border-color 140ms ease, transform 140ms ease;
}

.space-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.space-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(104, 224, 160, .08), rgba(17, 20, 22, .25)),
    repeating-linear-gradient(90deg, #141819 0, #141819 24px, #181d1f 24px, #181d1f 25px);
}

.space-preview .preview-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 19px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.space-card-body { padding: 18px; }

.space-meta {
  min-height: 18px;
  color: var(--blue);
  font-size: 11px;
}

.space-title {
  margin: 7px 0;
  font: 600 19px/1.25 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -.02em;
}

.space-description {
  min-height: 66px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.space-admins {
  margin-top: 12px;
  color: var(--green);
  font-size: 10px;
  line-height: 1.5;
}

.space-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:disabled { cursor: wait; opacity: .48; }

.button-primary {
  border-color: rgba(104, 224, 160, .45);
  color: var(--green);
  background: rgba(104, 224, 160, .1);
}

.button-primary:hover:not(:disabled) { background: rgba(104, 224, 160, .16); }

.button-secondary {
  border-color: var(--line);
  color: var(--blue);
  background: var(--surface-2);
}

.button-secondary:hover:not(:disabled) { border-color: rgba(118, 183, 255, .55); }

.button-block { width: 100%; }

.status-message {
  min-height: 20px;
  margin: -10px 0 16px;
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 22px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.user-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(41, 47, 51, .72);
}

.user-row:last-child { border-bottom: 0; }
.user-email { color: var(--text); }
.user-account { margin-top: 3px; color: var(--muted); font-size: 10px; }

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.role-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.role-badge.is-admin { color: var(--green); }

.modal {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: transparent;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .55);
}

.modal-wide { width: min(620px, calc(100% - 32px)); }

.modal::backdrop {
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(5px);
}

.modal-card {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: linear-gradient(145deg, rgba(23, 27, 30, .99), rgba(14, 17, 18, .99));
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal-heading h2 { font-size: 28px; }

.icon-button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) { color: var(--text); }
.icon-button:disabled { cursor: wait; opacity: .45; }

.modal-copy {
  margin: 13px 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.danger-note {
  margin: 0 0 18px;
  padding: 11px 12px;
  border: 1px solid rgba(240, 195, 108, .34);
  border-radius: 8px;
  color: var(--amber);
  background: rgba(240, 195, 108, .07);
  font-size: 11px;
  line-height: 1.55;
}

.danger-note code { color: var(--text); }

.access-list {
  display: grid;
  gap: 7px;
  margin: 0 0 18px;
}

.access-list-heading {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.access-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 7px 9px 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 11px;
}

.access-member .text-button {
  margin: 0;
  color: var(--red);
}

.access-list-empty {
  padding: 10px 11px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
}

.access-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
  padding: 0;
  border: 0;
}

.access-choice legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.access-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}

.access-option:has(input:checked) {
  border-color: rgba(104, 224, 160, .48);
  background: rgba(104, 224, 160, .07);
}

.access-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--green);
}

.access-option input:focus-visible { outline: 0; }

.access-option:has(input:focus-visible) {
  box-shadow: 0 0 0 2px rgba(104, 224, 160, .2);
}

.access-option span { display: grid; gap: 3px; }
.access-option strong { color: var(--text); font-size: 12px; }
.access-option small { color: var(--muted); font-size: 10px; line-height: 1.35; }

.field {
  display: grid;
  gap: 7px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  outline: 0;
  color: var(--text);
  background: var(--surface);
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.field input:disabled { opacity: .55; }

.domain-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.domain-field:focus-within {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.domain-field input { min-width: 0; border: 0; box-shadow: none; }
.domain-field input:focus { box-shadow: none; }
.domain-field span { padding-right: 11px; color: var(--muted); font-weight: 500; }

.optional,
.field-help { color: var(--muted); font-weight: 450; }
.field-help { margin: 7px 0 0; font-size: 10px; }

.confirm-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  cursor: pointer;
}

.confirm-field input {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  accent-color: var(--green);
}

.form-error {
  min-height: 20px;
  margin: 13px 0 7px;
  color: var(--red);
  font-size: 11px;
}

.text-button {
  display: block;
  margin: 15px auto 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.text-button:hover { color: var(--text); }

@media (max-width: 900px) {
  .site-header { grid-template-columns: 1fr auto; }
  .primary-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .space-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .site-header { gap: 12px; padding: 11px 14px; }
  .brand span:last-child,
  .account-label { display: none; }
  .account-actions .button { min-height: 34px; padding: 7px 9px; font-size: 11px; }
  main { width: min(100% - 28px, 1320px); }
  .hero { padding-top: 48px; }
  .content-section { padding: 18px; }
  .section-heading { align-items: flex-start; }
  .space-grid { grid-template-columns: 1fr; }
  .space-description { min-height: 0; }
  .access-choice { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: minmax(0, 1fr) auto; }
  .user-row .button { grid-column: 1 / -1; width: 100%; }
}
