:root {
  color-scheme: light;
  --bg: oklch(0.975 0.006 255);
  --surface: oklch(0.995 0.002 255);
  --surface-2: oklch(0.955 0.011 250);
  --surface-3: oklch(0.925 0.016 250);
  --ink: oklch(0.185 0.026 255);
  --muted: oklch(0.435 0.028 255);
  --subtle: oklch(0.56 0.026 255);
  --line: oklch(0.875 0.017 250);
  --line-strong: oklch(0.79 0.025 250);
  --accent: oklch(0.48 0.125 248);
  --accent-strong: oklch(0.36 0.115 250);
  --accent-soft: oklch(0.93 0.038 248);
  --success: oklch(0.43 0.095 158);
  --success-soft: oklch(0.93 0.045 158);
  --warning: oklch(0.62 0.12 78);
  --warning-soft: oklch(0.94 0.055 82);
  --danger: oklch(0.49 0.14 28);
  --danger-soft: oklch(0.94 0.045 28);
  --focus: oklch(0.66 0.18 248);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --font-ui: "IBM Plex Sans", "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 10;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-140%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand small,
small,
.hint,
.field-label {
  color: var(--muted);
}

.side-nav {
  display: grid;
  gap: var(--space-1);
}

.side-nav a,
.persona-switcher a {
  display: flex;
  align-items: center;
  min-height: 44px;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-weight: 700;
  transition:
    background-color 160ms ease-out,
    color 160ms ease-out;
}

.side-nav a {
  padding: 0 var(--space-3);
}

.side-nav a:hover,
.side-nav a.active,
.persona-switcher a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.viewer-card,
.persona-switcher {
  display: grid;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.viewer-card strong {
  line-height: 1.2;
}

.persona-switcher {
  margin-top: auto;
}

.persona-switcher div {
  display: grid;
  gap: var(--space-1);
}

.persona-switcher a {
  padding: 0 var(--space-2);
}

.workspace-main {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-7);
}

.mobile-bar {
  display: none;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.section-label,
.field-label {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.section-label {
  color: var(--accent-strong);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 {
  max-width: 760px;
  margin-bottom: var(--space-3);
  font-size: 42px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: var(--space-2);
  font-size: 15px;
}

p {
  color: var(--muted);
  text-wrap: pretty;
}

.lead {
  max-width: 68ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-3);
}

.action-note {
  flex-basis: 100%;
  max-width: 260px;
  margin: calc(-1 * var(--space-1)) 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  font-weight: 800;
  cursor: pointer;
  transition:
    background-color 160ms ease-out,
    border-color 160ms ease-out,
    color 160ms ease-out;
}

.button.primary {
  background: var(--accent);
  color: white;
}

.button.primary:hover {
  background: var(--accent-strong);
}

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

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

.button.disabled,
.button:disabled {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--subtle);
  cursor: not-allowed;
}

.stack-form,
.inline-upload,
.reply-form {
  display: grid;
  gap: var(--space-3);
}

.stack-form {
  margin-bottom: var(--space-5);
}

.stack-form.compact,
.inline-upload {
  border-top: 1px solid var(--line);
  margin-bottom: var(--space-4);
  padding-top: var(--space-4);
}

.inline-upload {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
}

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

label {
  display: grid;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  padding: var(--space-2) var(--space-3);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--line);
  margin-bottom: var(--space-5);
}

.status-strip div {
  display: grid;
  gap: var(--space-1);
  background: var(--surface);
  padding: var(--space-4);
}

.status-strip strong {
  font-size: 28px;
  letter-spacing: -0.03em;
}

.dashboard-grid,
.detail-grid,
.diff-grid {
  display: grid;
  gap: var(--space-5);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  margin-bottom: var(--space-5);
}

.detail-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  margin-bottom: var(--space-5);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-5);
}

.panel + .panel,
.detail-grid + .panel {
  margin-top: var(--space-5);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel-head.compact {
  margin-bottom: var(--space-3);
}

.text-link {
  color: var(--accent-strong);
  font-weight: 800;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.count-pill,
.status,
.decision,
.reactions span {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 var(--space-3);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.collection-list,
.artifact-list,
.request-list,
.version-list,
.comments {
  display: grid;
}

.collection-row,
.artifact-row,
.request-row,
.version-row {
  display: grid;
  align-items: center;
  gap: var(--space-4);
  border-top: 1px solid var(--line);
  padding: var(--space-4) 0;
}

.collection-row:first-child,
.artifact-row:first-child,
.request-row:first-child,
.version-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.collection-row,
.request-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.artifact-row {
  grid-template-columns: 44px minmax(0, 1fr) auto;
}

.version-row {
  grid-template-columns: 48px minmax(0, 1fr) auto;
}

.collection-row:hover strong,
.artifact-row:hover strong,
.text-link:hover {
  color: var(--accent-strong);
}

.artifact-main,
.collection-row span:first-child,
.version-row span:nth-child(2) {
  display: grid;
  gap: var(--space-1);
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  text-align: right;
}

.file-type,
.file-icon,
.version-number,
.avatar {
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--accent-strong);
  font-weight: 850;
}

.file-type,
.version-number,
.avatar {
  width: 40px;
  height: 40px;
}

.file-panel {
  display: grid;
  gap: var(--space-5);
}

.file-summary {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.file-icon {
  width: 72px;
  height: 72px;
  background: var(--ink);
  color: var(--surface);
  font-size: 30px;
}

.file-summary h2 {
  margin: var(--space-2) 0 var(--space-1);
}

.metadata-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
  margin: 0;
}

.metadata-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: var(--space-4);
  background: var(--surface);
  padding: var(--space-3);
}

.metadata-list.compact {
  min-width: 320px;
}

.metadata-list.compact div {
  grid-template-columns: 72px minmax(0, 1fr);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}

.metadata-list.compact div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-weight: 750;
}

dd {
  margin: 0;
  min-width: 0;
}

.activity-list {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.activity-list li {
  position: relative;
  padding-left: var(--space-5);
  color: var(--muted);
}

.activity-list li::before {
  content: "";
  position: absolute;
  top: 0.65em;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.access-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.access-table th,
.access-table td {
  border-top: 1px solid var(--line);
  padding: var(--space-3);
  text-align: left;
  vertical-align: top;
}

.access-table thead th {
  border-top: 0;
  color: var(--muted);
  font-size: 12px;
}

.access-table tbody th {
  color: var(--ink);
  font-weight: 800;
  text-transform: capitalize;
}

.access-table .allowed .decision {
  background: var(--success-soft);
  color: var(--success);
}

.access-table .blocked .decision {
  background: var(--danger-soft);
  color: var(--danger);
}

.request-row h2 {
  margin: var(--space-2) 0 var(--space-1);
}

.request-row p {
  margin-bottom: 0;
}

.diff-panel {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.diff-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.diff-summary span {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: var(--space-2) var(--space-3);
  font-weight: 800;
}

.diff-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.diff-line {
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-family: "IBM Plex Mono", "Aptos Mono", monospace;
  font-size: 13px;
}

.diff-line.added {
  background: var(--success-soft);
  color: var(--success);
}

.diff-line.removed {
  background: var(--danger-soft);
  color: var(--danger);
}

.comments {
  gap: var(--space-4);
}

.comment {
  display: grid;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.comment.reply {
  margin-left: var(--space-6);
  border-left: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.comment header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.comment header span:last-child {
  display: grid;
  gap: 2px;
}

.comment p {
  margin-bottom: 0;
  color: var(--ink);
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.comment-actions button,
.reply-form button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 var(--space-3);
  font-weight: 800;
  cursor: pointer;
}

.reply-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  margin: 0;
  padding: var(--space-4);
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .persona-switcher {
    margin-top: 0;
  }

  .persona-switcher div {
    display: flex;
    flex-wrap: wrap;
  }

  .persona-switcher a {
    padding: 0 var(--space-3);
  }

  .workspace-main {
    width: min(100% - 32px, 1180px);
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    display: none;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .brand.compact .brand-mark {
    width: 36px;
    height: 36px;
  }

  .page-header,
  .dashboard-grid,
  .detail-grid,
  .diff-grid,
  .collection-row,
  .request-row {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions .button {
    flex: 1 1 180px;
  }

  .action-note {
    max-width: none;
    margin-left: 0;
    text-align: left;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .artifact-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .artifact-row .row-meta,
  .collection-row .row-meta {
    grid-column: 1 / -1;
    justify-content: flex-start;
    text-align: left;
  }

  .version-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .version-row .status {
    grid-column: 2;
  }

  .metadata-list div,
  .metadata-list.compact div {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .inline-upload,
  .form-grid,
  .reply-form {
    grid-template-columns: 1fr;
  }

  .metadata-list.compact {
    min-width: 0;
  }

  .access-table,
  .access-table thead,
  .access-table tbody,
  .access-table tr,
  .access-table th,
  .access-table td {
    display: block;
  }

  .access-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .access-table tr {
    border-top: 1px solid var(--line);
    padding: var(--space-3) 0;
  }

  .access-table tr:first-child {
    border-top: 0;
  }

  .access-table th,
  .access-table td {
    border-top: 0;
    padding: var(--space-1) 0;
  }

  .comment.reply {
    margin-left: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
