:root {
  --header-h: 3rem;
}

.app-header {
  height: var(--header-h);
}

.app-body {
  padding-top: var(--header-h);
}

.tree-panel {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
}

.tree-node {
  cursor: pointer;
  user-select: none;
}

.tree-node.has-list > .tree-label {
  color: #2563eb;
  font-weight: 600;
}

.tree-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.tree-label:hover {
  background: #f1f5f9;
}

.tree-label.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.tree-label.tree-root {
  font-weight: 600;
  color: #475569;
}

.tree-badge {
  margin-left: auto;
  font-size: 0.7rem;
  opacity: 0.7;
}

.tree-action-btn {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  line-height: 1;
  background: white;
}

.tree-action-btn:hover:not(:disabled) {
  background: #f1f5f9;
}

.tree-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tree-context-menu {
  position: fixed;
  z-index: 60;
  min-width: 8rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgb(15 23 42 / 0.12);
  padding: 0.25rem;
}

.tree-context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

.tree-context-menu button:hover {
  background: #f1f5f9;
}

.tree-context-menu button.danger {
  color: #dc2626;
}

.tree-children {
  margin-left: 0.75rem;
  border-left: 1px solid #e2e8f0;
}

.papers-table {
  border-collapse: collapse;
}

.papers-table th,
.papers-table td {
  border: 1px solid #e2e8f0;
  padding: 0.375rem 0.5rem;
  vertical-align: top;
}

.papers-table th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: #64748b;
}

.papers-table tbody tr:hover {
  background: #f8fafc;
}

.papers-table td.editable {
  cursor: text;
}

.papers-table td.editing {
  padding: 0;
}

.papers-table td.editing input,
.papers-table td.editing textarea,
.papers-table td.editing select {
  width: 100%;
  border: 2px solid #3b82f6;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  outline: none;
}

.paper-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.875rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.paper-card.selected {
  border-color: #3b82f6;
  background: #eff6ff;
}

.paper-card .title {
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.4;
  margin-bottom: 0.375rem;
}

.toast.show {
  opacity: 1;
}

.loading-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgb(255 255 255 / 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-spinner.dark {
  border-color: rgb(15 23 42 / 0.15);
  border-top-color: #2563eb;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button.is-loading {
  opacity: 0.85;
  pointer-events: none;
}

.add-dialog::backdrop,
.detail-dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.drawer-overlay.open {
  display: block;
}

.tree-drawer.open {
  transform: translateX(0);
}

@media (max-width: 767px) {
  .add-dialog {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
  }
}


/* Summary 非模态编辑面板 */
main {
  position: relative;
}

.summary-editor {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0.75rem;
  pointer-events: none;
  animation: summary-editor-fade-in 0.2s ease-out;
}

.summary-editor.hidden {
  display: none;
}

.summary-editor-panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  background: white;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  box-shadow:
    0 4px 6px -1px rgb(15 23 42 / 0.06),
    0 20px 48px -12px rgb(15 23 42 / 0.18);
  overflow: hidden;
  animation: summary-editor-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.summary-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border-bottom: 1px solid #e2e8f0;
}

.summary-editor-meta {
  min-width: 0;
  flex: 1;
}

.summary-editor-label {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3b82f6;
  margin-bottom: 0.375rem;
}

.summary-editor-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  color: #0f172a;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.summary-editor-paperid {
  display: inline-block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #64748b;
  background: rgb(255 255 255 / 0.7);
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
}

.summary-editor-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: #64748b;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.summary-editor-close:hover {
  background: rgb(255 255 255 / 0.8);
  color: #0f172a;
}

.summary-editor-body {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.25rem;
  background: #fafbfc;
}

.summary-editor-textarea {
  width: 100%;
  height: 100%;
  min-height: 280px;
  resize: none;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem 1.125rem;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: #1e293b;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.summary-editor-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.12);
}

.summary-editor-textarea::placeholder {
  color: #94a3b8;
}

.summary-editor-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.summary-editor-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  background: white;
  flex-wrap: wrap;
}

.summary-editor-count {
  font-size: 0.75rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.summary-editor-hint {
  flex: 1;
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: center;
  min-width: 10rem;
}

.summary-editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.summary-editor-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.summary-editor-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.summary-editor-btn-cancel {
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
}

.summary-editor-btn-cancel:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.summary-editor-btn-save {
  border: none;
  background: #2563eb;
  color: white;
}

.summary-editor-btn-save:hover:not(:disabled) {
  background: #1d4ed8;
}

body.summary-editor-open .papers-table tbody tr:hover {
  background: inherit;
}

body.summary-editor-open .papers-table td.editing {
  background: #eff6ff;
  box-shadow: inset 0 0 0 2px #3b82f6;
}

@keyframes summary-editor-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes summary-editor-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 768px) {
  .summary-editor {
    padding: 1rem 1.25rem 1.25rem;
  }

  .summary-editor-textarea {
    min-height: 360px;
  }
}
