/* ============================================
   DESK.CSS
   Homepage desk interface styles
   ============================================ */

/* --------------------------------------------
   Desk Layout
   -------------------------------------------- */
body.desk-page {
  overflow: hidden;
  height: 100vh;
}

.desk-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 50;
  pointer-events: none;
}

.desk-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.desk-brand {
  pointer-events: auto;
}

.desk-brand-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.desk-brand-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.desk-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

/* --------------------------------------------
   Desk Canvas
   -------------------------------------------- */
.desk {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding-top: 56px;
}

.desk-status {
  position: absolute;
  bottom: 24px;
  left: 24px;
  font-size: 11px;
  color: var(--faint);
  z-index: 5;
  max-width: 300px;
}

.desk-status a {
  color: inherit;
  text-decoration: none;
}

.desk-status a:hover {
  color: var(--muted);
}

/* --------------------------------------------
   Desk Device (laptop/desktop centerpiece)
   -------------------------------------------- */
.desk-device {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.desk-device.visible {
  opacity: 1;
}

.desk-device.interactive {
  pointer-events: auto;
  cursor: pointer;
}

/* MacBook style */
.device-macbook {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.macbook-screen {
  width: 380px;
  height: 240px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px 12px 0 0;
  box-shadow: 
    inset 0 0 0 8px var(--bg),
    inset 0 0 0 9px var(--hair),
    var(--surface-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.macbook-screen::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  background: var(--hair);
  border-radius: 50%;
}

.macbook-screen-content {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  line-height: 1.6;
}

.macbook-screen-content .screen-greeting {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

.macbook-screen-content .screen-shortcut {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.macbook-screen-content .screen-status {
  font-size: 11px;
  color: var(--faint);
  max-width: 280px;
  margin: 0 auto;
}

.macbook-base {
  width: 420px;
  height: 14px;
  background: linear-gradient(to bottom, var(--surface) 0%, var(--bg) 100%);
  border: 1px solid var(--surface-border);
  border-top: none;
  border-radius: 0 0 4px 4px;
  position: relative;
}

.macbook-base::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: var(--hair);
  border-radius: 0 0 4px 4px;
}

.macbook-keyboard {
  width: 380px;
  height: 8px;
  margin-top: 2px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 2px;
  opacity: 0.6;
}

/* Windows/PC style - monitor + keyboard */
.device-windows {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.windows-monitor {
  width: 400px;
  height: 250px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  box-shadow: 
    inset 0 0 0 12px #1a1a1a,
    inset 0 0 0 13px var(--hair),
    var(--surface-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.windows-monitor-content {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  line-height: 1.6;
}

.windows-monitor-content .screen-greeting {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

.windows-monitor-content .screen-shortcut {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.windows-monitor-content .screen-status {
  font-size: 11px;
  color: var(--faint);
  max-width: 280px;
  margin: 0 auto;
}

.windows-stand {
  width: 80px;
  height: 40px;
  background: linear-gradient(to bottom, var(--surface-border) 0%, var(--surface) 100%);
  clip-path: polygon(10% 0%, 90% 0%, 100% 100%, 0% 100%);
}

.windows-stand-base {
  width: 140px;
  height: 8px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 2px;
  margin-top: -1px;
}

.windows-keyboard {
  width: 320px;
  height: 100px;
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 3px;
  padding: 8px;
  box-shadow: var(--surface-shadow);
}

.windows-key {
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 3px;
}

.windows-key.space {
  grid-column: span 6;
}

/* Dark mode adjustments */
[data-theme="dark"] .macbook-screen {
  box-shadow: 
    inset 0 0 0 8px #0a0a0a,
    inset 0 0 0 9px var(--hair),
    var(--surface-shadow);
}

[data-theme="dark"] .macbook-screen::before {
  background: #333;
}

[data-theme="dark"] .windows-monitor {
  box-shadow: 
    inset 0 0 0 12px #0a0a0a,
    inset 0 0 0 13px var(--hair),
    var(--surface-shadow);
}

/* Screen glow effect in dark mode */
[data-theme="dark"] .macbook-screen::after,
[data-theme="dark"] .windows-monitor::after {
  content: '';
  position: absolute;
  inset: 20px;
  background: radial-gradient(ellipse at center, rgba(100, 140, 180, 0.03) 0%, transparent 70%);
  pointer-events: none;
}

/* Hide on smaller screens */
@media (max-width: 1024px) {
  .desk-device {
    display: none;
  }
}

/* --------------------------------------------
   Notes
   -------------------------------------------- */
.note {
  position: absolute;
  width: 260px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  box-shadow: var(--surface-shadow);
  cursor: grab;
  user-select: none;
  transition: 
    box-shadow 0.3s var(--ease-out),
    transform 0.3s var(--ease-out),
    opacity 0.25s ease;
  /* Fix blur from rotation */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  /* Force GPU layer */
  will-change: transform;
}

.note:hover {
  box-shadow: 
    0 2px 4px rgba(0,0,0,0.02),
    0 4px 8px rgba(0,0,0,0.03),
    0 8px 16px rgba(0,0,0,0.04),
    0 16px 32px rgba(0,0,0,0.04),
    0 24px 48px rgba(0,0,0,0.03);
}

.note.dragging {
  cursor: grabbing;
  z-index: 100;
  transition: 
    box-shadow 0.15s var(--ease-out),
    transform 0.15s var(--ease-spring);
}

.note.dragging {
  box-shadow: 
    0 4px 8px rgba(0,0,0,0.04),
    0 8px 16px rgba(0,0,0,0.06),
    0 16px 32px rgba(0,0,0,0.06),
    0 32px 64px rgba(0,0,0,0.05);
}

/* Note content */
.note-title {
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.note-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.note-meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hair);
  font-size: 11px;
  color: var(--faint);
}

.note-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.2s ease;
}

.note:hover .note-link {
  opacity: 1;
  transform: translateY(0);
}

.note-link:hover {
  color: var(--accent-hover);
}

/* Note states */
.note.highlighted {
  box-shadow: 
    0 0 0 2px var(--accent-glow),
    0 0 24px var(--accent-glow),
    0 4px 8px rgba(0,0,0,0.04),
    0 8px 16px rgba(0,0,0,0.06);
  z-index: 50;
}

.note.dimmed {
  opacity: 0.2;
  transform: scale(0.98);
}

.note.dimmed:hover {
  opacity: 0.4;
}

/* --------------------------------------------
   Search Overlay
   -------------------------------------------- */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.search-overlay.open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.search-container {
  width: min(580px, 92%);
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: 16px;
  box-shadow: 
    0 4px 8px rgba(0,0,0,0.04),
    0 8px 16px rgba(0,0,0,0.04),
    0 16px 32px rgba(0,0,0,0.06),
    0 32px 64px rgba(0,0,0,0.08);
  overflow: hidden;
  transform: translateY(-10px) scale(0.98);
  transition: transform 0.2s var(--ease-out);
}

.search-overlay.open .search-container {
  transform: translateY(0) scale(1);
}

/* Search input */
.search-input-wrapper {
  padding: 16px 20px;
  border-bottom: 1px solid var(--hair);
}

.search-input {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.search-input::placeholder {
  color: var(--faint);
}

/* Search hints */
.search-hints {
  padding: 12px 20px;
  background: rgba(0,0,0,0.02);
  border-bottom: 1px solid var(--hair);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

[data-theme="dark"] .search-hints {
  background: rgba(255,255,255,0.02);
}

.search-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  padding: 3px 8px;
  background: var(--hair);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s ease;
  border: none;
}

.search-hint:hover {
  color: var(--muted);
  background: var(--surface-border);
}

/* Search results */
.search-results {
  max-height: 340px;
  overflow-y: auto;
}

.search-result {
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-result:hover,
.search-result.selected {
  background: var(--hair);
}

.search-result-title {
  font-size: 14px;
  font-weight: 450;
}

.search-result-context {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.search-result-hint {
  font-size: 11px;
  color: var(--faint);
  flex-shrink: 0;
  margin-left: var(--space-md);
}

.search-result-type {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  padding: 2px 6px;
  background: var(--hair);
  border-radius: 3px;
  text-transform: uppercase;
}

.search-empty {
  padding: 24px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.search-section {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Help panel */
.help-panel {
  padding: 20px;
}

.help-section {
  margin-bottom: var(--space-lg);
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-sm);
}

.help-commands {
  display: grid;
  gap: var(--space-sm);
}

.help-command {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
}

.help-command-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 80px;
}

.help-command-desc {
  font-size: 13px;
  color: var(--muted);
}

/* --------------------------------------------
   Responsive
   -------------------------------------------- */
@media (max-width: 1024px) {
  .note {
    width: 200px;
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .note {
    width: 160px;
    padding: 14px;
  }
  
  .note-title {
    font-size: 13px;
  }
  
  .note-body {
    font-size: 12px;
    line-height: 1.4;
  }
  
  .note-meta {
    font-size: 10px;
    margin-top: 8px;
    padding-top: 8px;
  }
  
  .note-link {
    font-size: 11px;
    margin-top: 8px;
  }
}

@media (max-width: 600px) {
  .desk-brand-hint {
    display: none;
  }
  
  .desk-header-inner {
    padding: 0 16px;
  }
  
  .search-overlay {
    padding-top: 60px;
    padding-left: 12px;
    padding-right: 12px;
  }
  
  .search-container {
    width: 100%;
  }
  
  .search-hints {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 16px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }
  
  .search-hint {
    flex-shrink: 0;
  }
  
  .desk-status {
    left: 16px;
    bottom: 16px;
    right: 16px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .note {
    width: calc(100vw - 32px);
    max-width: 280px;
  }
  
  .desk {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
}

/* Prevent horizontal scroll */
html, body.desk-page {
  max-width: 100%;
  overflow-x: hidden;
}

/* ============================================
   EDIT MODE STYLES
   ============================================ */

/* Edit toolbar */
.edit-toolbar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.edit-toolbar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.edit-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding-right: 8px;
  border-right: 1px solid var(--hair);
  margin-right: 4px;
}

.edit-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.edit-btn:hover {
  background: var(--bg);
  border-color: var(--muted);
}

.edit-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.edit-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.edit-btn.danger {
  color: #dc3545;
}

.edit-btn.danger:hover {
  background: #dc354510;
}

.edit-btn svg {
  flex-shrink: 0;
}

[data-theme="dark"] .edit-btn:not(.primary) {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .content-item-actions button {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .note-edit-btn,
[data-theme="dark"] .note-delete-btn {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .edit-overlay-btn {
  border-color: rgba(255, 255, 255, 0.25);
}

/* Note edit overlay */
.edit-mode .note {
  cursor: pointer;
}

.note-edit-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  gap: 4px;
}

.edit-mode .note:hover .note-edit-overlay {
  display: flex;
}

.note-edit-btn,
.note-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--hair);
  background: var(--panel-solid);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.note-edit-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.note-delete-btn:hover {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

/* Edit modal */
.edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.edit-modal-overlay.open {
  opacity: 1;
}

.edit-modal {
  width: min(440px, 90vw);
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.edit-modal-overlay.open .edit-modal {
  transform: scale(1);
}

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

.edit-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.edit-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  border-radius: 6px;
}

.edit-modal-close:hover {
  background: var(--hair);
}

.edit-modal-body {
  padding: 20px;
}

.edit-field {
  margin-bottom: 16px;
}

.edit-field:last-child {
  margin-bottom: 0;
}

.edit-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.edit-field input,
.edit-field textarea,
.edit-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
  color: var(--ink);
}

.edit-field input:focus,
.edit-field textarea:focus,
.edit-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.edit-field textarea {
  resize: vertical;
  min-height: 80px;
}

.edit-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--hair);
}

/* Wide modal for content editing */
.edit-modal.wide {
  width: min(600px, 94vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.edit-modal.wide .edit-modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: 60vh;
}

/* Tabs */
.edit-modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--hair);
  padding: 0 20px;
}

.tab-btn {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}

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

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Content list */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
}

.content-item-info strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.content-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.content-item-actions {
  display: flex;
  gap: 6px;
}

.content-item-actions button {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
}

.content-item-actions button:hover {
  background: var(--hair);
}

.content-item-actions button.danger {
  color: #dc3545;
}

.content-item-actions button.danger:hover {
  background: #dc354515;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Edit form inside tabs */
.edit-form {
  padding: 4px 0;
}

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

.status.info {
  padding: 12px;
  background: var(--accent-glow);
  border-radius: 8px;
  font-size: 13px;
}

/* Static field (non-editable) */
.edit-field-static {
  margin-bottom: 16px;
}

.edit-field-static label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.edit-field-static span {
  display: block;
  padding: 10px 12px;
  background: var(--hair);
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
}

/* Rich editor toolbar */
.rich-editor-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.rich-editor-toolbar button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rich-editor-toolbar button:hover {
  background: var(--hair);
  color: var(--ink);
}

.content-editor {
  border-radius: 0 0 8px 8px !important;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  line-height: 1.6;
}

/* Edit overlay button for cards on listing pages */
.edit-overlay-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  padding: 6px 12px;
  font-size: 12px;
  background: var(--accent);
  color: white;
  border: 2px solid var(--bg);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.edit-mode .edit-overlay-btn {
  opacity: 1;
}

.edit-overlay-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* Tag input with autocomplete */
.tag-input-wrapper {
  position: relative;
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  display: none;
  max-height: 200px;
  overflow-y: auto;
}

.tag-suggestion {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--hair);
}

.tag-suggestion:last-child {
  border-bottom: none;
}

.tag-suggestion:hover {
  background: var(--surface);
}

.tag-suggestion.new-tag {
  color: var(--accent);
  font-weight: 500;
}

/* Upload button in toolbar */
.upload-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-btn:hover {
  background: var(--hair);
  color: var(--ink);
}

/* Static field inline variant */
.edit-field-static-inline {
  padding: 10px 12px;
  background: var(--hair);
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
}

/* Tag pills in edit modal */
.tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 32px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 16px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.tag-pill button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  opacity: 0.7;
}

.tag-pill button:hover {
  opacity: 1;
}

/* Edit toast */
.edit-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 700;
}

.edit-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.edit-toast.error {
  border-color: #dc3545;
  color: #dc3545;
}

/* Edit mode indicator on notes */
.edit-mode .note.editable::after {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.edit-mode .note.editable:hover::after {
  opacity: 0.5;
}

/* Device editable indicator */
.edit-mode .desk-device.editable {
  cursor: pointer;
}

.edit-mode .desk-device.editable::after {
  content: 'Click Settings to edit';
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* Push page content below fixed edit toolbar */
.edit-mode .page-header {
  top: 60px;
}

.edit-mode .page-container {
  padding-top: 80px;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .edit-toolbar-inner {
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100vw - 32px);
  }
  
  .edit-toolbar-label {
    width: 100%;
    text-align: center;
    border-right: none;
    border-bottom: 1px solid var(--hair);
    padding-bottom: 8px;
    margin-bottom: 8px;
    margin-right: 0;
    padding-right: 0;
  }
  
  .edit-btn span:not(:empty) {
    display: none;
  }
}

/* ============================================
   INLINE EDITING
   ============================================ */

/* Editable section — hover outline + edit pill */
.editable-section {
  position: relative;
  transition: outline 0.15s ease;
  border-radius: 8px;
}

.edit-mode .editable-section:hover {
  outline: 2px dashed var(--hair);
  outline-offset: 8px;
}

.edit-mode .editable-section.editing {
  outline: 2px solid var(--accent);
  outline-offset: 8px;
}

/* Section edit pill — visible on hover */
.section-edit-pill {
  position: absolute;
  top: -4px;
  right: -4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  z-index: 10;
  white-space: nowrap;
}

.edit-mode .editable-section:hover .section-edit-pill {
  opacity: 1;
  transform: translateY(0);
}

.section-edit-pill:hover {
  background: var(--accent);
  color: white;
}

.section-edit-pill:disabled {
  opacity: 0.3 !important;
  cursor: not-allowed;
  pointer-events: none;
}

/* Contenteditable inline editing */
[contenteditable="true"].inline-editable {
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  outline: none;
  border-radius: 2px;
  transition: background 0.15s ease, border-color 0.15s ease;
  min-height: 1.2em;
}

[contenteditable="true"].inline-editable:focus {
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

[contenteditable="true"].inline-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  pointer-events: none;
}

/* Inline list add button */
.inline-list-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 6px 0;
  margin-top: 4px;
  border: 2px dashed var(--hair);
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.inline-list-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Inline delete button on items */
.inline-delete-btn {
  position: absolute;
  top: 50%;
  right: -28px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(180, 80, 80, 0.1);
  color: rgb(180, 80, 80);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.inline-delete-btn:hover {
  background: rgba(180, 80, 80, 0.2);
}

/* Show delete on hover of parent */
[data-edit-group]:hover > .inline-delete-btn,
[data-edit-list] > *:hover > .inline-delete-btn {
  opacity: 1;
}

/* Make items relative for delete positioning */
.editing [data-edit-group],
.editing [data-edit-list] > * {
  position: relative;
}

/* HTML edit textarea overlay */
.html-edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  resize: vertical;
}

.html-edit-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Contact method inline form */
.method-inline-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.method-inline-form label {
  font-size: 11px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.method-inline-form input {
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--hair);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
}

.method-inline-form input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Inline tag editor */
.inline-tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  position: relative;
}

.inline-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 4px 8px;
  border-radius: 12px;
}

.inline-tag-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
}

.inline-tag-remove:hover {
  opacity: 1;
}

.inline-tag-input {
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  width: 120px;
}

.inline-tag-input:focus {
  outline: none;
  border-color: var(--accent);
}

.inline-tag-suggestions {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  z-index: 410;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 4px;
}

.inline-tag-suggestion {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.inline-tag-suggestion:hover {
  background: var(--surface);
}

.inline-tag-suggestion.new-tag {
  color: var(--accent);
  font-weight: 500;
  border-top: 1px solid var(--hair);
}

.inline-tag-add-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px dashed var(--accent);
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.inline-tag-add-btn:hover {
  background: var(--accent);
  color: white;
}

/* Inline status select */
.inline-status-select {
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

.inline-status-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Inline date/year inputs */
.inline-date-input,
.inline-year-input {
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
}

.inline-date-input:focus,
.inline-year-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============================================
   VERSION HISTORY PANEL
   ============================================ */
.version-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 90vw);
  background: var(--panel-solid, var(--bg));
  border-left: 1px solid var(--hair);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  z-index: 300;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.version-panel.open {
  transform: translateX(0);
}

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

.version-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.version-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.version-panel-close:hover {
  color: var(--ink);
}

.version-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.version-item {
  padding: 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: border-color 0.15s ease;
}

.version-item:hover {
  border-color: var(--accent);
}

.version-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.version-item-label {
  font-weight: 500;
  font-size: 13px;
}

.version-item-time {
  font-size: 11px;
  color: var(--faint);
}

.version-item-section {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.version-item-actions {
  display: flex;
  gap: 6px;
}

.version-item button {
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.version-item button:hover {
  background: var(--accent);
  color: white;
}

.version-preview-content {
  margin-top: 0;
}

.version-preview-content:not(:empty) {
  margin-top: 10px;
}

.version-diff {
  border-top: 1px solid var(--hair);
  padding-top: 8px;
}

.diff-item {
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.diff-key {
  font-weight: 500;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.diff-current {
  color: rgb(180, 80, 80);
}

.diff-version {
  color: rgb(61, 106, 92);
}

.version-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--faint);
  font-size: 13px;
}

/* Version panel backdrop */
.version-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.version-panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   FLOATING FORMAT TOOLBAR
   ============================================ */
.format-toolbar {
  position: absolute;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--ink, #1a1a1a);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
}

.format-toolbar button {
  background: none;
  border: none;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}

.format-toolbar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.format-toolbar-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
}

/* ============================================
   UNIFIED GUIDE CONTENT EDITING
   ============================================ */
.edit-mode .guide-content-editable {
  outline: 2px dashed var(--hair);
  outline-offset: 12px;
  border-radius: 8px;
  min-height: 200px;
  padding: 4px;
  transition: outline-color 0.15s ease;
}

.edit-mode .guide-content-editable:focus {
  outline-color: var(--accent);
}

.guide-content-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  pointer-events: none;
}

