/* ── Loading skeleton (first-visit shimmer) ── */
@keyframes skeleton-shimmer {
  from { background-position: -600px 0; }
  to   { background-position:  600px 0; }
}

.skeleton-card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--card-w, 340px);
  height: var(--card-h, 250px);
  transform: translate3d(var(--card-x, 0), var(--card-y, 0), 0);
  border-radius: 12px;
  background: linear-gradient(
    90deg,
    rgba(32, 33, 36, 0.05) 25%,
    rgba(32, 33, 36, 0.11) 50%,
    rgba(32, 33, 36, 0.05) 75%
  );
  background-size: 600px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.thumb {
  background: rgba(255, 255, 255, 0.42);
  flex: 1 1 auto;
  min-height: 80px;
  overflow: hidden;
}

.thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
  width: 100%;
}

.thumb img {
  cursor: zoom-in;
}

.memory-card:hover .thumb img {
  transform: scale(1.04);
}

.item-body {
  flex: 0 0 auto;
  padding: 12px 14px 10px;
}

.item-body h3 {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 4px;
  margin-top: 0;
  cursor: text;
}

.title-row { position: relative; }

/* Inline title editor */
.title-edit-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.title-edit-row[hidden] { display: none; }

.title-input {
  flex: 1;
  border: 1.5px solid rgba(31, 111, 139, 0.5);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.95rem;
  font-family: Georgia, serif;
  background: rgba(255,255,255,0.85);
  outline: none;
}
.title-input:focus { border-color: #1f6f8b; }

.title-save, .title-cancel {
  border: none;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.title-save { background: #1f6f8b; color: #fff; }
.title-save:hover { background: #17596f; }
.title-cancel { background: rgba(0,0,0,0.07); color: #555; }
.title-cancel:hover { background: rgba(0,0,0,0.13); }



.snippet {
  color: #3c4043;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 10rem;
  overflow: auto;
  white-space: pre-wrap;
}

.inline-editor {
  border-radius: 14px;
  font-family: Georgia, serif;
  line-height: 1.35;
  min-height: 140px;
  resize: vertical;
}

/* item-kind label — never shown */
.item-kind { display: none; }

/* item-meta — tiny, muted, fade in on hover */
.item-meta {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 6px 0 0;
  opacity: 0;
  transition: opacity 150ms ease;
}
.memory-card:hover .item-meta { opacity: 1; }

/* item-actions (Open / Delete) — hidden until hover or selected */
.item-actions {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.memory-card:hover .item-actions,
.memory-card.selected .item-actions {
  opacity: 1;
  pointer-events: auto;
}
.item-actions a, .item-actions button {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 6px;
}

.delete, .danger-button { color: #9a4329; }

.item-body, .snippet {
  cursor: auto;
}


/* drag-handle — subtle grip icon, only on hover */
.drag-handle {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(32, 33, 36, 0.08);
  color: var(--muted);
  cursor: grab;
  font-size: 0.65rem;
  left: 8px;
  padding: 3px 6px;
  position: absolute;
  top: 8px;
  z-index: 3;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 160ms ease;
  letter-spacing: 1px;
}

.memory-card:hover .drag-handle,
.memory-card:focus-within .drag-handle {
  opacity: 1;
}

.resize-handle {
  border-bottom: 14px solid rgba(32, 33, 36, 0.38);
  border-left: 14px solid transparent;
  bottom: 9px;
  cursor: nwse-resize;
  position: absolute;
  right: 9px;
  z-index: 3;
}

.settings-panel {
  background: rgba(255, 253, 247, 0.96);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 20px;
  position: fixed;
  right: 14px;
  top: 14px;
  width: min(390px, calc(100% - 28px));
  z-index: 50;
}

.settings-panel[hidden] { display: none; }

.settings-head, .filters, .queue-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.settings-head h2 {
  font-family: Georgia, serif;
  font-size: 2rem;
  letter-spacing: -0.055em;
  line-height: 1;
  margin-bottom: 0;
}

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

.setting-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.border-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: -1px;
}

.setting-block label {
  display: flex;
  justify-content: space-between;
}

.setting-block input[type="range"] {
  accent-color: var(--marker);
  padding: 0;
}

.saved-pill {
  background: rgba(31, 111, 139, 0.08);
  border-radius: 18px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  padding: 0.9rem 1rem;
}

.filters {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.chip.active {
  background: var(--marker);
  color: #fff;
}

.queue-card {
  background: var(--rose);
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 20px;
  padding: 14px;
}

.queue-card[hidden] { display: none; }

#queueList {
  display: grid;
  gap: 8px;
}

.queue-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.queue-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-row strong {
  color: var(--muted);
  white-space: nowrap;
}

.queue-row[data-state="done"] strong { color: #527b3e; }
.queue-row[data-state="error"] strong { color: #a1492d; }

.minimap {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 110px;
  height: 110px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(32, 33, 36, 0.08);
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
  contain: layout style;
  transform: translateZ(0);
}

.command-bar { display: none; }

.minimap-dot {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--muted);
  border-radius: 1.5px;
  will-change: transform;
  opacity: 0.6;
}

.minimap-viewport {
  position: absolute;
  top: 0;
  left: 0;
  border: 1.5px solid rgba(31, 111, 139, 0.5);
  background: rgba(31, 111, 139, 0.08);
  border-radius: 3px;
  will-change: transform, width, height;
  transform: translateZ(0);
}

.floating-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 99px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  padding: 6px;
  gap: 4px;
  z-index: 60;
}

.tool-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.tool-button:hover {
  background: rgba(0,0,0,0.05);
  color: var(--ink);
}

.tool-button.active {
  background: var(--blue);
  color: var(--marker);
}

.floating-search {
  border: none;
  background: transparent;
  padding: 0 16px;
  font-size: 0.95rem;
  width: 200px;
  outline: none;
  border-left: 1px solid rgba(0,0,0,0.1);
  margin-left: 4px;
}

.zoom-bar {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  padding: 4px 6px;
  gap: 2px;
  z-index: 60;
}

.zoom-bar-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  color: #202124;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}
.zoom-bar-btn:hover { background: rgba(0,0,0,0.07); }

.zoom-bar span {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  user-select: none;
  color: #202124;
  letter-spacing: 0.01em;
}

.zoom-divider {
  width: 1px;
  height: 18px;
  background: rgba(0,0,0,0.12);
  margin: 0 3px;
  flex-shrink: 0;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: rgba(0,0,0,0.1);
  margin: 0 2px;
  flex-shrink: 0;
}

.zoom-bar button {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #202124;
  flex-shrink: 0;
}

.zoom-bar button svg, .tool-button svg {
  stroke: currentColor;
  width: 16px;
  height: 16px;
}

.tool-button.active svg {
  stroke: var(--marker);
}

.zoom-bar button:hover {
  background: rgba(0,0,0,0.05);
}

.zoom-bar span {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  user-select: none;
  color: #202124;
  letter-spacing: 0.01em;
}

.zoom-divider {
  width: 1px;
  height: 16px;
  background: rgba(0,0,0,0.1);
  margin: 0 4px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "board";
    padding: 8px;
    width: 100%;
    position: relative;
  }
  .app-shell.sidebar-closed { grid-template-columns: 1fr; }
  .navigator {
    position: absolute;
    top: 8px;
    left: 8px;
    bottom: 8px;
    width: calc(100% - 16px);
    max-width: 380px;
    height: auto;
    z-index: 45;
  }
  #status { display: none; }
  .board { border-radius: 24px; min-height: 0; }
  .canvas-dock { grid-template-columns: 1fr; }
  .capture-canvas {
    width: min(420px, calc(100vw - 36px));
  }
  .capture-canvas.is-writing {
    width: min(520px, calc(100vw - 36px));
  }
  .unlock-form { flex-direction: column; }
}

@media (max-width: 520px) {
  .lock-card { transform: none; }
  .capture-canvas { min-height: 150px; }
}

/* Composer dismiss header */
.composer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.composer-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.composer-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: 4px;
}
.composer-close:hover { color: var(--ink); background: rgba(0,0,0,0.06); }

/* Context menu shortcut hint */
.ctx-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: #999;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
}

/* Settings panel overlay */
.settings-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-panel-overlay[hidden] { display: none !important; }
.settings-panel-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: min(500px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
}
.settings-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}
.settings-section:first-of-type { border-top: none; margin-top: 0; }
.settings-section h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #444;
  font-weight: 600;
}
.settings-desc {
  font-size: 0.82rem;
  color: #888;
  margin: 0 0 12px;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}
.settings-row label { flex: 1; color: #555; }
.settings-row input[type="number"] {
  width: 80px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
}
.settings-row input[type="range"] { flex: 1; accent-color: #1f6f8b; }
.settings-action-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: #1f6f8b;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  margin-top: 4px;
}
.settings-action-btn:disabled { opacity: 0.6; cursor: wait; }
.settings-action-btn:hover:not(:disabled) { background: #17596f; }
.settings-ghost-btn {
  border: 1px solid #ddd;
  background: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  color: #555;
}
.settings-ghost-btn:hover { background: #f5f5f5; }
.recompress-log {
  margin-top: 10px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.78rem;
  font-family: monospace;
  color: #555;
  background: #f8f8f8;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.recompress-log:empty { display: none; }
