/* ===== Lab105 Design System — Light Knowledge Base Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

:root {
  --font-sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;

  /* Knowledge-base palette */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-muted: #F1F5F9;
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-soft: #EFF6FF;
  --primary-border: #BFDBFE;
  --secondary: #60A5FA;
  --text: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #FFFFFF;
  --border: #E2E8F0;
  --border-hover: #CBD5E1;
  --success: #10B981;
  --success-soft: #ECFDF5;
  --warning: #F59E0B;
  --warning-soft: #FFFBEB;
  --danger: #EF4444;
  --danger-soft: #FEF2F2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: .2s ease;

  --sidebar-width: 260px;
  --header-height: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.6); border: 2px solid transparent; background-clip: content-box; }

/* ===== Animations & Skeleton ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton {
  background: var(--surface-muted);
  position: relative; overflow: hidden; border-radius: var(--radius);
}
.skeleton::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0.4) 20%, rgba(255,255,255,0.6) 60%, rgba(255,255,255,0) 100%);
  animation: shimmer 1.5s infinite;
}

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(226, 232, 240, 0.6);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform .3s ease;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  border: none;
  background: rgba(15, 23, 42, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
  z-index: 35;
}
.sidebar-header {
  height: calc(var(--header-height) + var(--safe-top));
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--safe-top) 20px 0 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
}
.sidebar-title { font-size: 18px; font-weight: 600; color: var(--text); }
.sidebar-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.sidebar-toggle:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-hover);
}
.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 20px; }
.nav-section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .5px;
  padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--text-secondary); font-size: 16px; font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(241, 245, 249, 0.8); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft); color: var(--primary);
  font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
  padding: 14px 16px;
  padding-bottom: calc(14px + var(--safe-bottom));
  border-top: 1px solid rgba(226, 232, 240, 0.6);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(241, 245, 249, 0.8); }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818CF8);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 12px; color: var(--text-muted); }

/* Main area */
.main-content {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left .2s ease;
}

/* Top header */
.top-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  display: flex; align-items: center; justify-content: space-between;
  padding: max(0px, var(--safe-top)) calc(28px + var(--safe-right)) 0 calc(28px + var(--safe-left));
  position: sticky; top: 0; z-index: 30;
}
.top-header-start {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.page-title { font-size: 22px; font-weight: 600; color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.sidebar-toggle-header {
  display: none;
}

body.sidebar-collapsed .sidebar {
  width: 88px;
}
body.sidebar-collapsed .main-content {
  margin-left: 88px;
}
body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-item-label,
body.sidebar-collapsed .sidebar-user-info {
  display: none;
}
body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}
body.sidebar-collapsed .sidebar-user {
  justify-content: center;
}
body.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Page body */
.page-body {
  flex: 1;
  padding: 24px calc(28px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(28px + var(--safe-left));
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 18px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 16px; font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap; line-height: 1.4;
  min-height: 42px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--text-inverse); }
.btn-primary:hover { background: var(--primary-hover); color: var(--text-inverse); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-muted); border-color: var(--border-hover); }
.btn-danger { background: var(--danger); color: var(--text-inverse); }
.btn-danger:hover { background: #DC2626; color: var(--text-inverse); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 15px; }
.btn-lg { padding: 10px 20px; font-size: 18px; }
.btn svg { width: 16px; height: 16px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 15px; font-weight: 500;
  color: var(--text); margin-bottom: 5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 15px; transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 42px;
}
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: var(--border-hover); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-height: calc(100vh - 200px);
}
.mobile-stack-table td[data-label]::before {
  content: none;
}
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 16px; }
.data-table th {
  background: var(--surface-muted); color: var(--text-secondary);
  font-weight: 600; text-align: left;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 15px; white-space: nowrap;
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(4px); background: rgba(241, 245, 249, 0.9);
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
  background: var(--surface);
}
.data-table tbody tr:nth-child(even) td { background: #FAFAFA; }
.data-table tbody tr { transition: transform 0.1s, box-shadow 0.1s; }
.data-table tbody tr:hover td { background: var(--primary-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 16px; font-size: 16px; font-weight: 500;
  color: var(--text-muted); border: none; background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition);
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.list-tabs {
  margin-bottom: 18px;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 100px;
  font-size: 14px; font-weight: 500; line-height: 1.6;
}
.code-badge {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  color: #1d4ed8;
  background: #e0ecff;
  border: 1px solid #bfd3ff;
  font-weight: 700;
}
.cabinet-seq-badge {
  font-family: var(--font-mono);
  color: #dc2626;
  background: #fee2e2;
  border: 1px solid #fecaca;
  font-weight: 700;
}
.code-display {
  padding: 12px 0;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.08em;
  line-height: 1.4;
}
.code-display-secondary {
  color: #dc2626;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-gray { background: var(--surface-muted); color: var(--text-muted); }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  will-change: opacity;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 90%; max-width: 500px;
  box-shadow: 0 16px 32px -10px rgba(15, 23, 42, 0.18), 0 8px 16px -12px rgba(15, 23, 42, 0.18);
  transform: translateY(12px) scale(0.985);
  transition: transform 0.18s ease, opacity 0.18s ease;
  will-change: transform;
  max-height: min(calc(86vh - var(--safe-top) - var(--safe-bottom)), 900px);
  overflow: auto;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border: none; background: none;
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition);
}
.modal-close:hover { background: var(--surface-muted); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px; border-top: 1px solid var(--border);
}
body.modal-open {
  overflow: hidden;
}
body.sidebar-mobile-open {
  overflow: hidden;
}

@supports ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .modal-overlay {
    background: rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
  }
}

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
  display: flex; align-items: center; gap: 8px;
  min-width: 260px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

/* ===== Search bar ===== */
.search-bar {
  position: relative; max-width: 320px;
}
.search-bar .form-input { padding-left: 36px; }
.search-bar svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted);
}

/* ===== Tag-list (for supplies/steps) ===== */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 100px;
  background: var(--surface-muted); border: 1px solid var(--border);
  font-size: 14px; color: var(--text-secondary);
}
.tag-item .tag-remove {
  width: 14px; height: 14px; border: none; background: none;
  color: var(--text-muted); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all var(--transition);
}
.tag-item .tag-remove:hover { background: var(--danger-soft); color: var(--danger); }

/* ===== Sortable list ===== */
.sortable-list { list-style: none; }
.sortable-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 6px;
  background: var(--surface); transition: all var(--transition);
}
.sortable-item:hover { border-color: var(--primary-border); background: var(--primary-soft); }
.sortable-item .step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.sortable-item .step-content { flex: 1; font-size: 14px; line-height: 1.6; }
.sortable-item .step-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .5; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ===== Login page ===== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 50%, #F0FDF4 100%);
}
.login-card {
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 40px;
  width: 100%; max-width: 400px;
  border: 1px solid var(--border);
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
}
.login-title { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ===== Flash messages ===== */
.flash {
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 14px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #FECACA; }
.flash-success { background: var(--success-soft); color: var(--success); border: 1px solid #A7F3D0; }

/* ===== Experiment cards grid ===== */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.experiment-group-section {
  display: grid;
  gap: 14px;
}
.experiment-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.exp-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); cursor: pointer;
}
.exp-card:hover { 
  box-shadow: 0 12px 24px -6px rgba(59, 130, 246, 0.15), 0 4px 10px -2px rgba(59, 130, 246, 0.08); 
  transform: translateY(-4px); 
  border-color: var(--primary-border); 
}
.exp-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.exp-card-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.exp-card-select input {
  width: 14px;
  height: 14px;
}
.exp-card-title {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}
.exp-card-code { font-family: var(--font-mono); font-size: 14px; color: var(--text-muted); background: var(--surface-muted); padding: 4px 8px; border-radius: 6px; }
.exp-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.exp-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.exp-card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.exp-card-time { font-size: 12px; color: var(--text-muted); }
.exp-type-badge {
  width: 108px;
  min-width: 108px;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 10px;
  padding-right: 10px;
}
.exp-meta-badge {
  font-weight: 600;
}
.exp-meta-supply {
  background: #ecfdf5;
  color: #059669;
}
.exp-meta-step {
  background: #fff7ed;
  color: #ea580c;
}

/* ===== Two-pane layout (record create) ===== */
.split-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-height: calc(100vh - var(--header-height) - 100px); }
.split-pane { display: flex; flex-direction: column; }

/* ===== Reagent-picker (autocomplete) ===== */
.reagent-picker { position: relative; }
.reagent-picker-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 200px; overflow-y: auto; z-index: 50;
  display: none;
}
.reagent-picker-results.show { display: block; }
.reagent-picker-item {
  padding: 10px 12px; cursor: pointer; font-size: 15px;
  transition: background var(--transition);
}
.reagent-picker-item:hover { background: var(--primary-soft); }

/* ===== Shared page layouts ===== */
.toolbar-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar-inline .search-bar {
  flex: 1;
  min-width: 240px;
}
.dashboard-grid,
.detail-grid,
.stack-grid {
  display: grid;
  gap: 20px;
}
.dashboard-grid,
.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.record-row-actions {
  justify-content: flex-start;
  min-width: 0;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.info-chip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 12px 14px;
}
.info-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.summary-list {
  margin-left: 20px;
  display: grid;
  gap: 8px;
}
.content-block {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
}
.compact-empty {
  padding: 24px 12px;
}
.danger-card {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.record-builder-list {
  display: grid;
  gap: 16px;
}
.builder-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
}
.builder-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}
.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
}
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.option-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.option-card p {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}
.flash-info {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-100%);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  }
  .sidebar.open { transform: translateX(0); }
  body.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .main-content { margin-left: 0; }
  .split-layout { grid-template-columns: 1fr; }
  .dashboard-grid,
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .danger-card { flex-direction: column; align-items: stretch; }
  .card {
    padding: 16px;
    border-radius: 14px;
  }
  .card-header,
  .detail-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .top-header {
    height: auto;
    min-height: var(--header-height);
    align-items: flex-start;
    gap: 12px;
    padding-top: calc(14px + var(--safe-top));
    padding-bottom: 14px;
  }
  .top-header-start,
  .header-actions {
    width: 100%;
  }
  .page-title {
    font-size: 20px;
    line-height: 1.35;
    word-break: break-word;
  }
  .page-body {
    padding: 18px calc(16px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(16px + var(--safe-left));
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .header-actions > * {
    max-width: 100%;
  }
  .toolbar-inline {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-inline > * {
    width: 100%;
  }
  .experiment-filter-select,
  .experiment-sort-select {
    width: 100%;
  }
  .toolbar-inline .search-bar,
  .search-bar {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .form-actions,
  .row-actions,
  .experiment-inline-entry,
  .experiment-inline-actions,
  .record-card-section-meta {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .btn,
  .row-actions .btn,
  .experiment-inline-actions .btn,
  .experiment-inline-entry .btn {
    width: 100%;
  }
  .tabs {
    gap: 6px;
    padding-bottom: 2px;
  }
  .tab {
    padding: 10px 14px;
  }
  .table-wrapper {
    max-height: none;
  }
  .data-table {
    min-width: 640px;
    font-size: 15px;
  }
  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }
  .mobile-stack-table {
    min-width: 0;
    border-spacing: 0;
  }
  .mobile-stack-table thead {
    display: none;
  }
  .mobile-stack-table,
  .mobile-stack-table tbody,
  .mobile-stack-table tr,
  .mobile-stack-table td {
    display: block;
    width: 100%;
  }
  .mobile-stack-table tbody tr {
    margin: 0 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .mobile-stack-table tbody tr:last-child {
    margin-bottom: 0;
  }
  .mobile-stack-table tbody tr:nth-child(even) td,
  .mobile-stack-table tbody tr:hover td {
    background: transparent;
  }
  .mobile-stack-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    display: grid;
    grid-template-columns: minmax(82px, 96px) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }
  .mobile-stack-table td:last-child {
    border-bottom: none;
  }
  .mobile-stack-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    text-transform: none;
  }
  .mobile-stack-table td[colspan] {
    display: table-cell;
  }
  .mobile-stack-table td[colspan]::before {
    content: none;
  }
  .mobile-stack-table td .row-actions,
  .mobile-stack-table td .table-actions {
    justify-content: flex-start;
  }
  .mobile-stack-table td .btn {
    width: auto;
  }
  .sidebar-toggle-header {
    display: inline-flex;
  }
  .modal {
    width: calc(100% - 16px - var(--safe-left) - var(--safe-right));
    max-height: calc(100vh - 16px - var(--safe-top) - var(--safe-bottom));
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .modal-footer {
    flex-direction: column-reverse;
  }
  .modal-footer .btn {
    width: 100%;
  }
  .toast-container {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(12px + var(--safe-bottom));
  }
  .toast {
    width: 100%;
    min-width: 0;
  }
  .pagination {
    justify-content: stretch;
    gap: 8px;
  }
  .pagination > * {
    width: 100%;
  }
  .pagination-jump {
    flex-wrap: wrap;
  }
  .pagination-input {
    width: 100%;
    min-height: 42px;
  }
}

/* Utility */
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ===== Empty States ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; color: var(--text-muted); text-align: center;
}
.empty-state svg {
  width: 64px; height: 64px; color: var(--border-hover); margin-bottom: 16px;
}
.empty-state p {
  font-size: 15px; margin-bottom: 12px; color: var(--text-secondary);
}

/* ===== Pagination ===== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.pagination-info {
  font-size: 14px; color: var(--text-muted);
}
.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}
.pagination-input {
  width: 68px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  text-align: center;
  background: var(--surface);
  color: var(--text);
}
.pagination button:disabled {
  opacity: .4; cursor: not-allowed;
}

/* ===== Reagent page tuning ===== */
.reagent-page .tabs {
  gap: 8px;
  margin-bottom: 24px;
}
.reagent-page #reagentTable {
  table-layout: auto;
  min-width: 1320px;
}
.reagent-page .reagent-col-code {
  width: 132px;
}
.reagent-page .reagent-col-inner-seq {
  width: 96px;
}
.reagent-page .reagent-col-name {
  width: 240px;
}
.reagent-page .reagent-col-control,
.reagent-page .reagent-col-danger,
.reagent-page .reagent-col-state {
  width: 120px;
}
.reagent-page .reagent-col-location {
  width: 150px;
}
.reagent-page .reagent-col-stock {
  width: 190px;
}
.reagent-page .reagent-col-last-use {
  width: 170px;
}
.reagent-page .reagent-col-actions {
  width: 230px;
}
.reagent-page .reagent-table-card {
  padding: 0;
}
.reagent-page .reagent-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
}
.reagent-page .tab {
  padding: 10px 14px;
  font-size: 17px;
}
.reagent-page .search-bar {
  max-width: 420px;
}
.reagent-page .search-bar .form-input,
.reagent-page .form-label,
.reagent-page .form-input,
.reagent-page .form-select {
  font-size: 16px;
}
.reagent-page .data-table th {
  font-size: 16px;
}
.reagent-page .data-table td {
  font-size: 16px;
}
.reagent-page .badge {
  font-size: 15px;
}
.reagent-page .code-badge {
  font-size: 17px;
}
.reagent-page .cabinet-seq-badge {
  font-size: 16px;
}
.reagent-page .code-display {
  font-size: 26px;
}
.reagent-page .btn-sm {
  padding: 4px 6px;
  font-size: 14px;
}
.reagent-page .table-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.reagent-page .data-table td strong {
  word-break: keep-all;
  white-space: normal;
}

/* ===== Experiment form ===== */
.experiment-toolbar .search-bar {
  max-width: 360px;
}
.experiment-filter-select {
  width: 140px;
}
.experiment-sort-select {
  width: 140px;
}
.experiment-form {
  gap: 20px;
}
.experiment-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.95fr);
  gap: 18px;
  align-items: end;
}
.experiment-name-group {
  margin-bottom: 0;
}
.experiment-name-input {
  min-height: 52px;
  font-size: 18px;
  font-weight: 600;
}
.experiment-meta-row {
  display: grid;
  gap: 14px;
}
.experiment-meta-row-compact {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}
.experiment-meta-row-edit {
  grid-template-columns: repeat(3, minmax(140px, 1fr));
}
.experiment-type-group,
.experiment-code-group {
  margin-bottom: 0;
}
.experiment-top-panels {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 20px;
  align-items: start;
}
.experiment-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.85), rgba(255, 255, 255, 0.96));
  padding: 20px;
}
.experiment-supply-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.experiment-inline-entry,
.experiment-inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.experiment-inline-entry .form-input {
  flex: 1;
}
.experiment-item-board,
.step-preview-board,
.experiment-detail-list,
.step-detail-list {
  display: grid;
  gap: 12px;
}
.experiment-item-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.experiment-item-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 12px;
}
.experiment-item-meta {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}
.experiment-item-index,
.step-detail-index,
.step-preview-index {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
.experiment-item-copy {
  min-width: 0;
}
.experiment-item-copy strong {
  display: block;
  font-size: 16px;
}
.experiment-item-copy-sub {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.experiment-formula-grid,
.variable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.variable-builder-board {
  display: grid;
  gap: 12px;
}
.variable-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
}
.variable-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.step-editor-shell {
  display: grid;
  gap: 12px;
}
.step-editor-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.step-editor-surface {
  min-height: 220px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: 15px;
  line-height: 1.8;
  outline: none;
}
.step-editor-surface:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.step-editor-surface p + p {
  margin-top: 8px;
}
.editor-table,
.step-preview-body table,
.step-detail-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.editor-table td,
.step-preview-body td,
.step-detail-content td,
.editor-table th,
.step-preview-body th,
.step-detail-content th {
  border: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: top;
}
.step-preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.step-preview-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
}
.step-preview-card.dragging {
  opacity: .5;
}
.step-preview-card.drag-over {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.step-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.step-preview-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-preview-drag {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
}
.step-preview-body,
.step-detail-content {
  color: var(--text);
  line-height: 1.8;
}
.step-preview-body ul,
.step-detail-content ul {
  margin-left: 20px;
}
.experiment-detail-card,
.step-detail-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}
.experiment-detail-card-main {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.muted-picker-item {
  color: var(--text-muted);
}
.reagent-picker-button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  display: grid;
  gap: 2px;
}
.picker-meta {
  color: var(--text-muted);
  font-size: 12px;
}
.record-method-item {
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.record-method-item.is-selected {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 3px rgba(59,130,246,.08);
  background: linear-gradient(180deg, rgba(239,246,255,.8), rgba(255,255,255,1));
}
.record-variable-panel,
.record-reagent-preview {
  margin: 12px 0 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}
.record-variable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.record-variable-input {
  display: flex;
  align-items: center;
  gap: 8px;
}
.record-variable-unit {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.record-reagent-preview-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.record-reagent-preview-item {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.record-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 20px;
  align-items: start;
}
.record-editor-card {
  display: grid;
  gap: 16px;
}
.record-method-search-shell {
  display: grid;
  gap: 14px;
}
.record-method-search-results {
  display: grid;
  gap: 10px;
}
.record-method-result {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.record-method-result:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.record-method-result-main {
  min-width: 0;
}
.record-method-result-main strong {
  display: block;
  font-size: 16px;
}
.record-method-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.record-draft-shell {
  display: grid;
  gap: 16px;
}
.record-draft-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.record-summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.record-summary-bar-compact {
  margin-bottom: 14px;
}
.record-summary-chip {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}
.record-summary-chip strong {
  font-size: 20px;
  line-height: 1;
}
.record-association-panel,
.record-upload-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}
.record-association-tags,
.record-attachment-list {
  display: grid;
  gap: 10px;
}
.record-association-search {
  position: relative;
  display: grid;
  gap: 8px;
}
.record-color-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.record-color-picker input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
}
.record-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.record-section-card .builder-meta {
  margin-top: 0;
  margin-bottom: 10px;
}
.record-linked-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.record-step-prefix {
  color: var(--primary);
  font-weight: 700;
}
.record-outline-list {
  display: grid;
  gap: 10px;
}
.record-outline-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  color: inherit;
  text-decoration: none;
}
.record-outline-link:hover {
  border-color: var(--primary-border);
  background: #f8fbff;
}
.record-card-section-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.record-detail-attachment-block {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}
.record-detail-attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.record-detail-attachment-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  overflow: hidden;
}
.record-detail-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e2e8f0;
}
.record-detail-attachment-meta {
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.record-mobile-qr-card {
  min-width: 220px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}
.record-mobile-qr-image {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
}
.record-mobile-page {
  background: var(--bg);
}
.cabinet-manager-card {
  cursor: grab;
}
.cabinet-manager-card.dragging {
  opacity: 0.55;
  transform: scale(0.99);
}
.record-mobile-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
  display: grid;
  gap: 16px;
}
.experiment-detail-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.experiment-detail-sidebar {
  display: grid;
  gap: 20px;
}
.experiment-detail-compact-card {
  padding-bottom: 18px;
}
.experiment-detail-list-compact {
  gap: 10px;
}
.experiment-detail-card-compact {
  padding: 12px 14px;
}
.experiment-detail-steps-card {
  min-height: 100%;
}

@media (max-width: 480px) {
  .sidebar-header {
    padding: 0 14px;
  }
  .nav-item {
    font-size: 15px;
    padding: 11px 12px;
  }
  .sidebar-footer {
    padding-left: 12px;
    padding-right: 12px;
  }
  .page-body {
    padding: 14px calc(12px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(12px + var(--safe-left));
  }
  .card {
    padding: 14px;
  }
  .btn,
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
  }
  .page-title {
    font-size: 18px;
  }
  .experiment-name-input {
    font-size: 17px;
    min-height: 48px;
  }
  .record-method-result,
  .experiment-panel,
  .step-preview-card,
  .variable-card,
  .experiment-item-card,
  .record-attachment-item {
    padding: 12px;
  }
}

@media (max-width: 768px) {
  .experiment-hero-grid,
  .experiment-top-panels,
  .experiment-meta-row,
  .experiment-supply-grid,
  .experiment-meta-row-compact,
  .experiment-meta-row-edit {
    grid-template-columns: 1fr;
  }
  .experiment-detail-layout {
    grid-template-columns: 1fr;
  }
  .record-editor-layout {
    grid-template-columns: 1fr;
  }
  .record-mobile-qr-card {
    width: 100%;
    min-width: 0;
  }
  .record-mobile-qr-image {
    width: min(180px, 100%);
    height: auto;
  }
  .step-preview-header,
  .experiment-item-card {
    flex-direction: column;
    align-items: stretch;
  }
  .record-method-result,
  .record-draft-head {
    flex-direction: column;
    align-items: stretch;
  }
  .exp-card {
    padding: 14px;
  }
  .exp-card-header,
  .exp-card-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .exp-type-badge {
    width: auto;
    min-width: 0;
    align-self: flex-start;
  }
  .exp-card-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .exp-card-actions .btn,
  .exp-card-actions form {
    width: 100%;
  }
  .exp-card-actions form .btn {
    width: 100%;
  }
  .record-editor-card,
  .record-draft-shell,
  .record-method-search-shell {
    gap: 14px;
  }
  .record-association-panel,
  .record-upload-panel {
    padding: 12px;
  }
  .record-summary-chip strong {
    font-size: 18px;
  }
  .exp-grid,
  .record-summary-bar,
  .record-variable-grid,
  .record-detail-attachment-grid {
    grid-template-columns: 1fr;
  }
  .experiment-group-head {
    flex-direction: column;
    align-items: stretch;
  }
  .record-method-result-meta {
    justify-content: flex-start;
  }
  .record-outline-link {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .step-editor-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .step-editor-toolbar > * {
    flex-shrink: 0;
  }
  .step-editor-surface {
    min-height: 180px;
  }
  .reagent-page .search-bar {
    max-width: 100%;
  }
  .reagent-page .tabs {
    padding-bottom: 4px;
  }
  .reagent-page #reagentTable {
    min-width: 0;
  }
  .reagent-page .table-actions {
    flex-wrap: wrap;
    white-space: normal;
  }
}
