:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-alt: #f5f6f8;
  --surface-strong: #e5e9f4;
  --border: #c9d0da;
  --border-strong: #aab3c2;
  --text: #1c2430;
  --muted: #66707f;
  --accent: #354477;
  --accent-strong: #28335c;
  --accent-soft: #e5e9f4;
  --accent-2: #465a96;
  --success: #35704d;
  --warn: #a56300;
  --danger: #a13d46;
  --shadow: 0 10px 26px rgba(28, 36, 48, 0.08);
  --shadow-popover: 0 8px 22px rgb(28 36 48 / 10%);
  --duration: 140ms;
  --ease: ease-out;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

::selection {
  color: #ffffff;
  background: var(--accent);
}

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

button,
input,
select,
textarea,
.project-item,
.file-row {
  transition:
    color var(--duration) var(--ease),
    background-color var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

* {
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(53, 68, 119, 0.16), rgba(102, 112, 127, 0.08)),
    var(--bg);
}

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

.auth-language {
  position: fixed;
  top: 18px;
  right: 18px;
}

.auth-brand {
  margin-bottom: 8px;
}

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

.auth-copy,
.auth-hint,
.pane-subtitle,
.brand small,
.workspace-head p,
.chip,
.muted {
  color: var(--muted);
}

.auth-copy,
.auth-hint {
  margin: 0;
}

.auth-card [hidden] {
  display: none !important;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(300px, 390px) minmax(480px, 1fr);
  grid-template-rows: 58px 1fr;
  grid-template-areas:
    "topbar topbar topbar"
    "projects files viewer";
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 58px 1fr;
  grid-template-areas:
    "topbar"
    "admin-main";
}

.admin-main {
  grid-area: admin-main;
  min-width: 0;
  padding: 18px;
  overflow: auto;
  background: var(--bg);
}

.admin-panel {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-panel h1 {
  margin: 0;
  font-size: 20px;
}

.topbar {
  grid-area: topbar;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  color: #fff;
  background: var(--accent-strong);
  border-bottom: 1px solid #20294a;
}

.topbar .brand small,
.topbar .workspace-head p,
.topbar .chip {
  color: rgba(255, 255, 255, 0.82);
}

.topbar .chip {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.topbar .ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.topbar .language-switch {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.topbar .language-button {
  color: rgba(255, 255, 255, 0.88);
  background: transparent;
}

.topbar .language-button.active {
  color: var(--accent-strong);
  background: #fff;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-weight: 800;
}

.brand-mark-image {
  width: 38px;
  height: 42px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  background: transparent;
  border: 0;
}

.topbar .brand-mark-image {
  width: 30px;
  height: 34px;
}

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

.workspace-head {
  min-width: 0;
}

.workspace-head h1,
.workspace-head p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-head h1 {
  font-size: 17px;
}

.workspace-head p {
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.project-pane,
.files-pane,
.viewer-pane {
  min-width: 0;
  overflow: auto;
}

.project-pane {
  grid-area: projects;
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  padding: 12px;
}

.files-pane {
  grid-area: files;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px;
}

.viewer-pane {
  grid-area: viewer;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto minmax(220px, 36vh);
  gap: 10px;
  padding: 12px;
  background: var(--surface-alt);
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 15px;
}

.section-head,
.viewer-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pane-subtitle {
  margin: 3px 0 0;
  font-size: 12px;
}

.toolbox {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.toolbox > summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.toolbox > .stacked-form {
  padding: 0 10px 10px;
}

.stacked-form {
  display: grid;
  gap: 8px;
}

.filter-form {
  margin-top: 0;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compact-actions {
  width: min(210px, 100%);
}

.language-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.language-button {
  min-height: 32px;
  min-width: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
}

.language-button.active {
  color: #fff;
  background: var(--accent);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.icon-button {
  width: 36px;
  padding: 0;
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 6px 9px;
  border-radius: 999px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.tree-list {
  display: grid;
  gap: 2px;
}

.tree-row {
  width: 100%;
  min-height: 32px;
  justify-content: flex-start;
  padding: 5px 7px;
  color: var(--text);
  background: transparent;
  border-color: transparent;
  font-weight: 650;
}

.tree-row:hover,
.tree-row.active {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}

.tree-row .tree-label {
  min-width: 0;
  display: grid;
  gap: 1px;
  text-align: left;
}

.tree-row small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-caption,
.tree-empty {
  padding-top: 7px;
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.tree-empty {
  text-transform: none;
  font-weight: 650;
}

.tree-indent-1 {
  padding-left: 24px;
}

.tree-indent-2 {
  padding-left: 42px;
}

.tree-indent-3 {
  padding-left: 60px;
}

.tree-indent-4 {
  padding-left: 78px;
}

.file-list {
  display: grid;
  gap: 6px;
}

.file-search-row {
  margin-bottom: 8px;
}

.file-search-row input {
  width: 100%;
  min-height: 34px;
}

.file-filter-row,
.file-meta-grid,
.review-filter-row,
.review-meta-grid {
  display: grid;
  gap: 8px;
}

.file-filter-row {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 10px;
}

.file-meta-grid {
  grid-template-columns: 1fr 1fr;
}

.file-meta-grid input:last-child {
  grid-column: 1 / -1;
}

.review-filter-row {
  grid-template-columns: minmax(130px, 1fr) auto auto auto;
  align-items: center;
  margin-bottom: 10px;
}

.review-meta-grid {
  grid-template-columns: 1fr 1fr;
}

.folder-row,
.file-row,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.folder-row,
.item-row {
  background: var(--surface-alt);
}

.file-row.selected,
.item-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-row-main,
.folder-row-main,
.item-row-main {
  min-width: 0;
  min-height: 30px;
  justify-content: flex-start;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  font-weight: 700;
}

.file-row-main .icon,
.item-row-main .icon {
  width: 32px;
}

.file-row-main:hover,
.folder-row-main:hover,
.item-row-main:hover {
  filter: none;
}

.list-caption {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.item-counts {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.file-title {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: left;
}

.file-title small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.file-badges span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.upload-toolbox {
  margin-top: 12px;
}

.typst-editor-shell {
  position: relative;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.editor-meta-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 0.8fr) minmax(140px, 0.9fr);
  gap: 8px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
  overflow-x: auto;
}

.editor-toolbar .small-button {
  min-width: 34px;
}

.editor-toolbar select {
  width: auto;
  max-width: 190px;
}

.typst-editor-surface {
  min-height: 360px;
  max-height: 58vh;
  overflow: auto;
  padding: 34px 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(28, 36, 48, 0.03);
  line-height: 1.55;
  outline: none;
}

.typst-editor-surface:focus {
  border-color: var(--accent);
}

.typst-editor-surface:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.typst-editor-surface h1,
.typst-editor-surface h2,
.typst-editor-surface h3,
.typst-editor-surface p,
.typst-editor-surface ul,
.typst-editor-surface ol {
  margin: 0 0 12px;
}

.typst-editor-surface h1 {
  font-size: 30px;
}

.typst-editor-surface h2 {
  font-size: 23px;
}

.typst-editor-surface h3 {
  font-size: 18px;
}

.typst-editor-surface ul,
.typst-editor-surface ol {
  padding-left: 24px;
}

.editor-context-menu {
  position: fixed;
  z-index: 30;
  width: 220px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.editor-context-menu button {
  justify-content: flex-start;
  min-height: 32px;
  color: var(--text);
  background: transparent;
  border-color: transparent;
  font-weight: 700;
}

.editor-context-menu button:hover {
  background: var(--accent-soft);
  filter: none;
}

.menu-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.toolbar-separator {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}

.typst-table-dialog {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
}

.typst-table-dialog label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.typst-table-dialog input[type="number"] {
  width: 54px;
}

.typst-editor-surface table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.typst-editor-surface table td {
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
  min-width: 40px;
  min-height: 28px;
  vertical-align: top;
}

.typst-editor-surface table td:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.typst-editor-surface figure {
  margin: 12px 0;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: var(--surface-alt);
  text-align: center;
}

.typst-editor-surface figure .image-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.typst-editor-surface figure .image-placeholder::before {
  content: "\1F5BC";
  font-size: 20px;
}

.typst-editor-surface.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-color: var(--accent) var(--surface-strong);
  scrollbar-width: thin;
}

.tab {
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 8px 10px;
  font-weight: 800;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 340px);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.preview-surface,
.detail-strip,
.viewer-dock {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.preview-surface {
  display: grid;
  min-height: 0;
  overflow: hidden;
}

.detail-strip,
.viewer-dock {
  padding: 10px;
  overflow: auto;
}

.pdf-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 0;
  background: #fff;
}

.version-detail {
  display: grid;
  gap: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.detail-item {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
}

.detail-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-item strong,
.detail-item code {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card-form {
  display: grid;
  gap: 12px;
}

.card-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.card-section {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.card-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.card-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.card-field span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-field small {
  color: var(--muted);
  font-weight: 600;
}

.card-field input:disabled {
  color: var(--muted);
  background: var(--surface-alt);
}

.metadata-list {
  display: grid;
  gap: 6px;
}

.metadata-list div {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(90px, 180px) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.metadata-list small {
  color: var(--muted);
}

.metadata-list code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px;
}

th,
td {
  padding: 8px 7px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

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

.icon-only {
  min-width: 32px;
  width: 32px;
  padding-inline: 0;
}

.compact-input {
  min-height: 30px;
  padding: 5px 7px;
}

.check-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.status-pill.ok {
  color: var(--success);
  background: #e7f1eb;
}

.status-pill.off {
  color: #812f38;
  background: #f5e7e9;
}

.secondary {
  border-color: var(--accent-2);
  background: var(--accent-2);
}

.warning {
  border-color: var(--warn);
  background: var(--warn);
}

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

.file-input {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}

.preview-surface .empty-state {
  align-self: center;
  justify-self: center;
  width: min(420px, calc(100% - 28px));
  text-align: center;
}

.audit-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.audit-project-filter {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.settings-form {
  max-width: 640px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.system-info-panel {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(28, 36, 48, 0.34);
}

.system-info-dialog {
  width: min(620px, 100%);
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.system-info-content {
  display: grid;
  gap: 12px;
}

.system-links a {
  min-height: 30px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.system-links a:not(.secondary) {
  background: #fff;
  color: var(--accent);
}

.system-links a.secondary {
  border-color: var(--accent-2);
  background: var(--accent-2);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(220px, 280px) minmax(280px, 360px) minmax(420px, 1fr);
  }
}

@media (max-width: 940px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "topbar"
      "projects"
      "files"
      "viewer";
  }

  .admin-shell {
    grid-template-rows: auto 1fr;
  }

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

  .topbar-actions,
  .section-head,
  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .project-pane,
  .files-pane {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .viewer-pane {
    grid-template-rows: auto minmax(360px, 55vh) auto auto;
  }

  .auth-actions,
  .editor-meta-grid,
  .split,
  .audit-filter-grid,
  .file-filter-row,
  .file-meta-grid,
  .review-filter-row,
  .review-meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .tabs {
    padding-bottom: 4px;
    box-shadow: inset -18px 0 14px -18px var(--accent);
  }

  .tab {
    flex: 0 0 auto;
  }

  .toast {
    inset: 10px 10px auto;
    max-width: none;
  }
  .auth-screen,
  .admin-main,
  .project-pane,
  .files-pane,
  .viewer-pane {
    padding: 10px;
  }

  .topbar-actions,
  .file-actions,
  .button-row,
  .editor-toolbar {
    flex-wrap: wrap;
  }

  .file-row,
  .folder-row,
  .item-row {
    grid-template-columns: 1fr;
  }

  .file-actions,
  .item-counts {
    justify-content: flex-start;
  }

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

  .viewer-pane {
    grid-template-rows: auto minmax(320px, 54vh) auto auto;
  }

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

  table {
    min-width: 560px;
  }

  .typst-editor-surface {
    min-height: 280px;
    padding: 18px;
  }
}


.ui-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
  flex: 0 0 16px;
  color: currentColor;
}

.ui-icon-refresh { border: 2px solid currentColor; border-left-color: transparent; border-radius: 50%; transform: scale(.72); }
.ui-icon-refresh::after { position: absolute; right: -3px; top: -3px; width: 0; height: 0; border-left: 5px solid currentColor; border-top: 3px solid transparent; border-bottom: 3px solid transparent; content: ""; transform: rotate(-34deg); }
.ui-icon-close::before,.ui-icon-close::after { position:absolute; left:7px; top:2px; width:2px; height:12px; border-radius:1px; background:currentColor; content:""; }
.ui-icon-close::before { transform:rotate(45deg); }
.ui-icon-close::after { transform:rotate(-45deg); }
.ui-icon-folder { height:11px; margin-top:3px; border:1.5px solid currentColor; border-radius:2px; }
.ui-icon-folder::before { position:absolute; left:-1.5px; top:-4px; width:7px; height:4px; border:1.5px solid currentColor; border-bottom:0; border-radius:2px 2px 0 0; content:""; }
.ui-icon-document,.ui-icon-object,.ui-icon-project,.ui-icon-root { border:1.5px solid currentColor; border-radius:2px; }
.ui-icon-document::after,.ui-icon-object::after { position:absolute; left:3px; right:3px; top:4px; height:1.5px; background:currentColor; box-shadow:0 4px currentColor; content:""; }
.ui-icon-project::after,.ui-icon-root::after { position:absolute; inset:3px; background:linear-gradient(90deg,currentColor 1.5px,transparent 1.5px 4px,currentColor 4px 5.5px,transparent 5.5px),linear-gradient(currentColor 1.5px,transparent 1.5px 4px,currentColor 4px 5.5px,transparent 5.5px); content:""; }
.ui-icon-chevron::after { position:absolute; left:4px; top:4px; width:6px; height:6px; border-right:2px solid currentColor; border-bottom:2px solid currentColor; content:""; transform:rotate(45deg); }
.ui-icon-check::after { position:absolute; left:3px; top:2px; width:7px; height:11px; border-right:2px solid currentColor; border-bottom:2px solid currentColor; content:""; transform:rotate(45deg); }
.ui-icon-alert::after { position:absolute; inset:0; display:grid; place-items:center; border:1.5px solid currentColor; border-radius:50%; content:"!"; font-size:11px; font-weight:700; }
