:root {
  --radius: 0.75rem;
  --radius-md: calc(var(--radius) - 2px);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-2xl: calc(var(--radius) + 8px);
  --radius-3xl: calc(var(--radius) + 12px);
  --background: oklch(0.975 0.01 85);
  --foreground: oklch(0.24 0.025 160);
  --card: oklch(0.993 0.005 85);
  --primary: oklch(0.42 0.065 150);
  --primary-foreground: oklch(0.98 0.01 85);
  --secondary: oklch(0.93 0.025 120);
  --secondary-foreground: oklch(0.3 0.05 150);
  --muted: oklch(0.945 0.012 85);
  --muted-foreground: oklch(0.5 0.02 150);
  --accent: oklch(0.92 0.035 60);
  --accent-foreground: oklch(0.32 0.06 45);
  --clay: oklch(0.64 0.13 45);
  --warning: oklch(0.72 0.14 75);
  --border: oklch(0.88 0.015 90);
  --input: oklch(0.86 0.018 90);
  --ring: oklch(0.42 0.065 150);
  --shadow-soft: 0 1px 2px oklch(0.24 0.025 160 / 6%), 0 12px 32px -12px oklch(0.24 0.025 160 / 18%);
  --shadow-lift: 0 24px 60px -24px oklch(0.24 0.025 160 / 35%);
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Figtree", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--foreground);
  background: var(--background);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--secondary); color: var(--foreground); }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

img, svg { max-width: 100%; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.skip:focus { top: 12px; }

.wrap {
  width: min(72rem, calc(100% - 2.5rem));
  margin: 0 auto;
}

.host-warning {
  background: color-mix(in oklch, var(--warning) 28%, var(--card));
  border-bottom: 1px solid color-mix(in oklch, var(--warning) 55%, var(--border));
  padding: 12px 16px;
  text-align: center;
  overflow-wrap: anywhere;
}

.site-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklch, var(--background) 90%, transparent);
  border-bottom: 1px solid var(--border);
}

.site-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  backdrop-filter: blur(12px);
}

.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 4rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: inherit;
}

.logo .mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-md);
  background: var(--primary);
}

.logo .mark::after {
  content: "";
  width: 0.375rem;
  height: 0.875rem;
  border-radius: 0.125rem;
  background: var(--clay);
}

.shell {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  min-height: 100vh;
}

.shell-main { min-width: 0; }

.shell .wrap { width: min(72rem, calc(100% - 3rem)); }

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100vh;
  padding: 1rem 0.875rem;
  background: var(--card);
  border-right: 1px solid var(--border);
}

.rail-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
}

.desk-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.75rem 0 0;
}

.desk-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.desk-nav a svg { width: 1.125rem; height: 1.125rem; flex: 0 0 auto; }

.desk-nav a:hover { background: var(--accent); color: var(--accent-foreground); }

.desk-nav a[aria-current="page"] {
  background: var(--primary);
  color: var(--primary-foreground);
}

.desk-nav a[aria-current="page"]:hover {
  background: color-mix(in oklch, var(--primary) 90%, black);
  color: var(--primary-foreground);
}

.rail .sign-out { width: 100%; margin-top: auto; }

button.menu-button { display: none; }

.menu-button {
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
}

.menu-button:hover { background: var(--accent); color: var(--accent-foreground); }

.menu-button svg { width: 1.125rem; height: 1.125rem; }

.menu-button .icon-close { display: none; }

.menu-button[aria-expanded="true"] .icon-menu { display: none; }

.menu-button[aria-expanded="true"] .icon-close { display: block; }

.button, .text-button, .text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}

.button {
  height: 2.25rem;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 1px 2px oklch(0.24 0.025 160 / 12%);
  white-space: nowrap;
}

.button:hover:not(:disabled) { background: color-mix(in oklch, var(--primary) 90%, black); }

.button:disabled { opacity: 0.5; cursor: not-allowed; }

.button.light {
  background: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: 0 1px 2px oklch(0.24 0.025 160 / 8%);
}

.button.light:hover:not(:disabled) { background: color-mix(in oklch, var(--secondary) 80%, white); }

.button.ghost {
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 2px oklch(0.24 0.025 160 / 6%);
}

.button.ghost:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }

.text-button, .text-link {
  min-height: 2.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  justify-content: flex-start;
}

.text-button:hover, .text-link:hover { color: color-mix(in oklch, var(--primary) 75%, black); }

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

h1 { font-size: 2.25rem; line-height: 1.05; margin: 0; }

h2 { font-size: 1.5rem; line-height: 1.15; margin: 0; }

h3 { font-size: 1.25rem; line-height: 1.3; margin: 0; }

.auth-layout h1 { margin-top: 1rem; }

.lede {
  margin: 1.5rem 0 0;
  max-width: 36rem;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

.auth-layout {
  display: grid;
  gap: 2.5rem;
  align-items: start;
  padding: 2.5rem 0 4rem;
}

.page-intro h1 { margin-top: 0.75rem; }

.steps {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--clay);
}

details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0.25rem 1rem 0.75rem;
}

.card details { background: var(--background); }

summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  font-weight: 600;
  cursor: pointer;
}

details > .stack,
details > form { margin-top: 0.25rem; }

.panel, .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-soft);
  overflow-wrap: break-word;
}

.panel { padding: 1.5rem; }

.card {
  display: grid;
  gap: 0.5rem;
  padding: 1.25rem;
  min-width: 0;
}

.card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-soft);
}

.card p, .panel p { margin: 0; }

.stack { display: grid; gap: 1rem; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

.split > * { min-width: 0; }

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.limits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
}

label { display: grid; gap: 0.375rem; font-size: 0.875rem; font-weight: 500; min-width: 0; }

label .hint { font-weight: 400; }

label.check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 1.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}

label.check input,
label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-height: 1rem;
  accent-color: var(--primary);
}

input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 2.5rem;
  border: 1px solid var(--input);
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.3;
}

input[readonly] { background: var(--muted); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235c675f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.25rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.hint { margin: 0; color: var(--muted-foreground); font-size: 0.875rem; }

.form-error { margin: 0; color: var(--clay); font-weight: 600; }

.banner {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xl);
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 0.875rem;
}

.view { display: grid; gap: 1.5rem; padding: 1.75rem 0 4.5rem; }

.view h1 { font-size: 2.25rem; }

.view-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  justify-content: space-between;
}

.view-head .button { flex: 0 0 auto; }

.search { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }

.search label { flex: 1 1 14rem; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.empty {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
  background: color-mix(in oklch, var(--muted) 50%, transparent);
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.list { display: grid; gap: 1rem; }

.item-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.item-title {
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.item-top .pill { flex: 0 0 auto; }

.meta { color: var(--muted-foreground); font-size: 0.875rem; overflow-wrap: anywhere; }

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 1.75rem;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
}

.desk-mark {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.invite-link { font-family: var(--font-mono); font-size: 0.75rem; }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.facts > div {
  min-width: 0;
  padding: 1rem 1.25rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.facts dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.facts dd {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.fine-print {
  margin: 0;
  padding: 0 0 2.5rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

@media (max-width: 860px) {
  .shell { display: block; }

  .shell .wrap { width: min(72rem, calc(100% - 2.5rem)); }

  .rail {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    padding: 0.65rem 0.875rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: color-mix(in oklch, var(--card) 92%, transparent);
    backdrop-filter: blur(12px);
  }

  button.menu-button { display: inline-flex; margin-left: auto; }

  .rail .sign-out { display: none; margin-top: 0.5rem; }

  .rail:has(.desk-nav.is-open) .sign-out { display: inline-flex; }

  .desk-nav { display: none; margin: 0.5rem 0 0.25rem; }

  .desk-nav.is-open { display: flex; }

  .desk-nav a { min-height: 2.75rem; font-size: 1.125rem; }

  .panel > .button,
  .stack > .button,
  .copy-row > .button { width: 100%; }

  .fine-print { padding-bottom: calc(1.75rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .split, .copy-row, .search-row { grid-template-columns: 1fr; }

  .search { flex-direction: column; align-items: stretch; }

  .search label { flex-basis: auto; }

  .search-row .button, .search .button { width: 100%; }

  .actions { flex-direction: column; align-items: stretch; }

  .actions .button { width: 100%; }

  .pager { align-items: stretch; }

  .pager .button { flex: 1; }
}

@media (min-width: 861px) {
  .auth-layout {
    grid-template-columns: 1.1fr 0.9fr;
    padding-top: 4rem;
  }

  .auth-layout h1 { font-size: 3.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
