:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #65716b;
  --line: #d7ded9;
  --panel: #ffffff;
  --paper: #f5f7f4;
  --accent: #1f6f5b;
  --accent-strong: #144a3d;
  --danger: #ad2f2f;
  --warning: #a05a00;
  --ok: #247044;
  --shadow: 0 14px 34px rgba(24, 32, 29, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* Applied to pages gated by auth-guard.js's requireAuth() — keeps the
   authenticated shell invisible until the session check resolves, instead
   of flashing it before a possible redirect to login.html. Removed via JS
   once requireAuth() confirms a valid session. */
body.auth-pending {
  visibility: hidden;
}

/* Full-viewport overlay shown while chem-boot.js loads RDKit. Sits in the
   markup alongside the (currently auth-pending, so invisible) app shell —
   `visibility: visible` deliberately overrides the inherited
   `visibility: hidden` from body.auth-pending above, so this stays on
   screen while the rest of the shell is still hidden underneath it.
   Hidden via the `hidden` attribute once bootChemEngine() resolves. */
.chem-loading-overlay {
  position: fixed;
  inset: 0;
  visibility: visible;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.9rem;
}

.chem-loading-overlay[hidden] {
  display: none;
}

.chem-loading-overlay .spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: chem-spinner-rotate 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes chem-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

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

button,
select,
input {
  min-height: 38px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

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

button.secondary {
  background: #e7ece8;
  color: var(--ink);
}

button.secondary:hover {
  background: #d9e0db;
}

button.tertiary {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
  font-weight: 700;
}

button.tertiary:hover {
  background: #f4f7f5;
  color: var(--ink);
}

label,
.label,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

select,
input {
  padding: 0 10px;
}

input[data-field="title"]::placeholder {
  color: color-mix(in srgb, var(--muted) 68%, transparent);
}

textarea {
  min-height: 230px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* Top-level flex skeleton shared by both routes: a full-width .app-header
   bar (fixed height) stacked over whatever workspace body the page mounts
   (.app-shell's compound grid on SI Writer, .workspace-columns' sidebar +
   log stream on Experiment Capture). Both bodies carry the .workspace-body
   marker class so the sidebar-collapsed rules below apply identically to
   either one without coupling to their differing layout mode (grid vs flex). */
.app-viewport {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}

.workspace-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: #eef2ef;
  flex-shrink: 0;
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.workspace-tab:hover {
  color: var(--ink);
}

.workspace-tab.active {
  background: var(--ink);
  color: #fff;
}

.workspace-tab.disabled {
  color: var(--muted);
  opacity: 0.6;
  cursor: not-allowed;
}

.workspace-tab.disabled:hover {
  color: var(--muted);
}

.coming-soon-badge {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--muted);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

button.coming-soon:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.coming-soon-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 80px 24px;
  text-align: center;
  color: var(--muted);
}

.coming-soon-panel h2 {
  color: var(--ink);
  margin: 0;
}

.coming-soon-panel p {
  margin: 0;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 248px) 9px minmax(0, 1fr) 9px var(--detail-w, 420px);
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --sidebar-w / --detail-w are set inline by layout.js (js/layout.js), which
   is also what drives the .sidebar-collapsed class itself — see
   applyLayoutVars(). No width rule lives here so there's a single source of
   truth for panel sizing. */

.resize-handle {
  position: relative;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
}

.resize-handle::before {
  /* Wider than the visible line so the drag target is comfortable without
     the divider itself looking thick at rest. */
  content: "";
  position: absolute;
  inset: 0;
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 28px;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  background: var(--line);
  transition: background-color 0.12s ease, height 0.12s ease;
}

.resize-handle:hover::after,
.resize-handle:focus-visible::after {
  background: var(--accent);
  height: 44px;
}

.resize-handle:focus-visible {
  outline: none;
}

.workspace-body.sidebar-collapsed #sidebarResizeHandle {
  pointer-events: none;
}

.workspace-body.sidebar-collapsed #sidebarResizeHandle::after {
  opacity: 0.35;
}

body.resizing-panels {
  cursor: col-resize;
  user-select: none;
}

body.resizing-panels .resize-handle::after {
  background: var(--accent);
  height: 44px;
}

.projects-sidebar {
  background: #121512;
  color: #e7ece8;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.projects-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.projects-title {
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #b9c2bc;
  white-space: nowrap;
  overflow: hidden;
}

.toggle-sidebar-btn {
  background: transparent;
  color: #b9c2bc;
  border: 1px solid rgba(255, 255, 255, 0.16);
  min-height: 28px;
  min-width: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-weight: 800;
  flex-shrink: 0;
}

.toggle-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.new-project-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  flex-shrink: 0;
}

.new-project-btn,
.import-bundle-btn {
  flex: 1 1 100px;
  min-width: 0;
  min-height: 34px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-project-btn {
  background: #1f6f5b;
  color: #fff;
}

.new-project-btn:hover {
  background: #144a3d;
}

.import-bundle-btn {
  background: transparent;
  color: #b9c2bc;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.import-bundle-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.06);
}

.projects-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  border-radius: 6px;
  padding: 3px;
}

.project-row .project-select-btn {
  /* Grows to fill the row at comfortable widths, but won't shrink past a
     legible size — if the fixed-size Rename/Delete buttons don't fit
     alongside it, they wrap to their own line below instead of crushing
     the name down to a sliver. */
  flex: 1 1 88px;
  min-width: 60px;
}

.project-row.active {
  background: rgba(31, 111, 91, 0.4);
}

.project-select-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  color: #d7ddd9;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-row.active .project-select-btn {
  color: #fff;
}

.project-select-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.project-menu-btn {
  /* Always hit-testable (no pointer-events toggling) — only opacity fades
     for the "reveal on hover" look. Gating clickability on live :hover
     state is a real footgun, not just a testing one: a click landing
     before the hover state has visually settled can miss the element
     entirely since it's excluded from hit-testing while pointer-events is
     none. */
  flex-shrink: 0;
  opacity: 0;
  background: transparent;
  color: #b9c2bc;
  border: 1px solid transparent;
  min-width: 26px;
  min-height: 28px;
  padding: 0 6px;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  border-radius: 5px;
  transition: opacity 0.1s ease;
}

.project-row:hover .project-menu-btn,
.project-row:focus-within .project-menu-btn,
.project-row.menu-open .project-menu-btn {
  opacity: 1;
}

.project-menu-btn:hover,
.project-menu-btn:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
}

.project-rename-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  background: #1b211e;
  border: 1px solid #1f6f5b;
  color: #fff;
  border-radius: 5px;
  padding: 0 10px;
}

/* Portal dropdown: appended directly to <body> (see projects-sidebar.js)
   rather than nested in the sidebar, so it floats over the main workspace
   instead of being clipped by .projects-sidebar/.projects-list's overflow
   and never affects the sidebar's own width. */
.project-menu-dropdown {
  position: fixed;
  z-index: 2000;
  min-width: 176px;
  padding: 4px;
  background: #1b211e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #e7ece8;
  border: none;
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 5px;
}

.project-menu-item:hover,
.project-menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.project-menu-item-danger {
  color: #ff9a9a;
}

.project-menu-item-danger:hover,
.project-menu-item-danger:focus-visible {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
}

/* Daily project-history browse/restore modal (history-panel.js) — shared by
   both index.html and experiment.html's independent projects-sidebar
   implementations. */
.history-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(24, 32, 29, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.history-panel {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.history-panel-header h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.history-panel-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
}

.history-panel-close:hover,
.history-panel-close:focus-visible {
  background: var(--paper);
  color: var(--ink);
}

.history-panel-body {
  overflow-y: auto;
  padding: 8px;
}

.history-snapshot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-snapshot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px;
  border-radius: 6px;
}

.history-snapshot-row:hover {
  background: var(--paper);
}

.history-snapshot-date {
  font-size: 0.85rem;
  color: var(--ink);
}

.history-restore-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.history-restore-btn:hover,
.history-restore-btn:focus-visible {
  background: var(--accent-strong);
}

.history-restore-btn:disabled {
  opacity: 0.6;
}

.history-empty {
  margin: 0;
  padding: 12px 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.project-row-deleting {
  display: block;
  border-radius: 6px;
  padding: 8px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
}

.project-delete-warning {
  margin: 0 0 8px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: #f0c9c9;
}

.project-delete-warning strong {
  color: #ff9a9a;
  letter-spacing: 0.03em;
}

.project-delete-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.project-delete-input {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  background: #1b211e;
  border: 1px solid var(--danger);
  color: #fff;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 0.8rem;
}

.project-delete-confirm-btn {
  background: var(--danger);
  color: #fff;
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 5px;
  flex-shrink: 0;
}

.project-delete-confirm-btn:not(:disabled):hover {
  background: #c53d3d;
}

.project-delete-confirm-btn:disabled {
  background: #4a2b2b;
  color: #a98080;
  cursor: not-allowed;
}

.project-delete-cancel-btn {
  background: transparent;
  color: #b9c2bc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 5px;
  flex-shrink: 0;
}

.project-delete-cancel-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.34);
}

.workspace-bundle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.bundle-btn {
  flex: 1 1 auto;
  background: transparent;
  color: #b9c2bc;
  border: 1px solid rgba(255, 255, 255, 0.16);
  min-height: 32px;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 5px;
  white-space: nowrap;
}

.bundle-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.06);
}

.bundle-btn-full {
  background: #1f6f5b;
  color: #fff;
  border-color: transparent;
  min-height: 34px;
  font-size: 0.75rem;
}

.bundle-btn-full:hover {
  background: #144a3d;
  border-color: transparent;
}

.bundle-status {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
  min-height: 0;
}

.bundle-status:empty {
  padding: 0;
}

.bundle-status-success {
  color: #7fd9a8;
}

.bundle-status-error {
  color: #ff9a9a;
}

.workspace-body.sidebar-collapsed .projects-title,
.workspace-body.sidebar-collapsed .new-project-row,
.workspace-body.sidebar-collapsed .projects-list,
.workspace-body.sidebar-collapsed .workspace-bundle-row,
.workspace-body.sidebar-collapsed .bundle-status {
  display: none;
}

.workspace-body.sidebar-collapsed .projects-sidebar-header {
  justify-content: center;
  padding: 16px 8px;
}

.workspace-body.sidebar-collapsed .toggle-sidebar-btn {
  transform: rotate(180deg);
}

.master-pane {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.master-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 244, 0.96);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.brand h1,
.brand p,
.detail-header h2,
.compound-title {
  margin: 0;
}

.brand h1 {
  font-size: 1.08rem;
}

.brand p {
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-controls-label {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-right: 2px;
}

.filter-toggle-btn {
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 850;
  border: 1px solid transparent;
}

.filter-toggle-btn.warning {
  background: #f5cd2e;
  color: #4a3900;
}

.filter-toggle-btn.warning:hover {
  background: #e6bf1f;
}

.filter-toggle-btn.error {
  background: #f0862e;
  color: #3a1c00;
}

.filter-toggle-btn.error:hover {
  background: #de751e;
}

.filter-toggle-btn.missing {
  background: #d9433f;
  color: #fff;
}

.filter-toggle-btn.missing:hover {
  background: #c33430;
}

.filter-toggle-btn.review {
  background: #6558d3;
  color: #fff;
}

.filter-toggle-btn.review:hover {
  background: #5548c4;
}

.completion-tracker {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fbe0c2;
  color: #a05a00;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
  transition: background-color 0.4s ease, color 0.4s ease;
}

@keyframes completion-flash {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(36, 112, 68, 0.55);
  }
  35% {
    transform: scale(1.14);
    box-shadow: 0 0 0 9px rgba(36, 112, 68, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(36, 112, 68, 0);
  }
}

.completion-tracker.flash {
  animation: completion-flash 0.55s ease-out;
}

@keyframes completion-celebrate {
  0% {
    transform: scale(1) rotate(0deg);
    box-shadow: 0 0 0 0 rgba(36, 112, 68, 0.6);
  }
  20% {
    transform: scale(1.24) rotate(-2deg);
    box-shadow: 0 0 0 4px rgba(36, 112, 68, 0.3);
  }
  45% {
    transform: scale(0.95) rotate(1.5deg);
  }
  70% {
    transform: scale(1.1) rotate(-1deg);
    box-shadow: 0 0 0 10px rgba(36, 112, 68, 0);
  }
  100% {
    transform: scale(1) rotate(0deg);
    box-shadow: 0 0 0 0 rgba(36, 112, 68, 0);
  }
}

.completion-tracker.celebrate {
  animation: completion-celebrate 0.9s ease-out;
}

.filter-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: none;
}

.filter-option input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.compound-list {
  display: grid;
  gap: 12px;
  padding: 18px 22px 28px;
}

.compound-list.compound-drop-open {
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(31, 111, 91, 0.15);
}

.series-group {
  display: grid;
  gap: 10px;
}

.standalone-compound-block {
  display: grid;
  gap: 8px;
}

.quick-add-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.quick-add-segment {
  min-height: 24px;
  border: 1px dashed transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  opacity: 0.8;
}

.quick-add-segment:hover,
.quick-add-segment:focus-visible {
  opacity: 1;
}

.quick-add-segment.add-series {
  color: #8a5400;
  background: #fff4e2;
  border-color: #f2d3a5;
}

.quick-add-segment.add-series:hover,
.quick-add-segment.add-series:focus-visible {
  background: #ffecd0;
}

.quick-add-segment.add-compound {
  color: #0f5f57;
  background: #e6f6f3;
  border-color: #c0e9e2;
}

.quick-add-segment.add-compound:hover,
.quick-add-segment.add-compound:focus-visible {
  background: #dcf1ed;
}

.series-meta-card {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4f1;
  cursor: grab;
}

.series-meta-card.collapsed {
  opacity: 0.98;
}

.series-meta-card:active {
  cursor: grabbing;
}

.series-meta-card.compound-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 111, 91, 0.18);
}

.series-meta-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.series-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.series-meta-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.series-status-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.series-status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.series-status-tag.warning {
  background: #fff4dd;
  color: #8b4d00;
  border-color: #f0d4a2;
}

.series-status-tag.error {
  background: #ffe8e8;
  color: #972d2d;
  border-color: #efb7b7;
}

.series-status-tag.missing {
  background: #ffeef3;
  color: #8b2f5c;
  border-color: #f1bfd5;
}

.series-status-tag.ok {
  background: #eaf7ee;
  color: #2a7043;
  border-color: #b9dec5;
}

.series-status-tag.off {
  background: #eef2ef;
  color: #5f6b65;
  border-color: #d2dad5;
}

.series-status-tag.review {
  background: #ece9fb;
  color: #4a3fa0;
  border-color: #c9c2f0;
}

.series-title-wrap {
  display: grid;
  gap: 4px;
}

.series-title-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.series-title-input {
  min-height: 38px;
}

.series-general-procedure-row {
  display: grid;
  gap: 8px;
}

.series-general-procedure-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.series-general-procedure-input {
  min-height: 90px;
}

.series-autofill-checkbox {
  min-height: 0;
  height: auto;
  padding: 8px 10px;
  white-space: normal;
  line-height: 1.3;
}

.stoichiometry-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.stoichiometry-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.stoichiometry-body {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.stoichiometry-section-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stoichiometry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.stoichiometry-table th,
.stoichiometry-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}

.stoichiometry-table th {
  color: var(--muted);
  font-weight: 700;
}

.series-index {
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.series-meta-title-input {
  display: grid;
  gap: 6px;
}

.series-compounds {
  display: grid;
  gap: 10px;
  margin-left: 18px;
  padding-left: 12px;
  border-left: 2px solid #d3ddd6;
}

.series-group.dragging {
  opacity: 0.72;
}

.series-group.drop-before {
  box-shadow: inset 0 3px 0 0 var(--accent);
  border-radius: 8px;
}

.series-group.drop-after {
  box-shadow: inset 0 -3px 0 0 var(--accent);
  border-radius: 8px;
}

.insert-divider {
  position: relative;
  width: 100%;
  height: 10px;
  min-height: 10px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.insert-divider span {
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  height: 2px;
  border-radius: 999px;
  background: #d8e1db;
  transition: background 120ms ease, transform 120ms ease;
}

.insert-divider:hover span,
.insert-divider:focus-visible span {
  background: var(--accent);
  transform: scaleY(1.6);
}

.compound-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.compound-card:focus-visible {
  outline: 2px solid rgba(31, 111, 91, 0.25);
  outline-offset: 2px;
}

.compound-card.complete {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px rgba(36, 112, 68, 0.14), var(--shadow);
}

.compound-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 111, 91, 0.14), var(--shadow);
}

.compound-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 111, 91, 0.2), var(--shadow);
}

.compound-card.dragging {
  opacity: 0.72;
}

.compound-card.drop-before {
  box-shadow: inset 0 3px 0 0 var(--accent), var(--shadow);
}

.compound-card.drop-after {
  box-shadow: inset 0 -3px 0 0 var(--accent), var(--shadow);
}

.card-summary {
  display: grid;
  grid-template-columns: 72px minmax(170px, 1fr) minmax(140px, auto) 108px 92px;
  gap: 12px;
  align-items: end;
}

.computed-id {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2f6f3;
  font-size: 1.05rem;
  font-weight: 900;
}

.warning-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 38px;
}

.warning-badges .series-status-tag {
  min-height: 24px;
  font-size: 0.72rem;
  padding: 0 7px;
}

.flag-triangle {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 950;
  line-height: 1;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  padding-top: 7px;
}

.flag-triangle.warning {
  background: #f0b432;
}

.flag-triangle.missing {
  background: var(--danger);
}

.flag-triangle.off {
  background: #d8dfda;
  color: #57625d;
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef8f1;
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 850;
}

.expand-button {
  width: 100%;
}

.card-expanded {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.compound-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.compound-meta-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  flex: 1;
  min-width: 280px;
}

.compound-meta-thumb {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
}

.compound-meta-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.raw-row {
  display: grid;
  gap: 8px;
}

.method-row {
  display: grid;
  gap: 8px;
}

.method-row textarea {
  min-height: 100px;
}

.formula-row {
  display: grid;
  gap: 8px;
}

.formula-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.formula-input-row input {
  flex: 1;
}

.notes-row {
  display: grid;
  gap: 8px;
}

.notes-row-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.notes-remove-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.notes-remove-btn:hover {
  color: var(--ink);
  background: none;
}

.reference-row {
  display: grid;
  gap: 8px;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: none;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
  min-height: 0;
  margin: 0;
}

.complete-toggle {
  justify-content: center;
  padding: 0 8px;
  gap: 6px;
  font-size: 0.76rem;
  white-space: nowrap;
}

.image-row {
  display: grid;
  gap: 8px;
}

.image-drop-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.focused-card-hint {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.image-row input[type="file"] {
  padding: 7px;
  min-height: 0;
}

.spectra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.spectrum-field {
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 168px;
  padding: 16px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.spectrum-field.drag-over {
  border-color: var(--accent);
  background: rgba(31, 111, 91, 0.06);
}

.image-preview {
  display: flex;
  justify-content: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
}

.image-preview img {
  max-width: min(100%, 340px);
  max-height: 220px;
  object-fit: contain;
  border-radius: 6px;
  cursor: zoom-in;
}

/* Full-screen image viewer opened by clicking any .image-preview img (see
   image-lightbox.js). A portal appended directly to <body>, so it sits
   above page-specific overlays like the detail drawer (z-index 50) and the
   card/project menu dropdowns (z-index 2000). */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 12, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.image-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.image-lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* "Link compound" modal (see compounds/picker.js). Portal appended directly
   to <body>, shared by all three silos -- same z-index tier as the image
   lightbox since only one full-screen overlay is ever open at a time. */
.compound-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 12, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.compound-picker-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.compound-picker-modal {
  width: min(92vw, 440px);
  max-height: 84vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compound-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compound-picker-header h3 {
  margin: 0;
}

.compound-picker-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.compound-picker-search {
  width: 100%;
}

.compound-picker-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.compound-picker-empty {
  color: var(--muted);
  margin: 0;
}

.compound-picker-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  cursor: pointer;
}

.compound-picker-result:hover {
  border-color: var(--accent);
}

.compound-picker-result-name {
  font-weight: 600;
  flex: 1;
}

.compound-picker-result-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.compound-picker-result-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent-strong);
  white-space: nowrap;
}

.compound-picker-create {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compound-picker-create h4 {
  margin: 0;
}

.compound-picker-create label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Paste/drop destination confirmation popup (see paste-destination-picker.js).
   Portal appended directly to <body>, shared by the SI Writer compound-card
   flow and the Experiment drawer flow -- same z-index tier as the compound
   picker and image lightbox since only one full-screen overlay is ever open
   at a time. */
.paste-destination-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 12, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.paste-destination-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.paste-destination-modal {
  width: min(92vw, 440px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paste-destination-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.paste-destination-header h3 {
  margin: 0;
}

.paste-destination-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.paste-destination-thumb {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f6f4;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.paste-destination-thumb.loaded {
  opacity: 1;
}

.paste-destination-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Keycap hint for the 1/2/3 shortcuts (see the digit handler in
   paste-destination-picker.js's keydown listener) -- a translucent chip so
   it reads on both the neutral and .suggested (solid-accent) button fills
   without a separate color per state. */
.paste-destination-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.1);
  vertical-align: middle;
}

.paste-destination-choice.suggested .paste-destination-key {
  background: rgba(255, 255, 255, 0.25);
}

/* Base state matches button.secondary (light, neutral) -- the .suggested
   modifier below promotes one button to the strong solid-accent look
   (the app's default button style) so the classifier's guess reads as the
   visually elevated choice, not the other way around. */
.paste-destination-choice {
  width: 100%;
  background: #e7ece8;
  color: var(--ink);
  border: 2px solid transparent;
}

.paste-destination-choice:hover {
  background: #d9e0db;
}

.paste-destination-choice.suggested {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-strong);
}

.paste-destination-choice.suggested:hover {
  background: var(--accent-strong);
}

.notes-row textarea {
  min-height: 120px;
}

.empty-compound-list {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--muted);
  font-weight: 600;
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.reorder-actions,
.edit-actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-actions {
  margin-left: auto;
}

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

.detail-header {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-heading {
  display: grid;
  gap: 4px;
}

.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.format-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  flex: 1 1 420px;
}

.detail-header h2 {
  margin-top: 3px;
  font-size: 1.35rem;
}

.preview-pane {
  min-height: 0;
  overflow: auto;
  margin: 18px;
  border: 1px solid #0f1714;
  border-radius: 8px;
  background: #101714;
  color: #e8f1ec;
  padding: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.status-panel strong {
  display: block;
  margin-top: 3px;
  font-size: 0.88rem;
}

.issue-list {
  display: grid;
  gap: 7px;
}

.summary-issue-list {
  display: grid;
  gap: 7px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.summary-issue-list .issue {
  font-size: 0.82rem;
  padding: 6px 8px;
}

.issue {
  border-left: 4px solid var(--warning);
  padding: 8px 10px;
  background: #fff8ec;
  font-size: 0.9rem;
}

.issue.error {
  border-left-color: var(--danger);
  background: #fff0f0;
}

.issue.ok {
  border-left-color: var(--ok);
  background: #eef8f1;
}

.issue.review {
  border-left-color: #6558d3;
  background: #f2f0fc;
}

.review-approve-btn {
  border-color: #6558d3;
  color: #4a3fa0;
}

@media (max-width: 1080px) {
  /* The .app-viewport/.app-header skeleton stays fixed-height and sticky at
     every width — only the workspace body beneath it (.app-shell's grid,
     .workspace-columns' flex row) stacks and unlocks page scroll here. */
  .app-viewport {
    height: auto;
    overflow: visible;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    flex: none;
    height: auto;
    overflow: visible;
  }

  /* Panels stack vertically below this width, so column resizing no longer
     applies — the handles would otherwise render as awkward horizontal
     slivers between stacked sections. */
  .resize-handle {
    display: none;
  }

  .master-pane,
  .detail-pane {
    height: auto;
    overflow: visible;
  }

  .detail-pane {
    border-top: 1px solid var(--line);
  }

  .preview-pane {
    min-height: 340px;
  }
}

@media (max-width: 760px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace-tabs {
    justify-content: center;
  }

  .app-header-actions {
    margin-left: 0;
    justify-content: flex-end;
  }

  .card-summary,
  .compound-meta-fields,
  .status-panel {
    grid-template-columns: 1fr;
  }

  .compound-meta-thumb {
    align-self: center;
  }

  .filter-controls,
  .detail-toolbar,
  .format-controls,
  .card-actions,
  .detail-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .app-header,
  .master-toolbar,
  .compound-list {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .series-meta-actions {
    justify-content: space-between;
    flex-wrap: wrap;
  }
}

.unclassified-panel {
  margin: 0 20px 14px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #c9c2f0;
  background: #f2f0fc;
}

.unclassified-panel-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: #4a3fa0;
}

.unclassified-panel-header strong {
  font-size: 0.9rem;
}

.unclassified-list {
  display: grid;
  gap: 10px;
}

.unclassified-entry {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.unclassified-entry pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.85rem;
  max-height: 160px;
  overflow-y: auto;
}

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: var(--ok);
}

.toast-error {
  background: var(--danger);
}

.toast-info {
  background: var(--accent);
}
