:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f1f3f6;
  --surface-hover: #eef1f5;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #181c24;
  --text-secondary: #525d6d;
  --text-muted: #8490a3;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --success: #16a34a;
  --warning: #d97706;
  --mark-bg: #fef08a;
  --mark-text: #181c24;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a22;
  --surface-muted: #1e222d;
  --surface-hover: #242936;
  --border: #282e3d;
  --border-strong: #373f52;
  --text: #eef1f6;
  --text-secondary: #a5b0c2;
  --text-muted: #6e7a8e;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.18);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --success: #4ade80;
  --warning: #fbbf24;
  --mark-bg: rgba(250, 204, 21, 0.32);
  --mark-text: #fef9c3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 60px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 58px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.icon-clear {
  position: absolute;
  right: 34px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

.icon-clear:hover {
  color: var(--text);
}

.kbd-hint {
  position: absolute;
  right: 9px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 18px;
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  color: var(--text);
  background: transparent;
}

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

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

.btn-secondary {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-icon {
  width: 34px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
}

.btn-icon:hover {
  background: var(--surface-muted);
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.text-btn:hover {
  text-decoration: underline;
}

.text-btn.danger {
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 196px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 50;
}

.dropdown-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}

.dropdown-item:hover {
  background: var(--surface-muted);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 0;
}

/* Workspace 3-column layout */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Left Sidebar */
.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.section-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 8px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item .count {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface-muted);
  padding: 1px 7px;
  border-radius: 999px;
}

.nav-item.active .count {
  background: var(--primary);
  color: #fff;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}

.tag-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tag-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tag-pill .tag-count {
  opacity: 0.7;
  font-size: 11px;
}

/* Main Panel */
.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 22px;
  overflow-y: auto;
  gap: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.result-summary {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
}

.filter-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.select-input {
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

.random-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
}

.random-banner-actions {
  display: flex;
  gap: 8px;
}

/* Cards */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 32px;
}

.snippet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.snippet-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.snippet-card.pinned {
  border-left: 3px solid var(--warning);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.pin-badge {
  font-size: 11.5px;
  color: var(--warning);
  font-weight: 600;
}

.card-time {
  font-size: 11.5px;
  color: var(--text-muted);
}

.card-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.card-content mark,
.card-note mark,
.card-source mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 3px;
  padding: 0 2px;
}

.card-note {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border-left: 3px solid var(--border-strong);
  padding: 8px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: pre-wrap;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-tag {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-muted);
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.card-tag:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.card-source {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-source a {
  color: var(--primary);
  text-decoration: none;
}

.card-source a:hover {
  text-decoration: underline;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.use-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.use-counter strong {
  color: var(--text);
}

.counter-step {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
  border-radius: 4px;
  width: 20px;
  height: 20px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.counter-step:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

.action-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.action-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border-strong);
}

.action-btn.copy-btn {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
  font-weight: 600;
}

.action-btn.copy-btn:hover {
  background: var(--primary);
  color: #fff;
}

.action-btn.in-basket {
  border-color: var(--success);
  color: var(--success);
}

.action-btn.delete-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* Right Staging Basket Drawer */
.basket-drawer {
  width: 310px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.basket-drawer.collapsed {
  width: 0;
  border-left: none;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

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

.basket-title {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 14px;
}

.basket-sub {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.basket-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.basket-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-basket {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 16px;
  line-height: 1.7;
}

.basket-item {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.basket-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.basket-item-text {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.basket-item-note {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.basket-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text-secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 15.5px;
}

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.required {
  color: var(--danger);
}

.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  resize: vertical;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

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

/* Category Quick Pills */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
}

.category-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.category-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Tag Autocomplete */
.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.tag-suggestion-item {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  cursor: pointer;
}

.tag-suggestion-item:hover {
  background: var(--primary);
  color: #fff;
}

/* Toast */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: #181c24;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.18s ease;
}

[data-theme="dark"] .toast {
  background: #2b3142;
  border: 1px solid var(--border-strong);
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

/* Image Upload Dropzone & Preview */
.image-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 10px 12px;
  transition: border-color 0.15s, background 0.15s;
}

.image-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-prompt {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  padding: 6px 4px;
  user-select: none;
}

.dropzone-prompt:hover {
  color: var(--primary);
}

.upload-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.upload-thumb {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.upload-thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 17, 23, 0.78);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.upload-thumb-remove:hover {
  background: var(--danger);
}

/* Card Image Grid */
.card-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.card-images.single {
  display: flex;
}

.card-image-tile {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  max-height: 240px;
  cursor: zoom-in;
}

.card-images:not(.single) .card-image-tile {
  height: 148px;
}

.card-image-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.18s ease;
}

.card-images.single .card-image-tile img {
  width: auto;
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.card-image-tile:hover img {
  transform: scale(1.02);
}

.card-image-copy-mini {
  position: absolute;
  right: 6px;
  bottom: 6px;
  border: none;
  border-radius: 6px;
  background: rgba(15, 17, 23, 0.76);
  color: #fff;
  font-size: 11px;
  padding: 3px 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.card-image-tile:hover .card-image-copy-mini {
  opacity: 1;
}

.card-image-copy-mini:hover {
  background: var(--primary);
}

/* Lightbox */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.84);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
}

.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 92vw;
  max-height: 92vh;
}

.lightbox-inner img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
  background: #11131a;
  object-fit: contain;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive & Mobile / PWA Additions */
.badge-warn {
  background: var(--warning);
}

.offline-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(217, 119, 6, 0.14);
  border-bottom: 1px solid rgba(217, 119, 6, 0.35);
  color: var(--warning);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.offline-status-bar.online-pending {
  background: var(--primary-soft);
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.offline-status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-card-sm {
  max-width: 420px;
}

.modal-card-lg {
  max-width: 660px;
}

.setup-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.setup-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-field-row input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.code-snippet-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 12px !important;
  line-height: 1.5;
  white-space: pre;
}

.auth-error {
  color: var(--danger);
  font-size: 12.5px;
  background: var(--danger-soft);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}

.offline-modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.offline-queue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
}

.offline-queue-item {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.offline-queue-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.offline-queue-item-text {
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.offline-queue-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.offline-queue-thumbs img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.mobile-drawer-header,
.mobile-bottom-bar,
.mobile-drawer-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .sidebar {
    width: 200px;
  }
  .basket-drawer {
    position: fixed;
    right: 0;
    top: 60px;
    bottom: 0;
    z-index: 40;
    box-shadow: var(--shadow-md);
  }
}

@media (max-width: 768px) {
  .desktop-only-inline {
    display: none !important;
  }

  .topbar {
    height: auto;
    min-height: 54px;
    padding: 8px 12px;
    gap: 8px;
  }

  .brand-name {
    display: none;
  }

  .topbar-left {
    gap: 8px;
  }

  .search-box {
    max-width: none;
  }

  .kbd-hint {
    display: none;
  }

  .search-box input {
    padding-right: 32px;
    font-size: 14px;
  }

  .icon-clear {
    right: 8px;
  }

  .main-panel {
    padding: 12px 12px 80px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 270px;
    max-width: 82vw;
    z-index: 80;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14.5px;
  }

  .basket-drawer {
    top: 0;
    bottom: 0;
    width: 310px;
    max-width: 86vw;
    z-index: 80;
  }

  .mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.5);
    z-index: 70;
  }

  .mobile-bottom-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 60;
  }

  .mobile-nav-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    cursor: pointer;
    position: relative;
  }

  .mobile-nav-btn.primary {
    color: var(--primary);
    font-weight: 600;
  }

  .mobile-nav-icon {
    font-size: 16px;
    line-height: 1.1;
  }

  .mobile-badge {
    font-style: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    margin-left: 2px;
  }

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

  .toast-container {
    bottom: 72px;
    right: 12px;
    left: 12px;
  }
}
