:root {
  color: #172033;
  background: #eef3f8;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #172033;
  --muted: #64748b;
  --line: #d7dde6;
  --line-strong: #b9c4d0;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #16803c;
  --green-soft: #dcfce7;
  --amber: #a15c07;
  --amber-soft: #fef3c7;
  --red: #b42318;
  --red-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  min-width: 320px;
  min-height: 100vh;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.08), transparent 28rem),
    linear-gradient(135deg, #f8fafc 0%, #eef3f8 42%, #f3f7fb 100%);
}

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

button {
  min-height: 2rem;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  color: #ffffff;
  background: var(--blue);
  cursor: pointer;
  line-height: 1.15;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  min-height: 5.25rem;
  resize: vertical;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem;
  color: #111827;
  background: #f8fafc;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 2.65rem minmax(0, 1fr);
  background: transparent;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-panel {
  width: min(100%, 24rem);
  display: grid;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08), var(--shadow);
}

.auth-panel h1,
.auth-panel p {
  margin: 0;
}

.auth-panel h1 {
  font-size: 1.45rem;
}

.auth-panel p {
  color: var(--muted);
}

.auth-panel button {
  width: fit-content;
}

.auth-identity {
  margin-bottom: 0.25rem;
}

.app-bar {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr) minmax(9rem, 13rem) minmax(12rem, 18rem) auto auto auto;
  gap: 0.55rem;
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.3rem 0.6rem;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.app-identity,
.app-status,
.task-summary,
.library-switcher {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.app-identity strong,
.app-status strong,
.task-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.app-identity span,
.app-status span,
.task-summary span,
.library-switcher span,
.subtle,
.pending-file-list,
.empty-state {
  color: var(--muted);
  font-size: 0.78rem;
}

.library-switcher select {
  min-height: 1.7rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.82rem;
}

.workspace-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(28rem, var(--workspace-explorer-width, 64%), calc(100% - 24rem - 0.5rem)) 0.5rem minmax(24rem, 1fr);
  gap: 0;
  padding: 0.5rem;
}

.workspace-splitter {
  min-width: 0;
  width: 0.5rem;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  cursor: col-resize;
}

.workspace-splitter::before {
  display: block;
  width: 2px;
  height: 100%;
  margin: 0 auto;
  border-radius: 999px;
  background: transparent;
  content: "";
}

.workspace-splitter:hover::before,
.workspace-splitter:focus-visible::before,
.resizing-workspace .workspace-splitter::before {
  background: #93c5fd;
}

.resizing-workspace,
.resizing-preview {
  cursor: col-resize;
  user-select: none;
}

.explorer-pane,
.chat-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06), var(--shadow);
}

.explorer-pane {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.pane-header,
.tool-heading,
.source-title-row,
.button-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.pane-header {
  min-height: 2.7rem;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  background: #fbfcfe;
}

.pane-header h1,
.tool-heading h2,
.chunk-section h3,
.source-title-row h2 {
  margin: 0;
  color: #101827;
  font-weight: 650;
  letter-spacing: 0;
}

.pane-header h1 {
  font-size: 1rem;
}

.tool-heading h2,
.chunk-section h3 {
  font-size: 0.9rem;
}

.source-title-row h2 {
  font-size: 1.15rem;
}

.source-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.source-title-row p,
.chunk-row p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.secondary-button:hover:not(:disabled) {
  background: #eef2f7;
}

.icon-text-button,
.link-button {
  min-height: 1.7rem;
  border-color: transparent;
  padding: 0.15rem 0.35rem;
  color: var(--blue);
  background: transparent;
}

.icon-text-button:hover:not(:disabled),
.link-button:hover:not(:disabled) {
  color: #1d4ed8;
  background: var(--blue-soft);
}

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

.danger-button:hover:not(:disabled) {
  color: #7f1d1d;
  background: var(--red-soft);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  min-height: 2rem;
  border-color: var(--line-strong);
  padding: 0;
  color: #334155;
  background: #ffffff;
  font-weight: 800;
  line-height: 1;
}

.icon-button:hover:not(:disabled) {
  color: #1d4ed8;
  background: #eef6ff;
}

.settings-button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--blue);
}

.danger-solid-button {
  border-color: #b91c1c;
  color: #ffffff;
  background: #dc2626;
}

.danger-solid-button:hover:not(:disabled) {
  background: #b91c1c;
}

.count-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  color: var(--muted);
  background: #ffffff;
  font-size: 0.75rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.24);
}

.confirmation-dialog,
.shortcut-dialog {
  width: min(34rem, 100%);
  max-height: min(42rem, calc(100vh - 2rem));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.dialog-heading {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.dialog-heading p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.danger-note {
  margin: 0.85rem 0;
  border-left: 3px solid #dc2626;
  padding: 0.55rem 0.7rem;
  color: #7f1d1d;
  background: var(--red-soft);
  font-size: 0.82rem;
}

.delete-entry-list {
  display: grid;
  gap: 0.25rem;
  max-height: 8rem;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.75rem 0.55rem 1.5rem;
  color: #334155;
  background: #f8fafc;
  font-size: 0.8rem;
}

.delete-entry-list li {
  overflow-wrap: anywhere;
}

.delete-progress {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.85rem;
  color: #334155;
  font-size: 0.82rem;
}

.delete-progress-track {
  display: block;
  overflow: hidden;
  height: 0.4rem;
  border-radius: 999px;
  background: #fee2e2;
}

.delete-progress-track > span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: #dc2626;
  animation: delete-progress-slide 1.1s ease-in-out infinite;
}

@keyframes delete-progress-slide {
  0% {
    transform: translateX(-110%);
  }

  50% {
    transform: translateX(75%);
  }

  100% {
    transform: translateX(245%);
  }
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.shortcut-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0.8rem 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.shortcut-list div {
  display: grid;
  grid-template-columns: minmax(10rem, 0.82fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  border-bottom: 1px solid #edf1f6;
  padding: 0.45rem 0.6rem;
}

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

.shortcut-list dt,
.shortcut-list dd {
  margin: 0;
}

.shortcut-list dd {
  color: #475569;
  font-size: 0.8rem;
}

kbd {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  color: #1f2937;
  background: #ffffff;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
}

.explorer-controls,
.chat-scope-strip,
.upload-strip {
  display: grid;
  gap: 0.45rem;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  background: var(--panel-muted);
}

.query-field,
.upload-heading {
  display: grid;
  gap: 0.3rem;
}

.query-field span,
.explorer-filter-row span,
.upload-heading strong {
  color: #334155;
  font-size: 0.76rem;
  font-weight: 700;
}

.explorer-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tag-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
}

.tag-create-row input {
  min-width: 0;
}

.chat-scope-strip {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  background: #ffffff;
}

.chat-scope-strip div:first-child {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.chat-scope-strip strong,
.chat-scope-strip span {
  overflow-wrap: anywhere;
}

.chat-scope-strip span {
  color: var(--muted);
  font-size: 0.74rem;
}

.upload-strip {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  max-height: 15.5rem;
  overflow: auto;
}

.upload-heading {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  color: var(--blue);
  background: #ffffff;
  cursor: pointer;
  font-weight: 600;
}

.file-picker input {
  display: none;
}

.compact-textarea {
  min-height: 4rem;
  font-size: 0.78rem;
}

.pending-file-list {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-preview-summary {
  display: grid;
  gap: 0.1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem;
  background: #ffffff;
  font-size: 0.78rem;
}

.split-preview-summary span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-strip {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  overflow: auto hidden;
  min-height: 2rem;
  padding-bottom: 0.05rem;
}

.tag-strip span,
.tag-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.38rem;
  color: #334155;
  background: #f8fafc;
  font-size: 0.7rem;
  white-space: nowrap;
}

.tag-chip {
  max-width: 12rem;
  min-height: 1.55rem;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-chip:hover:not(:disabled),
.tag-chip.selected {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: var(--blue-soft);
}

.tag-chip-more {
  color: #475569;
  background: #ffffff;
}

.file-table-wrap {
  min-height: 0;
  overflow: auto;
  contain: content;
}

.explorer-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(25rem, 1fr) minmax(22rem, 34rem);
  overflow: hidden;
}

.file-list-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
}

.explorer-detail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #ffffff;
}

.explorer-detail-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  min-height: 2.45rem;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0.45rem 0.25rem 0.65rem;
  background: #f8fafc;
}

.explorer-detail-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.list-window-note {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  color: var(--muted);
  background: #fbfcfe;
  font-size: 0.75rem;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
}

.file-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 1.8rem;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0.45rem;
  color: #475569;
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
}

.file-table th:nth-child(1) {
  width: 2.35rem;
}

.file-table th:nth-child(2) {
  width: 43%;
}

.file-table th:nth-child(3) {
  width: 25%;
}

.file-table th:nth-child(4) {
  width: 18%;
}

.file-table th:nth-child(5) {
  width: 12%;
}

.file-table td {
  height: 2.55rem;
  border-bottom: 1px solid #edf1f6;
  padding: 0.22rem 0.45rem;
  vertical-align: middle;
}

.file-table tr {
  cursor: default;
}

.file-table tr:hover td {
  background: #f1f5f9;
}

.file-table tr.selected-file-row td {
  background: #eef6ff;
}

.file-table tr.active-file-row td {
  background: #e0f2fe;
}

.file-table tr.active-file-row td:first-child {
  box-shadow: inset 3px 0 #0284c7;
}

.file-table tr.active-file-row.selected-file-row td {
  background: var(--blue-soft);
}

.file-select-checkbox {
  width: 1rem;
  margin: 0;
  accent-color: var(--blue);
}

.file-name-button {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: center;
  width: 100%;
  min-height: 2rem;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.file-name-button:hover:not(:disabled) {
  background: transparent;
}

.file-name-button strong,
.file-name-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name-button small {
  color: var(--muted);
  font-size: 0.7rem;
}

.file-type-badge,
.file-type-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  color: #1d4ed8;
  background: #eff6ff;
  font-weight: 700;
  letter-spacing: 0;
}

.file-type-badge {
  width: 2rem;
  height: 1.55rem;
  font-size: 0.62rem;
}

.file-type-large {
  min-width: 3rem;
  height: 2rem;
  padding: 0 0.35rem;
  font-size: 0.75rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 650;
}

.file-size {
  display: block;
  overflow: hidden;
  margin-top: 0.15rem;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
}

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

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

.status-failed {
  color: var(--red);
  background: var(--red-soft);
}

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

.source-preview {
  min-height: 100%;
  overflow: hidden;
  background: #ffffff;
}

.explorer-detail .source-preview {
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
}

.empty-preview {
  display: grid;
  place-content: center;
  min-height: 100%;
  padding: 1rem;
  text-align: center;
}

.empty-preview h2 {
  margin: 0 0 0.35rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 1.1rem;
  line-height: 1.25;
}

.empty-preview p {
  max-width: 30rem;
  margin: 0;
  color: var(--muted);
}

.preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 18rem);
  min-height: 0;
}

.explorer-detail .preview-layout {
  grid-template-columns: 1fr;
}

.preview-main {
  min-width: 0;
  display: grid;
  gap: 0.7rem;
  border-right: 1px solid var(--line);
  padding: 0.75rem;
}

.explorer-detail .preview-main {
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.raw-preview {
  display: grid;
  min-height: 16rem;
  max-height: 34rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.explorer-detail .raw-preview {
  min-height: 12rem;
  max-height: 20rem;
}

.raw-preview object,
.raw-preview iframe,
.raw-preview img,
.raw-preview video {
  width: 100%;
  height: 100%;
  min-height: 16rem;
  border: 0;
}

.explorer-detail .raw-preview object,
.explorer-detail .raw-preview iframe,
.explorer-detail .raw-preview img,
.explorer-detail .raw-preview video {
  min-height: 12rem;
}

.raw-preview img {
  object-fit: contain;
}

.text-preview {
  max-height: 26rem;
}

.markdown-preview {
  display: block;
  max-height: 30rem;
  overflow: auto;
  padding: 0.75rem;
  background: #ffffff;
}

.explorer-detail .markdown-preview {
  max-height: 22rem;
}

.markdown-preview-body {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  color: #1f2937;
  font-size: 0.82rem;
  line-height: 1.5;
}

.markdown-preview-body h1,
.markdown-preview-body h2,
.markdown-preview-body h3,
.markdown-preview-body h4,
.markdown-preview-body p,
.markdown-preview-body ul,
.markdown-preview-body ol,
.markdown-preview-body pre,
.markdown-preview-body table {
  margin: 0;
}

.markdown-preview-body h1 {
  font-size: 1.25rem;
}

.markdown-preview-body h2 {
  font-size: 1.08rem;
}

.markdown-preview-body h3,
.markdown-preview-body h4 {
  font-size: 0.95rem;
}

.markdown-preview-body ul,
.markdown-preview-body ol {
  padding-left: 1.25rem;
}

.markdown-preview-body pre {
  overflow: auto;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  padding: 0.65rem;
  background: #f8fafc;
  font-size: 0.76rem;
}

.markdown-preview-body code {
  border-radius: 4px;
  padding: 0.08rem 0.25rem;
  background: #eef2f7;
  font-size: 0.78rem;
}

.markdown-preview-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-preview-body table {
  display: block;
  overflow: auto;
  border-collapse: collapse;
  max-width: 100%;
  font-size: 0.76rem;
}

.markdown-preview-body th,
.markdown-preview-body td {
  border: 1px solid #dbe3ee;
  padding: 0.32rem 0.45rem;
  text-align: left;
  vertical-align: top;
}

.markdown-preview-body a {
  color: #1d4ed8;
}

.text-preview pre {
  border: 0;
  border-radius: 0;
}

.media-preview,
.preview-loading,
.preview-unavailable {
  place-items: center;
  gap: 0.25rem;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.media-preview audio {
  width: min(100%, 34rem);
}

.chunk-section {
  display: grid;
  gap: 0.45rem;
}

.chunk-list {
  display: grid;
  gap: 0.35rem;
}

.chunk-row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: start;
  border: 1px solid #edf1f6;
  border-radius: 6px;
  padding: 0.45rem;
  background: #ffffff;
}

.chunk-row > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  color: #475569;
  background: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 700;
}

.chunk-row strong,
.chunk-row small {
  overflow-wrap: anywhere;
}

.chunk-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.metadata-panel {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #fbfcfe;
}

.metadata-panel dl {
  display: grid;
  gap: 0.4rem;
  margin: 0;
}

.metadata-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid #edf1f6;
  padding-bottom: 0.3rem;
}

.metadata-panel dl div.metadata-path-row {
  display: grid;
  justify-content: stretch;
  gap: 0.15rem;
}

.metadata-panel dt {
  color: var(--muted);
}

.metadata-panel dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metadata-path-row dd {
  white-space: normal;
  overflow-wrap: anywhere;
}

.field-label,
.tag-inspection {
  display: grid;
  gap: 0.4rem;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 650;
}

.tag-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.error-message {
  margin: 0;
  border: 1px solid var(--red-soft);
  border-radius: 6px;
  padding: 0.45rem;
  color: var(--red);
  background: #fff7f7;
}

.button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.chat-panel {
  display: grid;
  padding: 0;
}

.filesystem-pane {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.file-view-tabs {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0.3rem 0.45rem;
  background: #ffffff;
}

.view-tab {
  min-height: 1.8rem;
  border-color: transparent;
  padding: 0.24rem 0.65rem;
  color: #334155;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
}

.view-tab:hover:not(:disabled),
.view-tab.active {
  border-color: #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
}

.view-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  padding: 0 0.28rem;
  color: #1d4ed8;
  background: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
}

.explorer-commandbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.35rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0.45rem;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.explorer-commandbar button {
  min-height: 1.8rem;
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
}

.explorer-commandbar .icon-button {
  padding: 0;
}

.explorer-selection-summary {
  min-width: 0;
  display: grid;
  justify-items: end;
  gap: 0.05rem;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 0.2rem 0.45rem;
  color: #475569;
  background: #f8fbff;
  font-size: 0.74rem;
}

.explorer-selection-summary strong,
.explorer-selection-summary span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-search-view {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
}

.library-searchbar {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(8rem, 12rem) auto;
  gap: 0.5rem;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  background: #fbfdff;
}

.library-query-field,
.tag-select-field {
  display: grid;
  gap: 0.25rem;
  color: #334155;
  font-size: 0.76rem;
  font-weight: 700;
}

.tag-select-field select,
.tag-inspection input {
  min-height: 2rem;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  background: #ffffff;
  color: #0f172a;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
}

.segmented-control button {
  min-height: 2rem;
  border: 0;
  border-radius: 0;
  padding: 0.35rem 0.55rem;
  color: #334155;
  background: transparent;
}

.segmented-control button.active,
.segmented-control button:hover:not(:disabled) {
  color: #1d4ed8;
  background: var(--blue-soft);
}

.library-tag-panel {
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0.55rem;
  background: var(--panel-muted);
}

.library-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  max-height: 4.1rem;
  overflow: hidden;
}

.library-tag-panel.expanded .library-tag-list {
  max-height: 12rem;
  overflow: auto;
}

.library-result-summary {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0.38rem 0.55rem;
  color: #475569;
  font-size: 0.76rem;
}

.library-hit-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-hit-text {
  color: var(--muted);
  font-size: 0.72rem;
}

.library-result-summary button {
  margin-left: auto;
  min-height: 1.75rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.74rem;
}

.filesystem-tags {
  min-height: 1.85rem;
  padding-bottom: 0;
}

.breadcrumb-row {
  display: flex;
  gap: 0.15rem;
  align-items: center;
  min-width: 0;
  overflow: auto hidden;
  border-bottom: 1px solid var(--line);
  padding: 0.28rem 0.45rem;
  background: #ffffff;
}

.breadcrumb-button {
  position: relative;
  min-height: 1.55rem;
  border-color: transparent;
  padding: 0.18rem 0.45rem;
  color: #334155;
  background: transparent;
  font-size: 0.78rem;
}

.breadcrumb-button:not(:first-child)::before {
  content: "/";
  margin-right: 0.35rem;
  color: var(--muted);
}

.breadcrumb-button.current {
  color: var(--ink);
  font-weight: 700;
}

.filesystem-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}

.filesystem-layout > .library-search-view,
.filesystem-layout > .results-view,
.explorer-view-body {
  min-width: 0;
  min-height: 0;
}

.explorer-view-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.filesystem-layout.has-preview {
  grid-template-columns: minmax(20rem, var(--preview-list-width, 46%)) 0.5rem minmax(24rem, 1fr);
}

.file-browser {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.preview-splitter {
  min-width: 0;
  width: 0.5rem;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  cursor: col-resize;
}

.preview-splitter::before {
  display: block;
  width: 2px;
  height: 100%;
  margin: 0 auto;
  border-radius: 999px;
  background: transparent;
  content: "";
}

.preview-splitter:hover::before,
.preview-splitter:focus-visible::before,
.resizing-preview .preview-splitter::before {
  background: #93c5fd;
}

.filesystem-layout.has-preview .file-list-header,
.filesystem-layout.has-preview .file-rows [role="row"] {
  grid-template-columns: minmax(10rem, 1fr) 3.7rem 5.3rem 6.4rem 6.2rem;
}

.file-list-header,
.file-rows [role="row"] {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) 4.2rem 5.5rem 7.5rem 6.5rem;
  gap: 0.45rem;
  align-items: center;
}

.library-file-list-header,
.library-file-rows [role="row"],
.filesystem-layout.has-preview .library-file-list-header,
.filesystem-layout.has-preview .library-file-rows [role="row"],
.results-file-list-header,
.results-file-rows [role="row"],
.filesystem-layout.has-preview .results-file-list-header,
.filesystem-layout.has-preview .results-file-rows [role="row"] {
  grid-template-columns: minmax(13rem, 1fr) 4.2rem 6.5rem minmax(11rem, 1.2fr);
}

.file-list-header {
  height: 1.8rem;
  border-bottom: 1px solid var(--line);
  padding: 0 0.55rem;
  color: #475569;
  background: #f8fafc;
  font-size: 0.73rem;
  font-weight: 700;
}

.file-rows {
  min-height: 0;
  overflow: auto;
  contain: content;
  font-size: 0.78rem;
}

.file-rows [role="row"] {
  min-height: 2.25rem;
  border-bottom: 1px solid #edf1f6;
  padding: 0.18rem 0.55rem;
  cursor: default;
  outline: none;
}

.file-rows [role="row"]:hover {
  background: #f1f5f9;
}

.file-rows [role="row"].selected-file-row {
  background: linear-gradient(90deg, #eaf3ff 0%, #f6fbff 100%);
}

.file-rows [role="row"].active-file-row {
  box-shadow: inset 3px 0 #2563eb;
}

.library-file-rows [role="row"],
.results-file-rows [role="row"] {
  cursor: pointer;
}

.library-file-rows .file-select-checkbox {
  justify-self: center;
}

.filesystem-name-cell {
  min-width: 0;
  display: block;
}

.filesystem-name-cell strong,
.muted-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filesystem-name-cell strong {
  display: block;
  font-weight: 600;
}

.muted-cell {
  color: var(--muted);
  font-size: 0.7rem;
}

.filesystem-type-cell {
  min-width: 0;
  display: flex;
  align-items: center;
}

.entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.35rem;
  border-radius: 4px;
  font-size: 0.58rem;
  font-weight: 800;
}

.folder-icon {
  position: relative;
  border: 1px solid #f5c76b;
  background: #ffe8a3;
}

.folder-icon::before {
  content: "";
  position: absolute;
  top: -0.22rem;
  left: 0.12rem;
  width: 0.72rem;
  height: 0.28rem;
  border: 1px solid #f5c76b;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: #ffe8a3;
}

.file-icon {
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
}

.empty-file-list {
  display: grid;
  min-height: 8rem;
  place-items: center;
  color: var(--muted);
}

.status-progress-track {
  display: block;
  overflow: hidden;
  width: 100%;
  height: 0.34rem;
  border-radius: 999px;
  background: #e2e8f0;
}

.status-progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width 180ms ease;
}

.status-ready + .status-progress-track > span {
  background: var(--green);
}

.status-failed + .status-progress-track > span {
  background: var(--red);
}

.status-cell {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.chatkit-element,
.chat-panel > * {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(34rem, 1fr) minmax(32rem, 0.85fr);
    gap: 0.5rem;
  }

  .workspace-splitter {
    display: none;
  }

  .chat-panel {
    min-height: 32rem;
  }

  body {
    overflow: auto;
  }

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

.admin-workspace-hidden {
  display: none;
}

.admin-workspace-panel {
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  background: var(--panel-muted);
  border-top: 1px solid var(--line);
}

.admin-portfolio-panel {
  display: grid;
  gap: 0.85rem;
  max-width: 1160px;
  margin: 0 auto;
}

.account-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  max-width: 1120px;
  margin: 0 auto;
}

.account-settings-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: var(--panel);
}

.account-settings-section h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
}

.account-settings-section dl {
  display: grid;
  gap: 0.6rem;
  margin: 0.9rem 0 0;
}

.account-settings-section dl div {
  display: grid;
  gap: 0.15rem;
}

.account-settings-section dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.account-settings-section dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.payment-receipt-flow {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.payment-reference-box {
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.65rem;
  background: var(--panel-muted);
}

.payment-reference-box strong {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.payment-reference-box span {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-portfolio-panel h2,
.admin-portfolio-panel h3,
.admin-portfolio-panel p {
  margin: 0;
}

.admin-portfolio-panel__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 23rem);
  gap: 0.85rem;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.admin-portfolio-panel__toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}

.admin-portfolio-panel__pager,
.admin-portfolio-panel__review header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.admin-portfolio-panel__header p,
.admin-portfolio-panel__grant p,
.admin-portfolio-panel__review p,
.admin-portfolio-panel td span,
.admin-portfolio-panel__empty,
.admin-portfolio-panel__loading {
  color: var(--muted);
}

.admin-portfolio-panel__toolbar input,
.admin-portfolio-panel__grant input,
.admin-portfolio-panel__grant textarea,
.admin-portfolio-panel__review select {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
}

.admin-portfolio-panel button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 700;
}

.admin-portfolio-panel__button--primary,
.admin-portfolio-panel__button--positive {
  border-color: #1d4ed8;
  background: var(--blue);
  color: #ffffff;
}

.admin-portfolio-panel__button--secondary,
.admin-portfolio-panel__pager button {
  background: #ffffff;
  color: var(--ink);
}

.admin-portfolio-panel__button--danger {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--red);
}

.admin-portfolio-panel button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.admin-portfolio-panel__status,
.admin-portfolio-panel__loading {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: var(--panel);
}

.admin-portfolio-panel__table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-portfolio-panel table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.admin-portfolio-panel th,
.admin-portfolio-panel td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.admin-portfolio-panel td {
  min-width: 6.5rem;
}

.admin-portfolio-panel th {
  color: var(--muted);
  background: var(--panel-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-portfolio-panel__user-row--selected td {
  background: #eff6ff;
}

.admin-portfolio-panel__user-row--inactive {
  opacity: 0.72;
}

.admin-portfolio-panel__identity-cell,
.admin-portfolio-panel__credit-cell {
  display: grid;
  gap: 0.2rem;
}

.admin-portfolio-panel__identity-cell span,
.admin-portfolio-panel__credit-cell span {
  overflow-wrap: anywhere;
}

.admin-portfolio-panel__actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  white-space: nowrap;
}

.admin-portfolio-panel__pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  text-transform: capitalize;
}

.admin-portfolio-panel__pill--positive {
  border-color: #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.admin-portfolio-panel__pill--muted {
  background: #f1f5f9;
}

.admin-portfolio-panel__pager {
  justify-content: flex-end;
}

.admin-portfolio-panel__workbench,
.admin-portfolio-panel__review-grid {
  display: grid;
  gap: 0.85rem;
}

.admin-portfolio-panel__grant,
.admin-portfolio-panel__review {
  display: grid;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
}

.admin-portfolio-panel__grant-fields {
  display: grid;
  grid-template-columns: minmax(8rem, 0.3fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.admin-portfolio-panel__grant label {
  display: grid;
  gap: 0.35rem;
}

.admin-portfolio-panel__grant textarea {
  min-height: 5rem;
  resize: vertical;
}

.admin-portfolio-panel__review-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-portfolio-panel__review select {
  width: min(16rem, 100%);
}

.admin-portfolio-panel__review-item {
  display: grid;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  background: var(--panel-muted);
}

.admin-portfolio-panel__review-item > div:first-child,
.admin-portfolio-panel__review-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: space-between;
}

.admin-portfolio-panel__review-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.admin-portfolio-panel__empty {
  display: grid;
  min-height: 4.5rem;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.5rem;
    align-items: center;
  }

  .app-identity {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
  }

  .app-identity strong {
    font-size: 0.92rem;
  }

  .app-identity span {
    font-size: 0.72rem;
  }

  .app-status {
    grid-column: 1 / -1;
  }

  .app-status span,
  .task-summary,
  .library-switcher {
    display: none;
  }

  .app-status strong {
    font-size: 0.8rem;
  }

  .app-bar > button {
    min-height: 1.8rem;
    padding: 0.25rem 0.55rem;
  }

  .app-bar > .icon-button {
    padding: 0;
  }

  .account-settings-grid {
    grid-template-columns: 1fr;
  }

  .admin-portfolio-panel__header,
  .admin-portfolio-panel__grant-fields,
  .admin-portfolio-panel__review-grid {
    grid-template-columns: 1fr;
  }

  .admin-portfolio-panel__review header,
  .admin-portfolio-panel__actions-cell,
  .admin-portfolio-panel__pager {
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .admin-portfolio-panel__review select {
    width: 100%;
  }

  .workspace-grid,
  .preview-layout,
  .explorer-body,
  .filesystem-layout {
    grid-template-columns: 1fr;
  }

  .filesystem-layout.has-preview {
    grid-template-columns: 1fr;
  }

  .preview-splitter {
    display: none;
  }

  .workspace-grid {
    min-height: auto;
    grid-auto-rows: auto;
  }

  .explorer-pane {
    min-height: 30rem;
  }

  .file-list-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .file-browser {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .explorer-commandbar {
    grid-template-columns: 1fr;
  }

  .preview-main {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .source-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .source-title-row {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 36rem;
  }
}
