:root {
  color-scheme: light;
  --color-background: #fafafa;
  --color-foreground: #111111;
  --color-muted: #666666;
  --color-subtle: #8a8f98;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-surface: #ffffff;
  --color-surface-soft: #f7f7f8;
  --color-primary: #111111;
  --color-primary-hover: #333333;
  --color-link: #0969da;
  --color-success: #047857;
  --color-warning: #a16207;
  --color-danger: #b42318;
  --radius: 8px;
  --topbar-height: 64px;
  --next-body-font-size: 14px;
  --next-ui-font-size: 13px;
  --next-brand-title-size: 20px;
  --next-heading-size: 24px;
  --next-section-title-size: 18px;
  --next-card-number-size: 22px;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --line: #dce3ea;
  --line-strong: #c8d2dc;
  --text: #111827;
  --muted: #667085;
  --accent: #0969da;
  --accent-strong: #0550ae;
  --success: #0f7b45;
  --warning: #9a6700;
  --danger: #b42318;
  --shadow: 0 14px 36px rgba(17, 24, 39, 0.07);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
.button-link {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  cursor: progress;
  opacity: .65;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.secondary {
  background: var(--surface-soft);
}

.danger {
  border-color: #f2b8b5;
  color: var(--danger);
}

.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}

.brand img {
  display: block;
  width: 190px;
  max-width: 38vw;
  height: auto;
}

.brand span {
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions a {
  color: var(--muted);
}

.topbar-actions a:hover {
  color: var(--accent);
}

.user-chip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 10px;
  color: var(--text);
}

.workspace {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.sidebar {
  position: sticky;
  top: 68px;
  align-self: start;
  height: calc(100vh - 68px);
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.nav-item {
  display: block;
  width: 100%;
  margin: 2px 0;
  border-color: transparent;
  background: transparent;
  text-align: left;
  color: #344054;
}

.nav-item.is-active {
  border-color: #b6d7ff;
  background: #eef6ff;
  color: var(--accent-strong);
}

.content {
  display: grid;
  gap: 18px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
}

.panel.is-active,
.panel.log-panel {
  display: block;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 15px;
}

p {
  margin: 8px 0 0;
  line-height: 1.6;
  color: var(--muted);
}

.lede {
  max-width: 880px;
  color: #475467;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stats div,
.guide-grid article,
.note-box,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.stats strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.compact {
  margin-top: 18px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 330px;
}

.owner-cell {
  display: grid;
  gap: 3px;
  min-width: 130px;
}

.muted-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.status {
  display: inline-flex;
  min-width: 68px;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef4ff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.status-running {
  background: #e9f8ef;
  color: var(--success);
}

.status-failed,
.status-deleted {
  background: #fff1f0;
  color: var(--danger);
}

.status-stopped {
  background: #fff8e6;
  color: var(--warning);
}

.mono {
  margin-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

.stack-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 650;
}

label.full,
.form-actions.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
}

.inline-select {
  width: auto;
  min-width: 108px;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 13px;
}

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

small {
  color: var(--muted);
  font-weight: 400;
  line-height: 1.45;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(260px, 1fr);
  gap: 18px;
}

.note-box p + p {
  margin-top: 12px;
}

.skill-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.skill-preview-item {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.skill-preview-item strong,
.skill-preview-item small {
  overflow-wrap: anywhere;
}

.skill-preview-item strong {
  font-size: 13px;
}

.skill-choice {
  flex-direction: row;
  align-items: flex-start;
  cursor: pointer;
}

.skill-choice input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.skill-choice-copy {
  display: inline-flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.instance-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 260px;
}

.instance-skill-chip,
.instance-skill-more {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 140px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instance-skill-more {
  color: var(--muted);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.check-line input {
  width: 16px;
  height: 16px;
}

.empty-state {
  max-width: 760px;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
}

.log-panel {
  box-shadow: none;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

pre {
  min-height: 140px;
  max-height: 380px;
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #0b1220;
  color: #dbe7ff;
  padding: 14px;
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    min-height: 68px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

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

  .sidebar {
    position: static;
    height: auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    min-width: max-content;
  }

  .content {
    padding: 16px;
  }

  .stats,
  .guide-grid,
  .form-grid,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .brand img {
    max-width: 72vw;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .panel {
    padding: 16px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Next.js / Vercel style console shell */
body {
  background: var(--color-background);
  color: var(--color-foreground);
  font-size: var(--next-body-font-size);
}

.app-shell {
  min-height: 100vh;
  background: var(--color-background);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, .92);
  padding: 0 24px;
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--color-foreground);
  font-weight: 700;
}

.brand-lockup img {
  display: block;
  width: 142px;
  max-width: 28vw;
  height: auto;
}

.brand-title {
  font-size: var(--next-brand-title-size);
  font-weight: 720;
  line-height: 1.1;
  white-space: nowrap;
}

.account-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-muted);
  font-size: var(--next-ui-font-size);
}

.account-nav a {
  color: var(--color-muted);
}

.account-nav a:hover {
  color: var(--color-foreground);
}

.account-pill {
  max-width: 180px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-foreground);
  padding: 5px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-layout {
  display: grid;
  grid-template-columns: 204px minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-height));
}

.app-sidebar {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  height: calc(100vh - var(--topbar-height));
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 14px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 32px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #4b5563;
  padding: 7px 9px;
  text-align: left;
  font-size: var(--next-ui-font-size);
  font-weight: 560;
}

.nav-link:hover {
  border-color: var(--color-border);
  background: var(--color-surface-soft);
  color: var(--color-foreground);
}

.nav-link.is-active {
  border-color: var(--color-foreground);
  background: var(--color-foreground);
  color: #ffffff;
}

.nav-anchor {
  justify-content: flex-start;
}

.app-main {
  display: grid;
  gap: 16px;
  min-width: 0;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 22px;
}

.workspace-panel {
  display: none;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 18px;
}

.workspace-panel.is-active,
.workspace-panel.log-panel {
  display: block;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

h1 {
  font-size: var(--next-heading-size);
  font-weight: 680;
  line-height: 1.25;
}

h2 {
  font-size: var(--next-section-title-size);
  font-weight: 680;
  line-height: 1.35;
}

h3 {
  font-size: var(--next-body-font-size);
  font-weight: 650;
  line-height: 1.4;
}

p {
  line-height: 1.55;
}

.lead-copy {
  max-width: 820px;
  color: #4b5563;
  font-size: var(--next-body-font-size);
}

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

.metric-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 13px;
}

.metric-card strong {
  display: block;
  font-size: var(--next-card-number-size);
  font-weight: 680;
  line-height: 1;
}

.metric-card span {
  display: block;
  margin-top: 6px;
  color: var(--color-muted);
  font-size: 12px;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.resource-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-soft);
  padding: 13px;
}

.step-index {
  display: block;
  margin-bottom: 8px;
  color: var(--color-subtle);
  font-size: 11px;
  font-weight: 700;
}

table {
  font-size: var(--next-ui-font-size);
}

th,
td {
  padding: 10px 9px;
}

th {
  font-size: 11px;
}

label {
  gap: 6px;
  font-size: var(--next-ui-font-size);
}

input,
select,
textarea {
  padding: 9px 10px;
  font-size: var(--next-ui-font-size);
}

small {
  font-size: 12px;
}

.form-error {
  color: var(--color-danger);
}

.command-button {
  min-height: 34px;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: var(--color-primary);
  color: #ffffff;
  padding: 7px 11px;
  font: inherit;
  font-size: var(--next-ui-font-size);
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}

.command-button:hover {
  border-color: var(--color-primary-hover);
  background: var(--color-primary-hover);
  color: #ffffff;
}

.button-secondary {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-foreground);
  padding: 7px 11px;
  font: inherit;
  font-size: var(--next-ui-font-size);
  font-weight: 600;
  white-space: nowrap;
}

.button-secondary:hover {
  border-color: var(--color-foreground);
  color: var(--color-foreground);
}

.button-danger {
  border-color: #f1b8b5;
  color: var(--color-danger);
}

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

.status {
  display: inline-flex;
  min-width: 62px;
  justify-content: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
}

.status-running {
  background: #ecfdf5;
  color: var(--color-success);
}

.status-failed,
.status-deleted {
  background: #fff1f0;
  color: var(--color-danger);
}

.status-stopped {
  background: #fefce8;
  color: var(--color-warning);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-foreground);
  outline: 2px solid rgba(17, 17, 17, .08);
  outline-offset: 0;
}

.note-box,
.empty-state {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-soft);
}

.log-panel {
  background: var(--color-surface);
}

pre {
  border: 1px solid #1f2937;
}

.kb-workbench-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.kb-workbench {
  display: grid;
  grid-template-columns: minmax(190px, 220px) minmax(0, 1fr) minmax(220px, 280px);
  gap: 14px;
  align-items: start;
  margin-top: 18px;
}

.kb-rail,
.kb-main,
.kb-action-rail,
.kb-inline-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.kb-rail,
.kb-action-rail {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.kb-main {
  min-width: 0;
  overflow: hidden;
}

.kb-rail-toolbar,
.kb-filter-row,
.kb-inline-panel-header,
.kb-selected-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.kb-search-label {
  width: 100%;
}

.kb-rail-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
}

.kb-rail-item {
  display: grid;
  width: 100%;
  gap: 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-soft);
  padding: 9px;
  color: var(--color-foreground);
  text-align: left;
}

.kb-rail-item.is-active {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.kb-rail-item-title,
.kb-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.kb-meta-row,
.kb-count-row,
.kb-provenance-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.kb-selected-header {
  border-bottom: 1px solid var(--color-border);
  padding: 14px;
}

.kb-selected-header h3,
.kb-inline-panel h3 {
  margin: 0;
  font-size: var(--next-section-title-size);
  line-height: 1.25;
}

.kb-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
  padding: 8px 10px 0;
}

.kb-tab {
  min-height: 34px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 8px 10px;
  color: var(--color-muted);
}

.kb-tab.is-active {
  border-bottom-color: var(--color-primary);
  color: var(--color-foreground);
}

.kb-tab-content {
  min-height: 420px;
  padding: 12px;
}

.kb-page-browser {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.kb-page-list,
.kb-reader,
.kb-status-card,
.kb-source-list,
.kb-job-list,
.kb-review-list,
.kb-binding-list {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-soft);
}

.kb-page-list,
.kb-reader,
.kb-source-list,
.kb-job-list,
.kb-review-list,
.kb-binding-list {
  min-width: 0;
  padding: 10px;
}

.kb-source-list,
.kb-job-list,
.kb-review-list,
.kb-binding-list {
  overflow-x: auto;
}

.kb-source-table {
  table-layout: fixed;
}

.kb-source-select-cell {
  width: 68px;
}

.kb-source-file-cell {
  width: 190px;
}

.kb-source-mime-cell {
  width: 240px;
}

.kb-source-status-cell {
  width: 120px;
}

.kb-source-analysis-cell {
  white-space: nowrap;
}

.kb-source-processed-cell {
  width: 160px;
}

.kb-source-text-cell {
  width: 80px;
}

.kb-source-checksum-cell {
  width: 110px;
}

.kb-source-actions-cell {
  width: 170px;
}

.kb-source-file {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kb-analysis-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  background: #f8fafc;
  color: #334155;
}

.kb-analysis-badge.cached {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.kb-analysis-badge.missing,
.kb-analysis-badge.stale {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.kb-analysis-badge.failed {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.kb-ingest-notice {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-soft);
  margin-bottom: 10px;
  padding: 12px;
}

.kb-ingest-notice.success {
  border-color: rgba(4, 120, 87, .24);
  background: #ecfdf5;
}

.kb-ingest-notice.error {
  border-color: rgba(185, 28, 28, .24);
  background: #fef2f2;
}

.kb-ingest-notice p {
  margin: 4px 0 0;
  color: var(--color-muted);
}

.kb-source-row.is-inactive {
  color: var(--color-muted);
  background: #f9fafb;
}

.kb-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

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

.kb-compare-grid section {
  min-width: 0;
}

.kb-action-stack.horizontal {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.kb-action-stack.horizontal button {
  width: auto;
}

.kb-review-list .kb-list-button.is-active {
  background: #f9fafb;
}

.kb-workbench .mono {
  overflow-wrap: anywhere;
}

.kb-list-stack {
  display: grid;
  gap: 8px;
}

.kb-list-button {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 6px;
  padding: 9px;
  text-align: left;
  white-space: normal;
}

.kb-list-button.is-active {
  border-color: var(--color-primary);
}

.kb-reader-content {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-foreground);
  line-height: 1.7;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.kb-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--color-link);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.kb-status-badge.warning {
  background: #fff7ed;
  color: var(--color-warning);
}

.kb-status-badge.danger {
  background: #fef2f2;
  color: var(--color-danger);
}

.kb-status-badge.success {
  background: #ecfdf3;
  color: var(--color-success);
}

.kb-status-badge.archived {
  background: #f3f4f6;
  color: #4b5563;
}

.kb-status-badge.replaced {
  background: #fffbeb;
  color: #b45309;
}

.kb-status-badge.stale {
  background: #fef2f2;
  color: #b91c1c;
}

.kb-action-stack {
  display: grid;
  gap: 8px;
}

.kb-action-stack button {
  width: 100%;
  max-width: 100%;
}

.kb-inline-panel {
  margin-top: 14px;
  padding: 14px;
}

.kb-inline-panel[hidden] {
  display: none;
}

.kb-inline-panel-header {
  margin-bottom: 12px;
}

.kb-upload-label {
  display: grid;
  gap: 8px;
}

.kb-upload-dropzone {
  display: grid;
  min-height: 112px;
  align-content: center;
  gap: 12px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius);
  background: #f8fbff;
  padding: 18px;
  transition: border-color .16s ease, background .16s ease;
}

.kb-upload-dropzone.is-dragover,
.kb-upload-dropzone:focus-within {
  border-color: var(--color-link);
  background: #eef6ff;
}

.kb-upload-dropzone-copy {
  display: grid;
  gap: 4px;
  color: var(--color-muted);
}

.kb-upload-dropzone-copy strong {
  color: var(--color-foreground);
  font-size: 15px;
}

.kb-upload-dropzone input[type="file"] {
  width: 100%;
}

.kb-empty {
  border: 1px dashed var(--color-border-strong);
  border-radius: 6px;
  color: var(--color-muted);
  padding: 14px;
}

@media (max-width: 980px) {
  .app-topbar {
    min-height: var(--topbar-height);
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

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

  .app-sidebar {
    position: static;
    display: flex;
    height: auto;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-link {
    width: auto;
    min-width: max-content;
  }

  .app-main {
    padding: 16px;
  }

  .metric-grid,
  .resource-grid,
  .form-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .kb-workbench {
    grid-template-columns: 1fr;
  }

  .kb-rail-list {
    max-height: 260px;
  }

  .kb-page-browser {
    grid-template-columns: 1fr;
  }

  .kb-compare-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .brand-lockup img {
    width: min(210px, 82vw);
    max-width: none;
  }

  .account-nav {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .workspace-panel {
    padding: 16px;
  }

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

  .command-button,
  .button-secondary {
    width: max-content;
    max-width: 100%;
  }

  .actions {
    min-width: 260px;
  }

  .kb-workbench-header-actions,
  .kb-filter-row,
  .kb-inline-panel-header,
  .kb-selected-header {
    align-items: stretch;
    flex-direction: column;
  }

  .kb-tabs {
    padding-inline: 0;
  }

  .kb-tab {
    min-width: max-content;
  }
}

/* Auth and account settings surfaces */
.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 460px);
  gap: 24px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 22px 44px;
}

.auth-copy {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 30px 4px 0;
}

.auth-copy h1 {
  max-width: 650px;
  font-size: 34px;
  line-height: 1.16;
}

.auth-copy .lead-copy {
  max-width: 660px;
  font-size: 15px;
}

.auth-points {
  display: grid;
  gap: 12px;
  max-width: 660px;
  margin-top: 8px;
}

.auth-point {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.auth-point strong,
.auth-point span {
  display: block;
}

.auth-point strong {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 670;
}

.auth-point span {
  color: var(--color-muted);
  line-height: 1.55;
}

.auth-panel {
  align-self: start;
  display: block;
  padding: 20px;
}

.auth-form {
  grid-template-columns: 1fr;
  margin-top: 4px;
}

.auth-passport-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.auth-captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: center;
}

.auth-captcha-row img {
  width: 120px;
  height: 40px;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  background: var(--color-surface-soft);
  cursor: pointer;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2px;
  font-size: var(--next-ui-font-size);
}

.auth-links a {
  color: var(--color-muted);
}

.auth-links a:hover {
  color: var(--color-foreground);
}

.sidebar-divider {
  height: 1px;
  margin: 10px 8px;
  background: var(--color-border);
}

.profile-panel {
  display: block;
}

.profile-form {
  margin-top: 18px;
}

input[readonly] {
  background: var(--color-surface-soft);
  color: var(--color-muted);
}

@media (max-width: 980px) {
  .auth-layout {
    grid-template-columns: 1fr;
    padding: 20px 16px 32px;
  }

  .auth-copy {
    padding-top: 4px;
  }
}

@media (max-width: 640px) {
  .auth-copy h1 {
    font-size: 28px;
  }

  .auth-captcha-row {
    grid-template-columns: 1fr;
  }
}
