/**
 * MuuurderBoard Mobile Styles
 * Responsive design with accordion list view and slide panels
 * Minimum supported width: 420px
 */

/* ==========================================================================
   CSS Variables (inherited from common.css, with mobile-specific additions)
   ========================================================================== */
:root {
  --mobile-header-height: 56px;
  --panel-transition: transform 0.3s ease;
  --left-panel-width: min(85vw, 320px);
  --right-panel-width: 280px;
  --touch-target: 44px;
}

/* ==========================================================================
   Mobile Visibility Utilities
   ========================================================================== */
.mobile-only {
  display: none !important;
}

.desktop-only {
  display: block;
}

/* ==========================================================================
   Mobile Header
   ========================================================================== */
.mobile-header {
  display: none;
  height: var(--mobile-header-height);
  background: linear-gradient(180deg, #111 0%, var(--bg) 100%);
  border-bottom: 1px solid #222;
  padding: 0 12px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.mobile-header-left,
.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.mobile-logo {
  font-family: 'Georgia', serif;
  font-size: 16px;
  color: #f8f8f8;
  letter-spacing: -0.5px;
}

.mobile-logo i {
  font-style: italic;
  color: var(--accent);
}

/* Mobile header buttons */
.mobile-header-btn {
  width: var(--touch-target);
  height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #c6c6d0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mobile-header-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.mobile-header-btn:active {
  transform: scale(0.95);
}

.mobile-header-btn svg {
  width: 22px;
  height: 22px;
}

/* View toggle button */
.view-toggle-btn {
  font-size: 18px;
}

.view-toggle-btn.list-active::after {
  content: '';
}

/* ==========================================================================
   Panel Backdrop
   ========================================================================== */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 99;
}

.panel-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Left Panel (Edit Sidebar)
   ========================================================================== */
.panel-left {
  position: fixed;
  top: var(--mobile-header-height);
  left: 0;
  bottom: 0;
  width: var(--left-panel-width);
  background: var(--panel);
  border-right: 1px solid var(--node-border);
  transform: translateX(-100%);
  transition: var(--panel-transition);
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.panel-left.open {
  transform: translateX(0);
}

/* Panel close button */
.panel-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  color: #9ca3af;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}

.panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ==========================================================================
   Right Panel (Menu)
   ========================================================================== */
.panel-right {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--right-panel-width);
  background: var(--panel);
  border-left: 1px solid var(--node-border);
  transform: translateX(100%);
  transition: var(--panel-transition);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-right.open {
  transform: translateX(0);
}

/* Right panel header */
.panel-right-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--node-border);
}

.panel-right-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #f8f8f8;
  margin: 0;
}

/* Menu sections */
.menu-section {
  padding: 16px;
  border-bottom: 1px solid var(--node-border);
}

.menu-section:last-child {
  border-bottom: none;
}

.menu-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 12px;
}

/* Menu items */
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c6c6d0;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--node-border);
  color: #fff;
}

.menu-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.menu-item.danger {
  color: var(--accent);
}

.menu-item.danger:hover {
  background: rgba(225, 29, 72, 0.1);
  border-color: rgba(225, 29, 72, 0.3);
}

/* Mode toggle in menu */
.menu-mode-toggle {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.menu-mode-option {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.menu-mode-option.active {
  background: rgba(34, 211, 238, 0.1);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.menu-mode-option:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* Template select in menu */
.menu-template-select {
  width: 100%;
  margin-bottom: 8px;
}

.menu-btn-row {
  display: flex;
  gap: 8px;
}

.menu-btn-row .btn {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
}

/* ==========================================================================
   Accordion Card List
   ========================================================================== */
.card-list-container {
  display: none;
  padding: 8px;
  padding-bottom: 80px; /* Space for FAB */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  grid-area: board; /* Occupy same grid cell as board */
}

.card-list-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.card-list-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.card-list-empty p {
  font-size: 16px;
  margin-bottom: 8px;
}

.card-list-empty span {
  font-size: 13px;
  color: #6b7280;
}

/* Card item */
.card-item {
  background: var(--panel);
  border: 1px solid var(--node-border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.card-item:hover {
  border-color: #3f3f46;
}

.card-item.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2);
}

/* Card connected to selected link */
.card-item.link-connected {
  border-color: var(--accent-2);
  background: rgba(34, 211, 238, 0.05);
  box-shadow: 0 0 0 1px var(--accent-2), inset 0 0 20px rgba(34, 211, 238, 0.03);
}

/* Card item header */
.card-item-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  cursor: pointer;
  min-height: var(--touch-target);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.card-item-header:active {
  background: rgba(255, 255, 255, 0.03);
}

/* Type indicator dot */
.card-item-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Card info */
.card-item-info {
  flex: 1;
  min-width: 0;
}

.card-item-title {
  font-size: 15px;
  font-weight: 500;
  color: #f8f8f8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.card-item-meta {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-item-meta-sep::before {
  content: '\00b7';
  margin: 0 4px;
}

/* Expand chevron */
.card-item-chevron {
  width: 20px;
  height: 20px;
  color: #6b7280;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.card-item.expanded .card-item-chevron {
  transform: rotate(90deg);
}

/* Card item body (expandable) */
.card-item-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.card-item.expanded .card-item-body {
  max-height: none;
  overflow: visible;
}

.card-item-content {
  padding: 0 16px 16px;
  border-top: 1px solid var(--node-border);
}

/* Card description */
.card-item-desc {
  font-size: 13px;
  color: #9ca3af;
  line-height: 1.5;
  padding: 12px 0;
}

/* Card attribute tags */
.card-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}

.card-attr-tag {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 12px;
  font-size: 12px;
  color: #a78bfa;
  font-weight: 500;
}

/* Card conditions section */
.card-item-conditions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--node-border);
}

.card-item-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #60a5fa;
  margin-bottom: 10px;
}

/* Mobile condition item */
.mobile-condition-item {
  background: rgba(96, 165, 250, 0.05);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.mobile-condition-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.mobile-condition-arrow {
  color: #60a5fa;
  font-weight: bold;
}

.mobile-condition-target {
  font-weight: 500;
  color: #e5e7eb;
  flex: 1;
}

.mobile-condition-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(96, 165, 250, 0.2);
  border-radius: 10px;
  color: #60a5fa;
}

/* Condition rules */
.mobile-condition-rules {
  font-size: 12px;
  color: #9ca3af;
}

.mobile-condition-rules.empty {
  font-style: italic;
  color: #6b7280;
}

.mobile-condition-block {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
}

.mobile-block-logic,
.mobile-rule-logic {
  display: block;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #a78bfa;
  padding: 4px 0;
}

.mobile-rule {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 2px 0;
}

.mobile-rule-field {
  color: #fbbf24;
  font-family: monospace;
  font-size: 11px;
}

.mobile-rule-op {
  color: #60a5fa;
  font-size: 11px;
}

.mobile-rule-value {
  color: #34d399;
  font-family: monospace;
  font-size: 11px;
}

/* Accordion sections */
.card-item-accordion {
  margin-top: 12px;
  border: 1px solid var(--node-border);
  border-radius: 8px;
  overflow: hidden;
}

.card-item-accordion-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.card-item-accordion-header:active {
  background: rgba(255, 255, 255, 0.05);
}

.card-item-accordion-header .card-item-section-title {
  flex: 1;
  margin: 0;
}

.accordion-count {
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #9ca3af;
  margin-right: 8px;
}

.accordion-chevron {
  width: 16px;
  height: 16px;
  color: #6b7280;
  transition: transform 0.2s ease;
  transform: rotate(-90deg);
}

.card-item-accordion.expanded .accordion-chevron {
  transform: rotate(0deg);
}

.card-item-accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.card-item-accordion.expanded .card-item-accordion-content {
  max-height: 2000px;
}

/* Mobile Condition Editor Modal */
.mobile-condition-modal .mobile-condition-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
}

.mobile-condition-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--node-border);
  background: var(--bg-primary);
}

.mobile-condition-editor-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #f8f8f8;
}

.mobile-condition-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 24px;
  cursor: pointer;
  border-radius: 6px;
}

.mobile-condition-close:active {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-condition-editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.mobile-condition-editor-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--node-border);
  background: var(--bg-primary);
}

.mobile-condition-editor-footer .btn {
  flex: 1;
}

.mobile-condition-editor-footer .btn.danger {
  background: #8b0000;
  color: #fff;
}

/* Block Logic Toggle */
.mobile-block-logic-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(96, 165, 250, 0.1);
  border-radius: 8px;
  margin-bottom: 16px;
}

.mobile-block-logic-label {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 600;
}

/* Edit Block */
.mobile-edit-block {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--node-border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.mobile-edit-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--node-border);
}

.mobile-edit-block-title {
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
}

.mobile-edit-block-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-edit-block-content {
  padding: 12px;
}

/* Edit Rule */
.mobile-edit-rule {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.mobile-edit-rule-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.mobile-edit-rule-row:last-child {
  margin-bottom: 0;
}

.mobile-edit-select {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--node-border);
  border-radius: 6px;
  color: #f8f8f8;
  font-size: 13px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.mobile-edit-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--node-border);
  border-radius: 6px;
  color: #f8f8f8;
  font-size: 13px;
}

.mobile-edit-rule-delete {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 0, 0, 0.3);
  border: 1px solid rgba(139, 0, 0, 0.5);
  border-radius: 6px;
  color: #ff6b6b;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-edit-rule-delete:active {
  background: rgba(139, 0, 0, 0.5);
}

/* Rule Logic Indicator */
.mobile-rule-logic-indicator {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #60a5fa;
  padding: 4px 0;
}

/* Block Logic Indicator (between blocks) */
.mobile-block-logic-indicator {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #a78bfa;
  padding: 8px 0;
}

/* Add buttons */
.mobile-add-rule-btn,
.mobile-add-block-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--node-border);
  border-radius: 6px;
  color: #60a5fa;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
}

.mobile-add-rule-btn:active,
.mobile-add-block-btn:active {
  background: rgba(96, 165, 250, 0.1);
}

.mobile-add-block-btn {
  margin-top: 16px;
  border-color: #60a5fa;
}

/* Delete Block Button */
.mobile-delete-block-btn {
  padding: 6px 10px;
  background: rgba(139, 0, 0, 0.3);
  border: 1px solid rgba(139, 0, 0, 0.5);
  border-radius: 4px;
  color: #ff6b6b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* Condition Edit Icon */
.mobile-condition-edit {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 6px;
  color: #60a5fa;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}

.mobile-condition-edit svg {
  width: 14px;
  height: 14px;
}

.mobile-condition-edit:active {
  background: rgba(96, 165, 250, 0.2);
}

/* Links sections */
.card-item-links-section {
  margin-top: 12px;
}

.card-item-links-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-item-links-title::before {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--node-border);
}

.card-item-links-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--node-border);
}

/* Link item */
.card-link-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.card-link-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #3f3f46;
}

.card-link-item:active {
  background: rgba(255, 255, 255, 0.07);
}

.card-link-item.selected {
  border-color: var(--accent-2);
  background: rgba(34, 211, 238, 0.05);
}

/* Link direction arrow */
.card-link-direction {
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  min-width: 24px;
  text-align: center;
  text-shadow: 0 0 8px currentColor;
}

/* Link target indicator */
.card-link-target-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

/* Link info */
.card-link-info {
  flex: 1;
  min-width: 0;
}

.card-link-target {
  font-size: 14px;
  font-weight: 500;
  color: #e5e5e5;
  margin-bottom: 4px;
}

.card-link-label {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
}

.card-link-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* Link type badge */
.link-type-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  opacity: 0.9;
}

/* Link options button */
.card-link-options {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.card-link-options:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Link edit button */
.card-link-edit {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 6px;
  color: #60a5fa;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}

.card-link-edit svg {
  width: 14px;
  height: 14px;
}

.card-link-edit:active {
  background: rgba(96, 165, 250, 0.2);
}

/* ==========================================================================
   Mobile Link Editor Modal
   ========================================================================== */
.mobile-link-modal .mobile-link-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  background: var(--node-bg);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.mobile-link-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--node-border);
  background: rgba(0, 0, 0, 0.2);
}

.mobile-link-editor-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.mobile-link-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 24px;
  cursor: pointer;
}

.mobile-link-close:active {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-link-editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.mobile-link-editor-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--node-border);
  background: rgba(0, 0, 0, 0.2);
}

.mobile-link-editor-footer .btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
}

/* Link editor form sections */
.mobile-link-section {
  margin-bottom: 20px;
}

.mobile-link-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 10px;
}

.mobile-link-label-input {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

.mobile-link-label-input:focus {
  outline: none;
  border-color: #60a5fa;
}

.mobile-link-label-input::placeholder {
  color: #6b7280;
}

/* Target card section (for changing link target) */
.mobile-link-target-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--node-border);
  border-radius: 8px;
}

.mobile-link-target-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mobile-link-target-name {
  flex: 1;
  font-size: 14px;
  color: #e5e5e5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-link-change-btn {
  padding: 6px 12px;
  background: rgba(96, 165, 250, 0.2);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 6px;
  color: #60a5fa;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-link-change-btn:active {
  background: rgba(96, 165, 250, 0.3);
}

/* Link type checkboxes */
.mobile-link-type-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-link-type-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-link-type-item:active {
  background: rgba(0, 0, 0, 0.4);
}

.mobile-link-type-item.selected {
  border-color: var(--link-type-color, #60a5fa);
  background: rgba(96, 165, 250, 0.1);
}

.mobile-link-type-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--node-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-link-type-item.selected .mobile-link-type-checkbox {
  background: var(--link-type-color, #60a5fa);
  border-color: var(--link-type-color, #60a5fa);
}

.mobile-link-type-checkbox svg {
  width: 12px;
  height: 12px;
  color: #fff;
  opacity: 0;
}

.mobile-link-type-item.selected .mobile-link-type-checkbox svg {
  opacity: 1;
}

.mobile-link-type-label {
  flex: 1;
  font-size: 14px;
  color: #e5e5e5;
}

.mobile-link-type-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Input values editor */
.mobile-input-values-section {
  margin-top: 16px;
  padding: 16px;
  background: rgba(125, 211, 252, 0.1);
  border: 1px solid rgba(125, 211, 252, 0.3);
  border-radius: 8px;
}

.mobile-input-values-title {
  font-size: 12px;
  font-weight: 600;
  color: #7dd3fc;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-input-value-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.mobile-input-key,
.mobile-input-value-field {
  flex: 1;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--node-border);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
}

.mobile-input-key {
  max-width: 120px;
}

.mobile-input-key:focus,
.mobile-input-value-field:focus {
  outline: none;
  border-color: #7dd3fc;
}

.mobile-input-key::placeholder,
.mobile-input-value-field::placeholder {
  color: #6b7280;
}

.mobile-input-delete {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  color: #ef4444;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-input-delete:active {
  background: rgba(239, 68, 68, 0.2);
}

.mobile-add-input-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px dashed rgba(125, 211, 252, 0.5);
  border-radius: 6px;
  color: #7dd3fc;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}

.mobile-add-input-btn:active {
  background: rgba(125, 211, 252, 0.1);
}

/* Card item actions */
.card-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--node-border);
}

.card-item-actions .btn {
  flex: 1;
  font-size: 13px;
  padding: 10px 12px;
}

/* Card item edit button */
.card-item-edit-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 6px;
  color: #60a5fa;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
}

.card-item-edit-btn svg {
  width: 16px;
  height: 16px;
}

.card-item-edit-btn:active {
  background: rgba(96, 165, 250, 0.2);
}

/* Card item thumbnail (circular preview) */
.card-item-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  margin-right: 10px;
}

.card-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Card item image button */
.card-item-image-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
  position: relative;
}

.card-item-image-btn svg {
  width: 16px;
  height: 16px;
}

.card-item-image-btn.has-images {
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.card-item-image-btn:active {
  background: rgba(59, 130, 246, 0.2);
}

.card-item-image-btn .image-count-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #22c55e;
  color: white;
  font-size: 10px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ==========================================================================
   Mobile Card Editor Modal
   ========================================================================== */
.mobile-card-modal .mobile-card-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  background: var(--node-bg);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.mobile-card-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--node-border);
  background: rgba(0, 0, 0, 0.2);
}

.mobile-card-editor-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-card-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 24px;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-card-close:active {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-card-editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.mobile-card-editor-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--node-border);
  background: rgba(0, 0, 0, 0.2);
}

.mobile-card-editor-footer .btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
}

/* Card editor sections */
.mobile-card-section {
  margin-bottom: 20px;
}

.mobile-card-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 10px;
}

.mobile-card-input {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
}

.mobile-card-input:focus {
  outline: none;
  border-color: #60a5fa;
}

.mobile-card-input::placeholder {
  color: #6b7280;
}

.mobile-card-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}

.mobile-card-textarea:focus {
  outline: none;
  border-color: #60a5fa;
}

.mobile-card-textarea::placeholder {
  color: #6b7280;
}

/* Card type selector (single-select) */
.mobile-card-type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-card-type-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-card-type-item:active {
  background: rgba(0, 0, 0, 0.4);
}

.mobile-card-type-item.selected {
  border-color: var(--type-color, #60a5fa);
  background: rgba(96, 165, 250, 0.1);
}

.mobile-card-type-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mobile-card-type-item span {
  font-size: 13px;
  color: #e5e5e5;
}

/* Card attribute selector (multi-select) */
.mobile-card-attr-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-card-attr-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-card-attr-item:active {
  background: rgba(0, 0, 0, 0.4);
}

.mobile-card-attr-item.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.mobile-card-attr-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--node-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-card-attr-item.selected .mobile-card-attr-checkbox {
  background: #10b981;
  border-color: #10b981;
}

.mobile-card-attr-checkbox svg {
  width: 12px;
  height: 12px;
  color: #fff;
  opacity: 0;
}

.mobile-card-attr-item.selected .mobile-card-attr-checkbox svg {
  opacity: 1;
}

.mobile-card-attr-item span {
  font-size: 13px;
  color: #e5e5e5;
}

.mobile-card-attr-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ==========================================================================
   Mobile Chain Feature
   ========================================================================== */

/* Chain icon button in card header */
.card-chain-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #64748b;
  transition: all 0.15s;
}

.card-chain-btn:hover,
.card-chain-btn:active {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

.card-chain-btn.chained {
  color: #a855f7;
  background: rgba(168, 85, 247, 0.15);
}

.card-chain-btn.chained:hover,
.card-chain-btn.chained:active {
  background: rgba(168, 85, 247, 0.25);
}

.card-chain-btn svg {
  width: 18px;
  height: 18px;
}

.chain-direction {
  font-size: 10px;
  font-weight: 600;
  margin-left: 2px;
}

/* Chain status banner */
.chain-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  margin: 0 12px 12px 12px;
}

.chain-status-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 500;
}

.chain-status-info svg {
  width: 16px;
  height: 16px;
  color: #a855f7;
}

.chain-clear-btn {
  padding: 6px 12px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 6px;
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.chain-clear-btn:hover,
.chain-clear-btn:active {
  background: rgba(168, 85, 247, 0.3);
  border-color: rgba(168, 85, 247, 0.6);
}

/* Mobile chain modal */
.mobile-chain-modal {
  z-index: 1001;
}

.mobile-chain-modal.active {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mobile-chain-editor {
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpModal 0.25s ease-out;
}

@keyframes slideUpModal {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.mobile-chain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--node-border);
  flex-shrink: 0;
}

.mobile-chain-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #f5f5f5;
}

.mobile-chain-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.15s;
}

.mobile-chain-close:hover,
.mobile-chain-close:active {
  background: rgba(255, 255, 255, 0.1);
  color: #e5e5e5;
}

.mobile-chain-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  -webkit-overflow-scrolling: touch;
}

/* Chain option buttons */
.chain-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chain-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--node-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.chain-option:hover,
.chain-option:active {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.3);
}

.chain-option.selected {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.5);
}

.chain-option-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.2);
  border-radius: 10px;
  color: #a855f7;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.chain-option-text {
  flex: 1;
}

.chain-option-title {
  font-size: 14px;
  font-weight: 600;
  color: #f5f5f5;
  margin-bottom: 2px;
}

.chain-option-desc {
  font-size: 12px;
  color: #9ca3af;
}

/* Chain current status */
.chain-current-status {
  padding: 16px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  margin-bottom: 16px;
}

.chain-current-direction {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #c4b5fd;
  margin-bottom: 4px;
}

.chain-current-count {
  font-size: 12px;
  color: #9ca3af;
}

/* Chain action buttons */
.chain-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.chain-actions .btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
}

/* Card in chain path indicator */
.card-item.is-chain-root {
  border-left: 3px solid #a855f7;
}

.card-item.in-chain-path {
  border-left: 3px solid rgba(168, 85, 247, 0.5);
  background: rgba(168, 85, 247, 0.05);
}

/* ==========================================================================
   Floating Action Button (FAB)
   ========================================================================== */
.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(225, 29, 72, 0.5), 0 3px 6px rgba(0, 0, 0, 0.3);
}

.fab:active {
  transform: scale(0.95);
}

.fab svg {
  width: 24px;
  height: 24px;
}

/* ==========================================================================
   Link Target Picker Modal
   ========================================================================== */
.link-picker-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
}

.link-picker-modal.open {
  display: flex;
}

.link-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.link-picker-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.link-picker-modal.open .link-picker-content {
  transform: translateY(0);
}

.link-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--node-border);
}

.link-picker-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #f8f8f8;
  margin: 0;
}

.link-picker-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--node-border);
}

.link-picker-search input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  color: #f8f8f8;
  font-size: 14px;
}

.link-picker-search input::placeholder {
  color: #6b7280;
}

.link-picker-list {
  max-height: calc(70vh - 130px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.link-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--node-border);
  cursor: pointer;
  transition: background 0.15s;
}

.link-picker-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.link-picker-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.link-picker-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.link-picker-item-title {
  font-size: 14px;
  color: #f8f8f8;
}

.link-picker-item-type {
  font-size: 12px;
  color: #6b7280;
  margin-left: auto;
}

/* ==========================================================================
   Touch Feedback Utilities
   ========================================================================== */
.touch-feedback {
  -webkit-tap-highlight-color: transparent;
}

.touch-feedback:active {
  opacity: 0.7;
}

/* ==========================================================================
   Mobile Media Queries
   ========================================================================== */

/* Tablet and below (768px) */
@media (max-width: 768px) {
  /* Show mobile elements */
  .mobile-only {
    display: block !important;
  }

  .desktop-only {
    display: none !important;
  }

  /* Show mobile header */
  .mobile-header {
    display: flex;
  }

  /* Hide desktop topbar and convert sidebar */
  .topbar {
    display: none !important;
  }

  /* Convert sidebar to slide panel */
  .sidebar {
    position: fixed;
    top: var(--mobile-header-height);
    left: 0;
    bottom: 0;
    width: var(--left-panel-width);
    transform: translateX(-100%);
    transition: var(--panel-transition);
    z-index: 100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Adjust app grid layout */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--mobile-header-height) 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  /* Main board adjustments */
  .board {
    grid-area: main;
    height: calc(100vh - var(--mobile-header-height));
    height: calc(100dvh - var(--mobile-header-height));
  }

  /* Show card list when in list view */
  body.list-view .card-list-container {
    display: block;
    grid-area: main; /* Mobile grid uses 'main' not 'board' */
  }

  body.list-view .board {
    display: none;
  }

  /* Show FAB in list view */
  body.list-view .fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hints adjustment */
  .hint {
    display: none;
  }

  /* Modal adjustments */
  .modal-content {
    width: 95%;
    max-width: none;
    max-height: 85vh;
    margin: auto 2.5%;
  }

  /* Link popup as bottom sheet */
  .link-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: translateY(100%);
    border-radius: 16px 16px 0 0;
    max-width: none;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .link-popup.visible {
    transform: translateY(0);
  }
}

/* Mobile (480px) */
@media (max-width: 480px) {
  /* Smaller logo */
  .mobile-logo {
    font-size: 15px;
  }

  /* Tighter spacing */
  .card-list-container {
    padding: 6px;
  }

  .card-item-header {
    padding: 12px 14px;
  }

  .card-item-content {
    padding: 0 14px 14px;
  }

  /* Menu adjustments */
  .panel-right {
    width: 100%;
  }

  /* FAB position */
  .fab {
    bottom: 20px;
    right: 20px;
  }
}

/* Small Mobile - Minimum supported (420px) */
@media (max-width: 420px) {
  /* Even tighter header */
  .mobile-header {
    padding: 0 8px;
  }

  .mobile-header-btn {
    width: 40px;
    height: 40px;
  }

  .mobile-logo {
    font-size: 14px;
  }

  /* Compact cards */
  .card-item-header {
    padding: 10px 12px;
    gap: 10px;
  }

  .card-item-title {
    font-size: 14px;
  }

  .card-item-meta {
    font-size: 11px;
  }

  /* Compact links */
  .card-link-item {
    padding: 8px 10px;
  }

  .card-link-target {
    font-size: 13px;
  }

  /* FAB smaller */
  .fab {
    width: 52px;
    height: 52px;
    bottom: 16px;
    right: 16px;
  }

  .fab svg {
    width: 22px;
    height: 22px;
  }
}

/* ==========================================================================
   Safe Area Insets (for notched devices)
   ========================================================================== */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-header {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
  }

  .panel-left,
  .sidebar.open {
    top: calc(var(--mobile-header-height) + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
  }

  .card-list-container {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .fab {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }

  @media (max-width: 420px) {
    .fab {
      bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }
}

/* ==========================================================================
   Landscape Orientation Adjustments
   ========================================================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-header {
    height: 48px;
  }

  .panel-left,
  .sidebar {
    top: 48px;
  }

  .board {
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
  }

  .card-list-container {
    padding-bottom: 70px;
  }

  .fab {
    width: 48px;
    height: 48px;
    bottom: 12px;
    right: 12px;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .panel-left,
  .panel-right,
  .sidebar,
  .panel-backdrop,
  .card-item-body,
  .card-item-chevron,
  .link-picker-content,
  .fab {
    transition: none;
  }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */
@media (prefers-contrast: high) {
  .card-item {
    border-width: 2px;
  }

  .card-item.selected {
    box-shadow: 0 0 0 2px var(--accent-2);
  }

  .card-link-item {
    border-width: 2px;
  }
}

/* ==========================================================================
   Will-change for Performance
   ========================================================================== */
.panel-left,
.panel-right,
.sidebar,
.link-picker-content {
  will-change: transform;
}

.panel-backdrop {
  will-change: opacity;
}

/* ==========================================================================
   Mobile Create Link Button
   ========================================================================== */
#mobileLinkCreateBtn {
  display: none;
}

@media (max-width: 768px) {
  #mobileLinkCreateBtn {
    display: inline-block;
  }
}

/* ==========================================================================
   Additional Mobile Refinements
   ========================================================================== */

/* Ensure proper z-index stacking */
@media (max-width: 768px) {
  /* Modal backgrounds should be above panels */
  .modal {
    z-index: 250;
  }

  /* Toast should be above everything */
  .toast {
    z-index: 500;
    bottom: 80px; /* Above FAB */
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
  }

  /* Board picker adjustments */
  .board-picker-list {
    max-height: 50vh;
  }

  /* Board action buttons for mobile */
  .board-picker-actions {
    flex-wrap: wrap;
  }

  .board-action-btn {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .board-action-btn.primary {
    flex: 1;
    justify-content: center;
  }

  /* Profile dropdown - hide on mobile (use menu instead) */
  .profile-container {
    display: none;
  }

  /* Input fields touch improvements */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="datetime-local"],
  textarea,
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: var(--touch-target);
  }

  /* Buttons touch improvements */
  .btn {
    min-height: var(--touch-target);
    padding: 10px 16px;
  }

  /* Tags - match legend chip styling */
  .tag {
    padding: 5px 10px;
    font-size: 12px;
  }

  /* Section headers in sidebar */
  .sidebar .section h3 {
    padding: 12px 0;
  }

  /* Sidebar close area for swipe hint */
  .sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.1));
    pointer-events: none;
  }
}

/* Card item improvements for small screens */
@media (max-width: 480px) {
  .card-item-actions {
    flex-direction: column;
  }

  .card-item-actions .btn {
    width: 100%;
  }
}

/* Landscape improvements */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
  .link-picker-content {
    max-height: 90vh;
  }

  .card-list-container {
    padding-bottom: 60px;
  }

  .modal-content {
    max-height: 95vh;
  }
}

/* Dark mode scrollbar styling for panels */
@media (max-width: 768px) {
  .sidebar::-webkit-scrollbar,
  .panel-right::-webkit-scrollbar,
  .card-list-container::-webkit-scrollbar {
    width: 4px;
  }

  .sidebar::-webkit-scrollbar-track,
  .panel-right::-webkit-scrollbar-track,
  .card-list-container::-webkit-scrollbar-track {
    background: transparent;
  }

  .sidebar::-webkit-scrollbar-thumb,
  .panel-right::-webkit-scrollbar-thumb,
  .card-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
  }
}

/* Fix for iOS rubber-banding on panels */
@supports (-webkit-touch-callout: none) {
  .sidebar,
  .panel-right {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* ===== Image Modal - Mobile Responsive ===== */
@media (max-width: 768px) {
  .image-modal-content {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
  }

  .image-modal-header {
    padding: 12px 16px;
  }

  .image-modal-header h3 {
    font-size: 14px;
  }

  .image-viewer {
    padding: 12px;
  }

  .image-nav {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }

  .image-nav.prev {
    left: 8px;
  }

  .image-nav.next {
    right: 8px;
  }

  .image-thumbnails {
    padding: 10px 16px;
    gap: 6px;
    min-height: 72px;
  }

  .image-thumb {
    width: 50px;
    height: 50px;
  }

  .image-upload-area {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 10px;
  }

  .image-upload-area .btn {
    width: 100%;
    justify-content: center;
  }

  .upload-hint {
    text-align: center;
  }

  .image-actions {
    padding: 12px 16px;
  }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
  .image-nav {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .image-thumb {
    width: 44px;
    height: 44px;
  }

  .image-empty {
    padding: 24px;
  }

  .image-empty .empty-icon {
    font-size: 36px;
  }
}
