:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --ink: #17202a;
  --muted: #60707d;
  --line: #d9dee3;
  --line-strong: #b8c1ca;
  --blue: #1d5f96;
  --blue-soft: #e3eef8;
  --green: #16614a;
  --green-soft: #dff2eb;
  --red: #b43f3f;
  --red-soft: #f7e4e4;
  --amber: #a96a1d;
  --amber-soft: #f8eddb;
  --shadow: 0 16px 42px rgba(23, 32, 42, 0.1);
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

#observablehq-main:has(.docs-repo-app),
#observablehq-main:has(.docs-repo-app) #observablehq-center,
#observablehq-main:has(.docs-repo-app) .observablehq {
  max-width: none !important;
  width: 100%;
  margin: 0 !important;
  padding: 0 !important;
}

body:has(.docs-repo-app) #observablehq-header,
body:has(.docs-repo-app) #observablehq-sidebar-toggle,
body:has(.docs-repo-app) #observablehq-sidebar-backdrop,
body:has(.docs-repo-app) #observablehq-sidebar,
body:has(.docs-repo-app) #observablehq-toc,
body:has(.docs-repo-app) #observablehq-footer {
  display: none !important;
}

body:has(.docs-repo-app) #observablehq-center,
body:has(.docs-repo-app) #observablehq-main {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

#observablehq-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}

.framework-header {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.framework-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.framework-header a {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.framework-header a:hover,
.framework-header a:focus-visible {
  background: var(--blue-soft);
  color: var(--blue);
}

.framework-signout {
  margin-left: auto;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

body:not(:has(.docs-repo-app[data-session="authenticated"])) .framework-signout {
  display: none;
}

.framework-home,
.framework-footer {
  color: var(--ink);
  font-weight: 800;
}

.framework-home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.framework-home::before {
  content: "DR";
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.docs-repo-app {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
}

.docs-repo-app * {
  box-sizing: border-box;
  letter-spacing: 0;
  min-width: 0;
}

.docs-repo-app :where(h1, h2, h3, p, a, button, label, span, strong, em, dd, dt) {
  max-width: 100%;
}

.docs-repo-app :where(h1, h2, h3, p, dd, dt, strong, em, span) {
  overflow-wrap: anywhere;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f9faf9, #eef2f5);
}

.auth-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-lockup,
.app-brand,
.project-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.project-avatar {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 900;
}

.brand-lockup strong,
.app-brand strong {
  display: block;
  font-size: 15px;
}

.brand-lockup em,
.app-brand em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.auth-panel h1,
.workspace-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.12;
}

.section-kicker {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-actions,
.workspace-actions,
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.primary-action,
.secondary-action,
.link-action,
.icon-button,
.view-switcher button,
.project-row,
.file-row {
  min-height: 34px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-action,
.secondary-action,
.link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid transparent;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.primary-action {
  background: var(--blue);
  color: #ffffff;
}

.secondary-action {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.link-action {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
}

.primary-action:disabled,
.secondary-action:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.icon-button.danger {
  color: var(--red);
}

.app-alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.app-alert.error {
  background: var(--red-soft);
  color: var(--red);
}

.app-alert.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px);
}

.app-brand {
  color: inherit;
  text-decoration: none;
}

.view-switcher {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.view-switcher button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.view-switcher button.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: 0 4px 12px rgba(23, 32, 42, 0.08);
}

.topbar-actions {
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status-pill.connected {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.demo {
  background: var(--amber-soft);
  color: var(--amber);
}

.docs-repo-shell {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  min-height: calc(100vh - 54px);
  width: 100%;
  max-width: 100vw;
}

.project-rail {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  min-height: calc(100vh - 54px);
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.create-project-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.create-project-form label,
.search-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.create-project-form input,
.create-project-form textarea,
.search-control input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.create-project-form input,
.create-project-form textarea {
  padding: 8px 10px;
}

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

.project-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.project-row.active {
  border-color: color-mix(in srgb, var(--blue) 44%, var(--line));
  background: var(--blue-soft);
}

.project-row strong,
.project-row em {
  display: block;
}

.project-row strong {
  font-size: 14px;
}

.project-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.project-row small {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 900;
}

.reset-demo {
  justify-self: start;
  gap: 6px;
}

.workspace-main {
  display: grid;
  align-content: start;
  gap: 12px;
  width: 100%;
  max-width: 100vw;
  padding: 14px;
}

.workspace-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.search-control {
  position: relative;
  width: min(280px, 42vw);
}

.search-control svg {
  position: absolute;
  left: 10px;
  bottom: 9px;
  color: var(--muted);
}

.search-control input {
  padding: 8px 10px 8px 36px;
}

.file-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 12px;
}

.file-list-panel,
.metadata-panel,
.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(23, 32, 42, 0.04);
}

.file-list-panel {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 12px;
  padding: 12px;
}

.upload-zone {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 900;
}

.file-table {
  display: grid;
  align-self: start;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  min-width: 0;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.file-row:not(.file-header) {
  cursor: pointer;
}

.file-row:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row.active {
  background: var(--blue-soft);
}

.file-header {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 36px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: default;
}

.file-row span:nth-child(2),
.file-row span:nth-child(4) {
  display: none;
}

.file-row span:nth-child(3) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.file-row-actions {
  display: flex;
  justify-content: flex-end;
}

.file-row strong,
.file-row em {
  display: block;
}

.file-row strong {
  font-size: 14px;
}

.file-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.metadata-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.panel-title h2,
.project-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.metadata-list,
.project-facts {
  display: grid;
  gap: 0;
  margin: 0;
}

.metadata-list div,
.project-facts div {
  display: grid;
  grid-template-columns: minmax(92px, 0.45fr) minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.metadata-list dt,
.project-facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metadata-list dd,
.project-facts dd {
  margin: 0;
  font-size: 13px;
}

.metadata-json {
  display: grid;
  gap: 8px;
}

.metadata-json span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metadata-json pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}

.project-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
}

.project-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.project-avatar {
  background: var(--green);
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 96px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 1080px) {
  .docs-repo-shell,
  .file-workspace {
    grid-template-columns: 1fr;
  }

  .project-rail {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .project-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-height: none;
  }

  .app-topbar {
    grid-template-columns: 1fr;
  }

  .view-switcher,
  .topbar-actions {
    justify-self: start;
  }

  .workspace-header {
    align-items: stretch;
    flex-direction: column;
  }

  .search-control {
    width: min(100%, 420px);
  }
}

@media (max-width: 640px) {
  body:has(.docs-repo-app) #observablehq-sidebar-toggle,
  body:has(.docs-repo-app) #observablehq-sidebar-backdrop,
  body:has(.docs-repo-app) #observablehq-sidebar {
    display: none !important;
  }

  #observablehq-main:has(.docs-repo-app),
  #observablehq-main:has(.docs-repo-app) #observablehq-center,
  #observablehq-main:has(.docs-repo-app) .observablehq {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
  }

  #observablehq-center:has(#observablehq-main .docs-repo-app) {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html:has(.docs-repo-app),
  body:has(.docs-repo-app) {
    overflow-x: hidden;
  }

  .docs-repo-app {
    width: 100vw;
    max-width: 100vw;
  }

  .docs-repo-shell,
  .project-rail,
  .workspace-main,
  .file-workspace,
  .file-list-panel,
  .metadata-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .auth-screen,
  .workspace-main,
  .project-rail,
  .app-topbar {
    padding: 12px;
  }

  .auth-panel {
    padding: 18px;
  }

  .workspace-actions,
  .auth-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-header h1 {
    font-size: 30px;
    line-height: 1.12;
  }

  .workspace-actions > *,
  .auth-actions > * {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .metadata-list div,
  .project-facts div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .view-switcher {
    width: 100%;
  }

  .project-list {
    grid-template-columns: 1fr;
  }

  .project-row,
  .file-row {
    width: 100%;
    max-width: 100%;
  }
}
