:root {
  --ink: #202124;
  --muted: #6c7078;
  --board: #fbfaf4;
  --paper: #fffdf7;
  --line: rgba(32, 33, 36, 0.12);
  --marker: #1f6f8b;
  --warm: #fff5c9;
  --green: #edf7df;
  --blue: #eaf5ff;
  --rose: #ffe8df;
  --shadow: 0 18px 45px rgba(32, 33, 36, 0.11);
  --sidebar-width: 260px;
  font-family: Aptos, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

body {
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background-color: var(--board);
}

.grid-bg {
  position: absolute;
  inset: -10000px;
  background-image: radial-gradient(var(--muted) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.15;
  pointer-events: none;
  z-index: -1;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image: radial-gradient(rgba(32, 33, 36, 0.12) 0.55px, transparent 0.55px);
  background-size: 9px 9px;
  mix-blend-mode: multiply;
}

.toast-stack {
  display: grid;
  gap: 10px;
  pointer-events: none;
  position: fixed;
  right: 16px;
  top: 78px;
  width: min(360px, calc(100% - 32px));
  z-index: 80;
}

.toast {
  animation: toast-in 220ms ease both;
  background: rgba(32, 33, 36, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color: #fffef8;
  font-weight: 800;
  padding: 0.9rem 1rem;
}

.lightbox {
  align-items: center;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 100;
}

.lightbox[hidden] { display: none; }

.lb-image-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: calc(100vh - 160px);
  max-width: 92vw;
  overflow: hidden;
  border-radius: 16px;
}
.lb-image-wrap img {
  transition: transform 200ms ease;
  will-change: transform;
}

/* Full-resolution view on hover */
.lb-full-res {
  justify-content: flex-start;
  align-items: flex-start;
}
.lb-full-res .lb-image-wrap {
  max-height: calc(100vh - 160px);
  max-width: 94vw;
  overflow: auto;
  cursor: grab;
  border-radius: 16px;
  display: block;
  align-items: initial;
  justify-content: initial;
}
.lb-full-res .lb-image-wrap img {
  max-height: none;
  max-width: none;
  object-fit: none;
  box-shadow: none;
  border-radius: 0;
  display: block;
}
.lb-full-res .lb-image-wrap:active {
  cursor: grabbing;
}

.lightbox img {
  border-radius: 16px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
  max-height: calc(100vh - 180px);
  max-width: 92vw;
  object-fit: contain;
  transition: opacity 180ms ease;
}

.lightbox img.is-swapping {
  opacity: 0;
}

.lb-btn {
  position: absolute;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.lb-btn:hover { background: rgba(255,255,255,0.18); transform: scale(1.08); }
.lb-close { top: 20px; right: 20px; font-size: 1rem; width: 40px; height: 40px; }
.lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lb-prev:hover { transform: translateY(-50%) scale(1.08); }
.lb-next { right: 20px; top: 50%; transform: translateY(-50%); }
.lb-next:hover { transform: translateY(-50%) scale(1.08); }
.lb-btn svg { stroke: rgba(255,255,255,0.9); }

.lb-counter {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  border: 1px solid rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 250ms ease;
}
.lightbox:hover .lb-counter { opacity: 1; }

.lb-caption {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  padding: 10px 24px;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
  pointer-events: none;
  opacity: 1;
  z-index: 11;
}
.lb-caption-title {
  color: rgba(255,255,255,0.95);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.lb-caption-date {
  color: rgba(255,255,255,0.55);
  font-size: 0.72rem;
  font-weight: 500;
}

.lb-strip {
  position: fixed;
  bottom: 42px;
  left: 0;
  right: 0;
  height: 80px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 8px;
  padding: 10px 24px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
  align-items: center;
  z-index: 11;
  opacity: 0;
  transition: opacity 250ms ease;
}
.lightbox:hover .lb-strip { opacity: 1; }
.lb-strip[hidden] { display: none; }
.lb-strip::-webkit-scrollbar { height: 4px; }
.lb-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.lb-strip-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: border-color 150ms, transform 150ms;
  opacity: 0.55;
}
.lb-strip-thumb:hover { border-color: rgba(255,255,255,0.4); opacity: 0.85; transform: translateY(-2px); }
.lb-strip-thumb.active { border-color: rgba(255,255,255,0.9); opacity: 1; }
.lb-strip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lb-strip-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  color: rgba(255,255,255,0.9);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 12px 4px 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 200ms ease;
}
.lb-strip-thumb.active .lb-strip-label,
.lb-strip-thumb:hover .lb-strip-label {
  opacity: 1;
}

/* Shortcuts modal */
.shortcuts-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shortcuts-modal[hidden] { display: none !important; }
.shortcuts-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 90vw;
  box-shadow: 0 24px 60px rgba(0,0,0,0.2);
  max-height: 80vh;
  overflow-y: auto;
}
.shortcuts-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.shortcuts-head button {
  border: none;
  background: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  align-items: center;
}
.shortcuts-grid kbd {
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-family: monospace;
  white-space: nowrap;
}


.context-menu {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
  position: fixed;
  z-index: 200;
}

.context-menu[hidden] { display: none; }

.context-menu button {
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 0.9rem;
  justify-content: space-between;
  padding: 8px 12px;
  text-align: left;
  transition: background 0.1s;
}

.context-menu button:hover {
  background: var(--blue);
  color: var(--marker);
}

.context-menu button[disabled] {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
  padding-bottom: 4px;
}

.shortcut-hint {
  color: var(--muted);
  font-size: 0.8em;
  margin-left: 12px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
}

.lock-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.lock-card {
  width: min(720px, 100%);
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid var(--line);
  border-radius: 34px;
  box-shadow: var(--shadow);
  padding: clamp(28px, 6vw, 56px);
  transform: rotate(-0.7deg);
}

.eyebrow, #lockHint, .item-kind, .item-meta, label, .queue-head strong, #status, #textCount {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

.lock-card h1 {
  font-family: Georgia, serif;
  font-size: clamp(2.55rem, 7vw, 5.7rem);
  letter-spacing: -0.075em;
  line-height: 0.9;
  margin-bottom: 20px;
}

.lock-card p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
  max-width: 560px;
}

.unlock-form {
  display: flex;
  gap: 10px;
  margin: 26px 0 12px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  outline: none;
  padding: 0.95rem 1rem;
}

input:focus, textarea:focus {
  border-color: rgba(31, 111, 139, 0.44);
  box-shadow: 0 0 0 4px rgba(31, 111, 139, 0.12);
}

button, .item-actions a {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffef8;
  cursor: pointer;
  font-weight: 800;
  padding: 0.82rem 1rem;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

button:hover, .item-actions a:hover {
  box-shadow: 0 12px 26px rgba(32, 33, 36, 0.16);
  transform: translateY(-1px);
}

.ghost-button, .chip, .delete {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: none;
}

.app-shell {
  display: grid;
  grid-template-areas:
    "sidebar board";
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 8px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  padding: 8px;
  width: 100%;
}

.app-shell.sidebar-closed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.command-bar {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-area: toolbar;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  margin: 0 auto;
  max-width: none;
  position: relative;
  z-index: 30;
  width: 100%;
}

.command-bar button {
  min-height: 52px;
}

.icon-button {
  align-items: center;
  aspect-ratio: 1;
  display: inline-grid;
  justify-content: center;
  min-height: 52px;
  padding: 0;
  width: 52px;
}

.navigator {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(32, 33, 36, 0.07);
  display: flex;
  flex-direction: column;
  gap: 0;
  grid-area: sidebar;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  width: 100%;
  z-index: 25;
  max-height: 100%;
}

.app-shell.sidebar-closed .navigator {
  display: none;
}