:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #1d252d;
  --muted: #5f6b76;
  --line: #d7dde3;
  --accent: #1f7a70;
  --accent-dark: #145b54;
  --warn: #a45b13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
}

/* Write controls stay unavailable throughout the permission handshake and
   remain hidden when component code toggles its own hidden/disabled state. */
body.readonly [data-write-only],
body:not([data-access-ready="true"]) [data-write-only],
body.readonly .write-only {
  display: none !important;
}

.readonly-badge {
  padding: 4px 9px;
  border: 1px solid rgba(255, 224, 160, 0.7);
  border-radius: 999px;
  color: #ffe0a0;
  font-size: 12px;
  white-space: nowrap;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 0 20px;
  background: #1e2a32;
  color: #fff;
  border-bottom: 1px solid #111920;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  height: 32px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tab.active {
  background: #fff;
  color: #1e2a32;
}

/* “示意图”外链按钮：外观与标签一致 */
.tab-link {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
}

.tab-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.status {
  margin-left: auto;
  color: #d9e4ea;
  font-size: 13px;
}

.topbar-log-button,
.topbar-stop-button {
  height: 32px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.topbar-log-button:hover,
.topbar-stop-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.topbar-stop-button:not(:disabled) {
  border-color: rgba(255, 185, 185, 0.85);
  color: #ffe1e1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.data-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.data-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.data-heading h2,
.data-heading h3 { margin: 0 0 6px; }
.data-heading p { margin: 0; color: var(--muted); }

.data-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  min-width: 0;
}

.data-card h3 { margin-top: 0; }

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

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

.data-form-grid input,
.data-form-grid select { width: 100%; }

.data-variable-picker { margin-top: 18px; }
.data-variable-picker .data-heading { margin-bottom: 8px; }
.data-variable-picker .hint { margin: 0 0 10px; }
.data-variable-picker input[type="search"] { width: 100%; margin-bottom: 10px; }
.data-variable-choices {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  max-height: 240px;
  min-height: 44px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.data-variable-choices button { padding: 5px 9px; font-size: 12px; }
.data-variable-choices button.selected { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }

.data-experiment-picker { margin-bottom: 18px; }
.data-experiment-picker .data-heading { margin-bottom: 8px; }
.data-experiment-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.data-experiment-tools button { padding: 4px 10px; font-size: 12px; }
.data-experiment-choices { max-height: 132px; }
.data-status { margin: 10px 0 0; min-height: 1.2em; font-size: 13px; color: var(--muted); }
.data-status.data-warning { color: #a33228; }
.plan-experiment { padding: 6px 0; border-top: 1px solid var(--line); }
.plan-experiment p { margin: 0 0 4px; }

.data-options { margin-top: 18px; }
.data-options summary { cursor: pointer; margin-bottom: 14px; font-weight: 600; }
.data-force { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.data-force input { width: 18px; height: 18px; flex: none; }
.data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.data-warning { color: #a33228; font-weight: 600; }
.data-ok { color: var(--accent-dark); }

.inventory-panel > summary { cursor: pointer; font-size: 18px; font-weight: 600; }
.inventory-panel[open] > summary { margin-bottom: 16px; }

.inventory-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.inventory-filters label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.inventory-filters input, .inventory-filters select { width: 100%; }
.inventory-scroll { overflow: auto; max-height: 540px; border: 1px solid var(--line); border-radius: 6px; }
.inventory-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inventory-table th, .inventory-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.inventory-table th { position: sticky; top: 0; background: #f0f4f5; }
.inventory-table button { border: 0; background: none; color: var(--accent-dark); padding: 0; text-decoration: underline; cursor: pointer; }
.inventory-table tr.selected { background: #e8f4ee; }
.inventory-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; }

.coverage-scroll {
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.coverage-table { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.coverage-table th,
.coverage-table td { border: 1px solid var(--line); min-width: 38px; padding: 3px 6px; text-align: center; }
.coverage-table th { position: sticky; top: 0; background: #f0f4f5; z-index: 1; }
.coverage-table tr > th:first-child { position: sticky; left: 0; z-index: 2; }
.coverage-table .slice-complete { height: 24px; width: 24px; padding: 0; border: 0; background: #dcefe7; color: #166149; }
.coverage-table .slice-missing { color: #9da8af; }
.slice-details,
#processingPlan pre { overflow: auto; max-height: 280px; background: #f6f8f9; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.history-row span { overflow-wrap: anywhere; }

/* 2026-10-21：自定义试验、变量说明浮窗、清单维度、完成情况图例、可收起历史任务 */
.data-experiment-choices button.custom { border-style: dashed; }
.data-experiment-choices button.unavailable { color: #a33228; }
.data-experiment-add { margin-top: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 6px; background: #fafcfc; }
.data-experiment-add .hint { margin: 0 0 10px; }
.data-experiment-add-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 10px; align-items: end; }
.data-experiment-add-row label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.data-experiment-add-row input { width: 100%; }
.data-experiment-custom-list { display: grid; gap: 6px; margin-top: 8px; font-size: 13px; }
.data-experiment-custom-list div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.data-experiment-custom-list span { overflow-wrap: anywhere; }
.data-experiment-custom-list button { padding: 3px 9px; font-size: 12px; flex: none; }
.var-tooltip { position: fixed; z-index: 1000; max-width: min(440px, calc(100vw - 24px)); padding: 10px 12px; background: #1d252d; color: #f5f7f9; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.22); font-size: 12.5px; line-height: 1.5; pointer-events: none; }
.var-tooltip[hidden] { display: none; }
.var-tooltip strong { font-size: 13.5px; }
.var-tooltip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; }
.var-tooltip dt { color: #9fb3bf; }
.var-tooltip dd { margin: 0; overflow-wrap: anywhere; }
.inventory-table td.dim-cell { color: var(--muted); }
.inventory-table td.dim-error { color: #a33228; }
.inventory-selected { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: #f6f8f9; }
.inventory-selected[hidden] { display: none; }
.inventory-selected h4 { margin: 0 0 8px; }
.inventory-selected dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.inventory-selected dt { color: var(--muted); }
.inventory-selected dd { margin: 0; overflow-wrap: anywhere; }
.coverage-explain { margin: 0 0 6px; }
.coverage-legend { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.coverage-legend span { display: inline-block; min-width: 20px; text-align: center; border-radius: 4px; }
.coverage-legend .legend-done { background: #dcefe7; color: #166149; }
.coverage-legend .legend-todo, .coverage-legend .legend-none { color: #9da8af; border: 1px solid var(--line); }
.coverage-table td.slice-todo { color: #5f6b76; background: #fff8e8; }
.history-panel > summary { cursor: pointer; font-size: 18px; font-weight: 600; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.history-panel[open] > summary { margin-bottom: 12px; }
.history-panel > summary { list-style: none; }
.history-panel > summary::-webkit-details-marker { display: none; }
.history-panel > summary::before { content: "▸"; font-size: 14px; color: var(--muted); }
.history-panel[open] > summary::before { content: "▾"; }
.history-count { font-size: 13px; font-weight: 400; color: var(--muted); }
.history-tools { margin-bottom: 6px; }
.history-tools .hint { margin: 0; }

@media (max-width: 850px) {
  .data-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-shell { padding: 14px; }
}

@media (max-width: 540px) {
  .data-form-grid { grid-template-columns: 1fr; }
  .data-experiment-add-row { grid-template-columns: 1fr; }
  .history-row { align-items: flex-start; flex-direction: column; }
}

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

.sidebar {
  padding: 16px;
  background: #eef2f4;
  border-right: 1px solid var(--line);
}

button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

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

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

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

.dashboard-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.dashboard-item {
  width: 100%;
  text-align: left;
  background: transparent;
}

.dashboard-item.active {
  border-color: var(--accent);
  background: #dcecea;
}

.main {
  min-width: 0;
  padding: 18px;
}

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

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

.main-head h2 {
  margin: 0;
  font-size: 20px;
  cursor: pointer;
}

.dashboard-title-row button {
  height: 30px;
  padding: 0 10px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.image-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.image-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.image-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-card h3 {
  margin: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-title-row button {
  height: 28px;
  padding: 0 8px;
  flex-shrink: 0;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.card-actions button {
  height: 30px;
  padding: 0 8px;
}

.image-card img {
  display: block;
  width: 100%;
  background: #fff;
  cursor: pointer;
}

.image-card details {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(1320px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(18, 28, 36, 0.45);
}

.zoom-dialog {
  width: min(1280px, calc(100vw - 24px));
  height: min(920px, calc(100vh - 24px));
}

.log-dialog {
  width: min(1480px, calc(100vw - 24px));
  height: min(900px, calc(100vh - 24px));
}

.log-dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  background: #f3f5f6;
}

.log-dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-refresh-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.log-contents {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
  gap: 10px;
  padding: 10px;
}

.log-source {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.log-source h4 {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #26333c;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: #26333c;
  color: #fff;
  font-size: 13px;
}

.log-source pre {
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: auto;
  border: 1px solid #26333c;
  border-radius: 0 0 6px 6px;
  padding: 10px;
  background: #10171c;
  color: #d7e1e6;
  font: 12px/1.45 Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .log-contents {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

.zoom-head {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.zoom-head h3 {
  margin: 0;
  font-size: 18px;
}

#zoomImage {
  display: block;
  width: 100%;
  height: calc(100% - 52px);
  object-fit: contain;
  background: #fff;
}

.plot-form {
  min-width: 0;
  max-height: calc(100vh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
}

#plotForm [hidden] { display: none !important; }
.custom-code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.custom-code-label { display: block; margin-bottom: 8px; }
#customCode { display: block; width: 100%; min-height: 320px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.6; tab-size: 4; white-space: pre; overflow: auto; }

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 18px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 20px;
}

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

.form-grid-span-3 {
  grid-column: 1 / -1;
}

fieldset {
  min-width: 0;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  color: var(--muted);
  font-size: 13px;
  padding: 0 6px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

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

input,
select {
  height: 34px;
  padding-top: 0;
  padding-bottom: 0;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.variable-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin: 8px 0;
}

.variable-toolbar strong {
  font-size: 13px;
}

.variable-table,
.quiver-table {
  display: grid;
  gap: 6px;
  max-width: 100%;
  margin-bottom: 12px;
  overflow-x: auto;
}

.variable-head,
.variable-row {
  display: grid;
  grid-template-columns: 42px minmax(90px, 1fr) 92px minmax(150px, 1.4fr) minmax(150px, 1.4fr) 90px 72px 72px 76px 76px;
  gap: 6px;
  min-width: 1020px;
  align-items: center;
}

.quiver-head,
.quiver-row {
  display: grid;
  grid-template-columns: 42px minmax(110px, 1fr) minmax(100px, 1fr) minmax(110px, 1fr) minmax(90px, 1fr) minmax(80px, 1fr) 76px;
  gap: 6px;
  min-width: 710px;
  align-items: center;
}

.variable-head,
.quiver-head {
  color: var(--muted);
  font-size: 11px;
}

.check-cell {
  display: flex;
  justify-content: center;
}

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

.row-delete {
  height: 30px;
  padding: 0 8px;
}

.row-advanced-toggle {
  height: 30px;
  padding: 0 8px;
}

.variable-advanced {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin: 4px 0 10px;
  padding: 12px;
  border: 1px solid #e5eaee;
  border-radius: 7px;
  background: #f8fafb;
}

.variable-advanced[hidden] {
  display: none;
}

.parameter-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.parameter-details > summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.parameter-details > .hint {
  padding: 0 12px;
}

.compact-details {
  margin-top: 4px;
}

.advanced-option-groups {
  display: grid;
  gap: 10px;
  padding: 10px 12px 14px;
}

.advanced-option-group {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #e7ecef;
}

.advanced-option-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.advanced-option-group > strong {
  font-size: 12px;
  color: var(--accent-dark);
}

.advanced-option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

pre {
  overflow: auto;
  white-space: pre-wrap;
}

.progress-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(520px, calc(100vw - 32px));
  max-height: 50vh;
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(20, 32, 40, 0.2);
  overflow: hidden;
  z-index: 20;
}

.progress-panel.open {
  display: block;
}

.progress-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.progress-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#cancelProgress {
  height: 30px;
  color: #8a2f17;
}

#progressMessages {
  max-height: calc(50vh - 48px);
  overflow: auto;
  padding: 10px 12px;
}

.progress-message {
  padding: 6px 0;
  border-bottom: 1px solid #edf1f3;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

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

  .advanced-option-grid,
  .variable-advanced {
    grid-template-columns: 1fr;
  }
}

.progress-job-picker {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.form-status {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #a33020;
}
.form-status:empty { display: none; }

/* Shared image ordering: the highlighted edge is the insertion position. */
.image-card img { cursor: grab; }
.image-card.dragging { opacity: 0.45; }
.image-card.dragging img { cursor: grabbing; }
.image-card.drop-before { box-shadow: inset 5px 0 #2563eb; }
.image-card.drop-after { box-shadow: inset -5px 0 #2563eb; }

/* Literature reader */
.literature-shell { display: grid; grid-template-columns: 190px 280px minmax(0, 1fr); height: calc(100vh - 56px); min-height: 550px; }
.literature-categories, .literature-list-panel { padding: 16px 12px; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; }
.literature-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.literature-panel-head h2 { font-size: 16px; margin: 0 0 10px; }
.literature-panel-head h3 { font-size: 15px; margin: 0 0 10px; }
.literature-panel-head button { font-size: 12px; padding: 4px 7px; }
.literature-list-controls { display: flex; gap: 4px; }
.literature-shell.literature-list-collapsed { grid-template-columns: 190px 50px minmax(0, 1fr); }
.literature-list-collapsed .literature-list-panel { padding: 12px 4px; }
.literature-list-collapsed .literature-list-panel .literature-panel-head { justify-content: center; }
.literature-list-collapsed .literature-list-panel h2,
.literature-list-collapsed #literatureRefresh,
.literature-list-collapsed #literatureSearch,
.literature-list-collapsed #literatureCount,
.literature-list-collapsed #literatureDocuments { display: none; }
.literature-list-collapsed #literatureToggle { width: 40px; padding: 0; }
.literature-category-list, .literature-documents { display: flex; flex-direction: column; gap: 4px; overflow: auto; min-height: 0; }
.literature-category-list { flex: 1; }
.literature-category, .literature-document { width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.literature-category { padding: 9px 10px; }
.literature-document { display: flex; flex-direction: column; gap: 5px; padding: 10px; height: auto; min-height: 62px; flex-shrink: 0; overflow-wrap: anywhere; }
.literature-document strong { font-size: 13px; line-height: 1.35; font-weight: 600; }
.literature-document small { color: var(--muted); line-height: 1.3; }
.literature-category:hover, .literature-document:hover { background: #eef6f4; }
.literature-category.active, .literature-document.active { background: #e5f3ef; border-color: #9bcfc5; }
.literature-category-actions { display: flex; gap: 5px; padding-top: 9px; border-top: 1px solid var(--line); }
.literature-category-actions button { flex: 1; }
#literatureSearch { width: 100%; margin: 4px 0 9px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 5px; }
.literature-list-panel .literature-documents { flex: 1; }
.literature-muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
.literature-reading-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.literature-reader-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 17px; min-height: 78px; background: #fff; border-bottom: 1px solid var(--line); }
.literature-reader-heading h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.literature-reader-heading p { margin: 5px 0 0; }
#literatureAssign { position: relative; flex: none; font-size: 13px; }
#literatureAssign summary { cursor: pointer; padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px; }
#literatureAssignments { position: absolute; z-index: 5; right: 0; top: 32px; width: 200px; max-width: calc(100vw - 24px); max-height: min(60vh, 360px); overflow-y: auto; padding: 9px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 3px 12px #0002; }
#literatureAssignments label { display: flex; align-items: center; gap: 8px; padding: 6px 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
#literatureAssignments input[type="checkbox"] { flex: 0 0 16px; width: 16px; height: 16px; margin: 0; padding: 0; }
.literature-reader-body { --literature-notes-default-width: 320px; display: grid; grid-template-columns: minmax(0, 1fr) 8px minmax(0, var(--literature-notes-width, var(--literature-notes-default-width))); flex: 1; min-height: 0; }
.literature-notes-resize { cursor: col-resize; touch-action: none; background: #eef2f4; position: relative; }
.literature-notes-resize::after { content: ''; position: absolute; top: 50%; left: 2px; width: 4px; height: 36px; margin-top: -18px; border-radius: 2px; background: #a8b8c0; }
.literature-notes-resize:hover, .literature-notes-resize:focus-visible, .literature-notes-resizing .literature-notes-resize { background: #cce6e0; }
.literature-notes-resize:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.literature-notes-resizing, .literature-notes-resizing * { cursor: col-resize !important; user-select: none; }
.literature-notes-resizing #literaturePages { pointer-events: none; }
.literature-pdf-area { min-width: 0; min-height: 0; background: #e7ebee; }
#literaturePages { width: 100%; height: 100%; border: 0; display: block; }
.literature-notes { min-width: 0; background: #fff; border-left: 1px solid var(--line); padding: 12px; overflow: auto; overflow-wrap: anywhere; }
#literatureHighlightSelection { width: 100%; margin-bottom: 8px; padding: 8px; }
.literature-ai-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.literature-ai-actions button { flex: 1; padding: 7px 3px; font-size: 12px; }
.literature-ai-result { padding: 9px; margin: 8px 0; border: 1px solid #9bcfc5; border-radius: 6px; background: #f5faf9; }
.literature-ai-result[hidden] { display: none; }
.literature-ai-result h4 { margin: 0 0 6px; font-size: 13px; }
.literature-ai-result p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.literature-ai-result button { width: 100%; padding: 7px; }
.literature-ai-settings { margin: 8px 0; font-size: 12px; }
.literature-ai-settings summary { cursor: pointer; }
.literature-ai-settings form { display: grid; gap: 7px; padding: 8px 0; }
.literature-ai-settings label { display: grid; gap: 3px; }
.literature-ai-settings input { width: 100%; min-width: 0; padding: 6px; border: 1px solid var(--line); border-radius: 4px; }
.literature-ai-settings form div { display: flex; gap: 6px; }
.literature-ai-settings form button { font-size: 11px; }
.literature-ai-note { margin: 12px 0; border: 1px solid #9bcfc5; border-radius: 6px; background: #f5faf9; }
.literature-ai-note summary { cursor: pointer; padding: 9px 10px; font-size: 13px; font-weight: 600; }
.literature-ai-note-content { max-height: min(48vh, 480px); overflow: auto; padding: 0 10px 10px; overflow-wrap: anywhere; font-size: 12px; line-height: 1.55; }
.literature-ai-note-content h4, .literature-ai-note-content h5 { margin: 12px 0 5px; line-height: 1.4; }
.literature-ai-note-content h4 { font-size: 13px; }
.literature-ai-note-content h5 { font-size: 12px; }
.literature-ai-note-content p { margin: 5px 0 10px; }
.literature-ai-note-content ul { margin: 5px 0 10px; padding-left: 18px; }
.literature-ai-note-content li { margin: 3px 0; }
.literature-ai-note-content blockquote { margin: 7px 0; padding: 7px 9px; border-left: 3px solid #75b5a9; background: #fff; }
.literature-ai-note-content code { padding: 1px 3px; border-radius: 3px; background: #e8f0ee; font-size: .95em; }
.literature-ai-note-content .literature-math { font-family: "Cambria Math", "STIX Two Math", serif; white-space: nowrap; }
.literature-ai-note-content .literature-display-math { overflow-x: auto; margin: 8px 0; padding: 8px; border: 1px solid #d6e5e0; border-radius: 4px; background: #fff; font: 12px/1.5 "Cambria Math", "STIX Two Math", serif; white-space: pre; }
.literature-ai-note-content .katex-display { margin: 0; text-align: left; }
.literature-ai-note-content .katex-display > .katex { text-align: left; }
.literature-ai-note-content .literature-note-figure { display: block; width: 100%; height: auto; margin: 8px 0; border: 1px solid #d6e5e0; border-radius: 4px; cursor: zoom-in; }
.literature-ai-note-content .literature-note-table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: 11px; }
.literature-ai-note-content .literature-note-table th, .literature-ai-note-content .literature-note-table td { padding: 5px; border: 1px solid #cbdad5; text-align: left; vertical-align: top; }
.literature-ai-note-content .literature-note-table th { background: #e8f3f0; }
#literatureMessage { min-height: 2.5em; }
.literature-error { color: #a12b2b; }
.literature-annotation-form { display: grid; gap: 9px; padding: 11px; margin: 9px 0; border: 1px solid #9bcfc5; border-radius: 6px; background: #f5faf9; }
.literature-annotation-form[hidden] { display: none; }
.literature-annotation-form label { display: grid; gap: 4px; font-size: 12px; }
.literature-annotation-form textarea { width: 100%; resize: vertical; min-height: 45px; border: 1px solid var(--line); border-radius: 4px; padding: 6px; }
.literature-annotation-form input[type=color] { height: 30px; width: 55px; }
.literature-annotation-form div { display: flex; gap: 5px; }
.literature-annotations { display: grid; gap: 9px; }
.literature-annotation { border: 1px solid var(--line); border-left: 5px solid #ffe08a; border-radius: 5px; padding: 9px; }
.literature-note-jump { color: var(--accent-dark); border: 0; padding: 0; background: transparent; font-weight: 600; cursor: pointer; }
.literature-annotation blockquote { margin: 7px 0; padding-left: 8px; border-left: 2px solid var(--line); font-size: 12px; line-height: 1.4; white-space: pre-wrap; max-height: 130px; overflow: auto; }
.literature-annotation p { margin: 7px 0; font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.literature-note-actions { display: flex; gap: 5px; }
.literature-note-actions button { padding: 4px 6px; font-size: 11px; }
@media (max-width: 1200px) { .literature-shell { grid-template-columns: 150px 230px minmax(0, 1fr); } .literature-reader-body { --literature-notes-default-width: 270px; } }
@media (max-width: 1200px) { .literature-shell.literature-list-collapsed { grid-template-columns: 150px 50px minmax(0, 1fr); } }
@media (max-width: 850px) { .literature-shell { grid-template-columns: 145px minmax(0, 1fr); height: auto; min-height: calc(100vh - 56px); } .literature-list-panel { grid-column: 2; max-height: 220px; } .literature-reading-panel { grid-column: 1 / -1; height: 750px; } }
@media (max-width: 850px) { .literature-shell.literature-list-collapsed { grid-template-columns: 145px 50px minmax(0, 1fr); } .literature-list-collapsed .literature-reading-panel { grid-column: 3; } }
@media (max-width: 600px) { .literature-shell { display: block; } .literature-categories { max-height: 165px; } .literature-list-panel { max-height: 240px; } .literature-reading-panel { height: 900px; } .literature-reader-body { display: flex; flex-direction: column; } .literature-pdf-area { min-height: 550px; flex: 1; } .literature-notes { max-height: 300px; border-left: 0; border-top: 1px solid var(--line); } }
@media (max-width: 600px) { .literature-notes-resize { display: none; } }
@media (max-width: 600px) { .literature-list-collapsed .literature-list-panel { max-height: 50px; } .literature-list-collapsed .literature-list-panel .literature-panel-head { justify-content: flex-start; } }
