* {
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  background: #111111;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --glass-surface: oklch(0 0 0 / 0.55);
  --glass-surface-strong: oklch(0 0 0 / 0.7);
  --glass-stroke: oklch(1 0 0 / 0.1);
  --glass-stroke-hover: oklch(1 0 0 / 0.18);
  --glass-stroke-strong: oklch(1 0 0 / 0.25);
  --glass-blur: blur(22px) saturate(1.12);
  --font-compact: "SF Compact Text", "SF Compact", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-public-demo="true"] :is(
  #clip-add-button,
  #board-create-button,
  #manual-note-section
) {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  width: 100%;
  height: 100%;
  background: #111111;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111111;
}

/* --- Design Topbar --- */

.design-topbar {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 0;
  right: 0;
  z-index: 55;
  color: oklch(1 0 0);
  pointer-events: none;
}

.design-topbar::before,
.design-topbar::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  z-index: 2;
  width: 84px;
  pointer-events: none;
}

.design-topbar::before {
  left: 0;
  background: linear-gradient(90deg, #111111 0%, oklch(0.18 0 0 / 0.62) 24%, transparent 100%);
}

.design-topbar::after {
  right: 0;
  background: linear-gradient(270deg, #111111 0%, oklch(0.18 0 0 / 0.62) 24%, transparent 100%);
}

.filter-scroll {
  min-width: 0;
  position: relative;
  z-index: 1;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  pointer-events: auto;
  padding-inline: calc(20px + var(--safe-left)) calc(96px + var(--safe-right));
  scroll-padding-inline: calc(20px + var(--safe-left)) calc(96px + var(--safe-right));
}

.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: max-content;
  padding: 1px 0;
}

.filter-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 40px;
  padding: 12px 18px;
  border: none;
  border-radius: 100px;
  background: var(--glass-surface);
  box-shadow: 0 0 0 1px var(--glass-stroke);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  isolation: isolate;
  overflow: hidden;
  color: oklch(1 0 0 / 0.64);
  font: inherit;
  font-family: var(--font-compact);
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition-property: background, box-shadow, color, transform;
  transition-duration: 0.16s;
  transition-timing-function: ease-out;
}

.filter-chip-count {
  color: currentColor;
  font: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: inherit;
  opacity: 0.52;
}

.filter-chip:hover {
  background: var(--glass-surface-strong);
  box-shadow: 0 0 0 1px var(--glass-stroke-hover);
  color: oklch(1 0 0 / 0.9);
}

.filter-chip:hover .filter-chip-count {
  opacity: 0.64;
}

.filter-chip:active {
  transform: scale(0.96);
}

.filter-chip.active {
  background: var(--glass-surface-strong);
  box-shadow: 0 0 0 1px var(--glass-stroke-strong);
  color: oklch(1 0 0);
}

.filter-chip.active .filter-chip-count {
  opacity: 0.68;
}

#viewport {
  position: relative;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  background: #111111;
  cursor: grab;
}

#viewport.grabbing {
  cursor: grabbing;
}

#container {
  position: absolute;
  inset: -10vmin;
  width: 100%;
  height: 100%;
  background: #111111;
}

#grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #111111;
}

.grid-item {
  position: absolute;
  overflow: hidden;
  user-select: none;
  backface-visibility: hidden;
  border-radius: 8px;
  contain: layout style paint;
}

.grid-author-pill {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 24px);
  background: none;
  border: none;
  color: oklch(1 0 0 / 0.92);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.grid-author-pill::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 999px;
}

.grid-author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.grid-author-label {
  display: flex;
  align-items: center;
  height: 22px;
  min-width: 0;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  background: oklch(0 0 0 / 0.55);
  backdrop-filter: blur(12px) saturate(1.2);
}

.grid-item > img:not(.play-pill-icon) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  border-radius: 8px;
  outline: 1px solid rgba(255, 255, 255, 0.1);
  outline-offset: -1px;
  transition-property: filter;
  transition-duration: 0.3s;
  transition-timing-function: ease;
}

.grid-item:hover:not(.lightbox-active) > img {
  filter: brightness(1.08);
}

.grid-item:focus-visible {
  outline: none;
}

.grid-item:focus-visible > img:not(.play-pill-icon) {
  outline: 2px solid oklch(1 0 0 / 0.72);
  outline-offset: 3px;
  filter: brightness(1.08);
}

/* --- Search Bar --- */

.search-bar {
  position: fixed;
  right: auto;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  z-index: 56;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: min(420px, calc(100vw - 40px - var(--safe-left) - var(--safe-right)));
  min-height: 40px;
  padding: 12px 18px;
  background: var(--glass-surface);
  border: none;
  border-radius: 100px;
  box-shadow: 0 0 0 1px var(--glass-stroke);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  isolation: isolate;
  overflow: hidden;
  transition-property: background, box-shadow;
  transition-duration: 0.2s;
  transition-timing-function: ease-out;
  transform: translateX(-50%);
}

.search-bar:focus-within {
  background: var(--glass-surface-strong);
  box-shadow: 0 0 0 1px var(--glass-stroke-strong);
}

.search-icon {
  color: oklch(1 0 0 / 0.4);
  flex-shrink: 0;
}

.search-bar:focus-within .search-icon {
  color: oklch(1 0 0 / 0.7);
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: oklch(1 0 0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 400;
  min-width: 0;
}

#search-input::placeholder {
  color: oklch(1 0 0 / 0.5);
}

.search-shortcut {
  flex-shrink: 0;
  padding: 2px 6px;
  background: oklch(1 0 0 / 0.08);
  border: none;
  border-radius: 6px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1);
  color: oklch(1 0 0 / 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

.search-bar:focus-within .search-shortcut {
  display: none;
}

/* --- Clip URL Flow --- */

.clip-add-button {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: calc(50% + 222px);
  z-index: 56;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: oklch(0 0 0 / 0.58);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.11);
  backdrop-filter: blur(12px) saturate(1.15);
  color: oklch(1 0 0 / 0.72);
  cursor: pointer;
  transition-property: background, color, transform, box-shadow;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

.clip-add-button:hover {
  background: oklch(0 0 0 / 0.74);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.18);
  color: oklch(1 0 0 / 0.92);
}

.clip-add-button:active {
  transform: scale(0.96);
}

.board-create-button {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: calc(50% - 266px);
  z-index: 56;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: oklch(0 0 0 / 0.58);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.11);
  backdrop-filter: blur(12px) saturate(1.15);
  color: oklch(1 0 0 / 0.72);
  cursor: pointer;
  transition: background 0.18s ease-out, color 0.18s ease-out, transform 0.18s ease-out, box-shadow 0.18s ease-out;
}

.board-create-button:hover {
  background: oklch(0 0 0 / 0.74);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.18);
  color: oklch(1 0 0 / 0.92);
}

.board-create-button:active {
  transform: scale(0.96);
}

.board-modal {
  position: fixed;
  inset: 0;
  z-index: 121;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(12px);
}

.board-modal[hidden] {
  display: none;
}

.board-panel {
  box-sizing: border-box;
  width: min(480px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: oklch(0 0 0 / 0.88);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.12), 0 28px 90px oklch(0 0 0 / 0.5);
  color: oklch(1 0 0);
}

.board-selection-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: oklch(1 0 0 / 0.5);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#board-unavailable-count {
  color: oklch(0.8 0.11 75);
  text-align: right;
}

.board-selection-list {
  display: grid;
  gap: 6px;
  max-height: min(250px, 30dvh);
  overflow-y: auto;
  padding-right: 2px;
}

.board-selection-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  background: oklch(1 0 0 / 0.06);
  color: oklch(1 0 0 / 0.78);
  cursor: pointer;
}

.board-selection-item input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: oklch(0.82 0.12 150);
}

.board-selection-copy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.25;
}

.board-header {
  position: fixed;
  top: calc(78px + var(--safe-top));
  left: 0;
  right: 0;
  z-index: 54;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px calc(24px + var(--safe-right)) 6px calc(24px + var(--safe-left));
  background: oklch(0 0 0 / 0.72);
  backdrop-filter: blur(10px);
  color: oklch(1 0 0);
  pointer-events: none;
}

.board-header[hidden] {
  display: none;
}

.board-heading {
  min-width: 0;
  text-shadow: 0 1px 12px oklch(0 0 0 / 0.8);
}

.board-header-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 650;
}

.board-header-counts {
  margin: 3px 0 0;
  color: oklch(1 0 0 / 0.58);
  font-size: 12px;
  line-height: 1.2;
}

.board-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  pointer-events: auto;
}

.board-header-actions button {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid oklch(1 0 0 / 0.16);
  border-radius: 4px;
  background: oklch(0 0 0 / 0.48);
  color: oklch(1 0 0 / 0.8);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.board-header-actions button:hover {
  background: oklch(0 0 0 / 0.74);
  color: oklch(1 0 0);
}

.board-unavailable-repairs {
  position: fixed;
  top: calc(132px + var(--safe-top));
  right: calc(24px + var(--safe-right));
  z-index: 54;
  box-sizing: border-box;
  width: min(360px, calc(100vw - 48px - var(--safe-left) - var(--safe-right)));
  max-height: min(48dvh, 420px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid oklch(1 0 0 / 0.14);
  border-radius: 6px;
  background: oklch(0 0 0 / 0.78);
  box-shadow: 0 12px 36px oklch(0 0 0 / 0.32);
  backdrop-filter: blur(10px);
  color: oklch(1 0 0 / 0.86);
}

.board-unavailable-repairs[hidden] {
  display: none;
}

.board-repair-title,
.board-repair-summary,
.board-repair-copy {
  margin: 0;
}

.board-repair-title {
  font-size: 13px;
  line-height: 1.3;
}

.board-repair-summary {
  margin-top: 3px;
  color: oklch(1 0 0 / 0.58);
  font-size: 12px;
  line-height: 1.35;
}

.board-repair-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.board-repair-item {
  display: grid;
  gap: 8px;
  padding: 9px;
  border-radius: 5px;
  background: oklch(1 0 0 / 0.06);
}

.board-repair-copy {
  color: oklch(1 0 0 / 0.72);
  font-size: 12px;
  line-height: 1.35;
}

.board-repair-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.board-repair-action {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid oklch(1 0 0 / 0.16);
  border-radius: 4px;
  background: oklch(0 0 0 / 0.42);
  color: oklch(1 0 0 / 0.82);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.board-repair-action:hover:not(:disabled) {
  background: oklch(0 0 0 / 0.72);
  color: oklch(1 0 0);
}

.board-repair-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.board-mode .search-bar,
.board-mode .design-topbar {
  opacity: 0.58;
}

.board-mode .design-topbar,
.board-mode .design-topbar * {
  pointer-events: none;
}

.board-mode .search-bar input:disabled,
.board-mode .filter-chip:disabled {
  cursor: not-allowed;
}

.board-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.clip-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(12px);
}

.clip-modal[hidden] {
  display: none;
}

.clip-panel {
  box-sizing: border-box;
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  background: oklch(0 0 0 / 0.82);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.12), 0 28px 90px oklch(0 0 0 / 0.5);
  color: oklch(1 0 0);
}

.clip-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.clip-panel-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: 0;
}

.clip-close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: oklch(1 0 0 / 0.08);
  color: oklch(1 0 0 / 0.64);
  cursor: pointer;
}

.clip-field {
  display: grid;
  gap: 8px;
}

.clip-field span {
  color: oklch(1 0 0 / 0.46);
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clip-field input,
.clip-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-radius: 16px;
  background: oklch(1 0 0 / 0.08);
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.1);
  color: oklch(1 0 0 / 0.92);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
}

.clip-field input {
  min-height: 44px;
  padding: 0 13px;
}

.clip-field textarea {
  min-height: 92px;
  resize: vertical;
  padding: 12px 13px;
}

.clip-field input::placeholder,
.clip-field textarea::placeholder {
  color: oklch(1 0 0 / 0.34);
}

.clip-field input:focus,
.clip-field textarea:focus {
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.22), 0 0 0 3px oklch(1 0 0 / 0.08);
}

.clip-preview {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  background: oklch(1 0 0 / 0.06);
}

.clip-preview[hidden] {
  display: none;
}

.clip-preview img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  background: oklch(1 0 0 / 0.08);
}

.clip-preview p {
  margin: 0;
}

#clip-preview-title {
  overflow: hidden;
  color: oklch(1 0 0 / 0.86);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#clip-preview-meta {
  margin-top: 4px;
  color: oklch(1 0 0 / 0.42);
  font-size: 12px;
  line-height: 1.2;
}

.clip-status {
  min-height: 16px;
  margin: 0;
  color: oklch(1 0 0 / 0.46);
  font-size: 12px;
  line-height: 1.3;
}

.clip-status.error {
  color: oklch(0.74 0.16 28);
}

.clip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.clip-button {
  min-height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  transition-property: background, color, transform, opacity;
  transition-duration: 0.16s;
  transition-timing-function: ease-out;
}

.clip-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.clip-button.primary {
  background: oklch(1 0 0 / 0.9);
  color: oklch(0.145 0 0);
}

.clip-button.secondary {
  background: oklch(1 0 0 / 0.08);
  color: oklch(1 0 0 / 0.62);
}

.clip-button:not(:disabled):active {
  transform: scale(0.96);
}

/* --- Lightbox --- */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: oklch(0 0 0 / 0.62);
  pointer-events: none;
  opacity: 0;
  transition-property: opacity;
  transition-duration: 0.3s;
  transition-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
}

.lightbox-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(6px);
  z-index: -1;
}

.lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 34px;
}

.lightbox-nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-control-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(1 0 0 / 0.075);
  border: none;
  border-radius: 50%;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.09);
  color: oklch(1 0 0 / 0.58);
  cursor: pointer;
  transition-property: background, box-shadow, color, transform, opacity;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
  backdrop-filter: blur(12px);
}

.lightbox-control-button:hover:not(:disabled) {
  background: oklch(1 0 0 / 0.13);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.16);
  color: oklch(1 0 0 / 0.86);
}

.lightbox-control-button:disabled {
  opacity: 0.28;
  cursor: default;
}

.lightbox-control-button:active:not(:disabled) {
  transform: scale(0.96);
}

.lightbox-info {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: clamp(320px, 32vw, 430px);
  min-width: 0;
  padding: calc(36px + var(--safe-top)) 40px 36px calc(40px + var(--safe-left));
  overflow-y: auto;
  background: oklch(0 0 0 / 0.8);
  box-shadow: 1px 0 0 oklch(1 0 0 / 0.08);
  backdrop-filter: blur(24px) saturate(1.18);
  transform: translateX(-18px);
  text-align: left;
  opacity: 0;
  transition-property: opacity, transform;
  transition-duration: 0.4s;
  transition-timing-function: ease;
  transition-delay: 0s;
  color: oklch(1 0 0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: none;
}

.lightbox-overlay.active .lightbox-info {
  opacity: 1;
  transform: translateX(0);
  transition-delay: 0.25s;
}

.lightbox-panel-copy {
  margin-bottom: 36px;
}

.lightbox-eyebrow {
  margin: 0 0 8px;
  color: oklch(1 0 0 / 0.42);
  font-size: 14px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0;
}

.lightbox-author-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  justify-content: flex-start;
}

.lightbox-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.lightbox-link {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 500;
  color: oklch(1 0 0 / 0.84);
  text-decoration: none;
  transition-property: color;
  transition-duration: 0.2s;
  transition-timing-function: ease;
}

.lightbox-link:hover {
  color: oklch(1 0 0);
}

.lightbox-date {
  font-size: 12px;
  line-height: 1;
  color: oklch(1 0 0 / 0.38);
  font-variant-numeric: tabular-nums;
}

.lightbox-title {
  margin: 0;
  max-width: 100%;
  color: oklch(1 0 0 / 0.94);
  font-size: 24px;
  line-height: 1.16;
  font-weight: 560;
  letter-spacing: 0;
  text-wrap: balance;
}

.lightbox-description {
  margin: 28px 0 0;
  color: oklch(1 0 0 / 0.54);
  font-size: 16px;
  line-height: 1.42;
  font-weight: 400;
  text-wrap: pretty;
}

.lightbox-meta-list {
  margin: 0 0 28px;
  padding: 0;
}

.lightbox-meta-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
  gap: 20px;
  padding: 13px 0;
  border-top: 1px solid oklch(1 0 0 / 0.11);
}

.lightbox-meta-row:last-child {
  border-bottom: 1px solid oklch(1 0 0 / 0.11);
}

.lightbox-meta-row[hidden],
.lightbox-visible-section[hidden] {
  display: none;
}

.lightbox-meta-row dt {
  color: oklch(1 0 0 / 0.42);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 500;
}

.lightbox-meta-row dd {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
  margin: 0;
  color: oklch(1 0 0 / 0.88);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 500;
  text-align: right;
}

.lightbox-visible-section {
  margin: 0 0 22px;
}

.lightbox-section-label {
  margin: 0 0 8px;
  color: oklch(1 0 0 / 0.42);
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lightbox-visible {
  margin: 0;
  color: oklch(1 0 0 / 0.56);
  font-size: 13px;
  line-height: 1.45;
  text-wrap: pretty;
}

.manual-note-section {
  margin: 0 0 24px;
  padding: 14px 0 0;
  border-top: 1px solid oklch(1 0 0 / 0.11);
}

.manual-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.manual-note-label {
  margin: 0;
  color: oklch(1 0 0 / 0.42);
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.manual-note-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 13px;
  border: none;
  border-radius: 999px;
  background: oklch(1 0 0 / 0.08);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1);
  color: oklch(1 0 0 / 0.68);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  cursor: pointer;
  transition-property: background, box-shadow, color, transform;
  transition-duration: 0.18s;
  transition-timing-function: ease-out;
}

.manual-note-edit:hover {
  background: oklch(1 0 0 / 0.13);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.16);
  color: oklch(1 0 0 / 0.9);
}

.manual-note-edit:active {
  transform: scale(0.96);
}

.manual-note-text {
  min-height: 18px;
  margin: 0;
  color: oklch(1 0 0 / 0.62);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  text-wrap: pretty;
}

.manual-note-text.empty {
  color: oklch(1 0 0 / 0.34);
}

.manual-note-form {
  display: grid;
  gap: 10px;
}

.manual-note-form[hidden] {
  display: none;
}

#manual-note-input {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  padding: 11px 12px;
  border: none;
  border-radius: 14px;
  background: oklch(1 0 0 / 0.08);
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.1);
  color: oklch(1 0 0 / 0.9);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
}

#manual-note-input::placeholder {
  color: oklch(1 0 0 / 0.32);
}

#manual-note-input:focus {
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.22), 0 0 0 3px oklch(1 0 0 / 0.08);
}

.manual-note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.manual-note-button {
  min-height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  transition-property: background, color, transform, opacity;
  transition-duration: 0.16s;
  transition-timing-function: ease-out;
}

.manual-note-button:disabled,
.manual-note-edit:disabled {
  opacity: 0.42;
  cursor: default;
}

.manual-note-button.primary {
  background: oklch(1 0 0 / 0.9);
  color: oklch(0.145 0 0);
}

.manual-note-button.secondary {
  background: oklch(1 0 0 / 0.08);
  color: oklch(1 0 0 / 0.62);
}

.manual-note-button:not(:disabled):active {
  transform: scale(0.96);
}

.manual-note-status {
  min-height: 14px;
  margin: 8px 0 0;
  color: oklch(1 0 0 / 0.36);
  font-size: 12px;
  line-height: 1.2;
}

.manual-note-status.error {
  color: oklch(0.74 0.16 28);
}

.lightbox-sidebar-footer {
  margin-top: 26px;
  margin-bottom: 10px;
}

.lightbox-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 20px;
}

.lightbox-tags:empty {
  display: none;
}

.lightbox-tag {
  padding: 3px 10px;
  background: oklch(1 0 0 / 0.08);
  border: none;
  border-radius: 100px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1);
  color: oklch(1 0 0 / 0.6);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.lightbox-stats {
  display: flex;
  gap: 22px;
  justify-content: flex-start;
  margin-top: 2px;
}

.lightbox-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  color: oklch(1 0 0 / 0.35);
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

.lightbox-stat svg {
  opacity: 0.6;
}

@media (max-width: 520px) {
  .lightbox-overlay {
    background: oklch(0 0 0 / 0.68);
  }

  .lightbox-info {
    top: auto;
    right: calc(12px + var(--safe-right));
    bottom: calc(12px + var(--safe-bottom));
    left: calc(12px + var(--safe-left));
    width: auto;
    min-width: 0;
    max-height: min(43dvh, 360px);
    padding: 26px 22px 24px;
    border-radius: 24px;
    box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1);
    transform: translateY(18px);
  }

  .lightbox-controls {
    gap: 10px;
    margin-bottom: 18px;
  }

  .lightbox-nav-controls {
    gap: 8px;
  }

  .lightbox-overlay.active .lightbox-info {
    transform: translateY(0);
  }

  .lightbox-panel-copy {
    margin-bottom: 18px;
  }

  .lightbox-title {
    font-size: 18px;
    line-height: 1.2;
  }

  .lightbox-author-row {
    margin-top: 12px;
  }

  .lightbox-description {
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.36;
  }

  .lightbox-meta-list {
    margin-bottom: 18px;
  }

  .lightbox-meta-row {
    grid-template-columns: minmax(86px, 0.75fr) minmax(0, 1.25fr);
    gap: 14px;
    padding: 10px 0;
  }

  .lightbox-visible-section,
  .lightbox-tags {
    display: none;
  }

  .manual-note-section {
    margin-bottom: 16px;
    padding-top: 12px;
  }

  #manual-note-input {
    min-height: 92px;
  }
}

.grid-item.lightbox-active {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 101;
  pointer-events: none;
  overflow: hidden;
  border-radius: 8px;
  transform-origin: top left;
}

.grid-item.lightbox-active img {
  pointer-events: none;
}

.play-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 12px 16px;
  border-radius: 100px;
  background: oklch(0 0 0 / 0.45);
  backdrop-filter: blur(12px);
  border: none;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.13);
  transition-property: background, box-shadow, opacity, transform;
  transition-duration: 0.2s;
  transition-timing-function: ease;
  color: oklch(1 0 0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.9);
}

.play-pill.visible {
  opacity: 1;
  transform: scale(1);
}

.play-pill-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  filter: invert(1);
}

.lightbox-play-btn:hover .play-pill {
  background: oklch(0 0 0 / 0.6);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.2);
}

.lightbox-play-btn:active .play-pill.visible {
  transform: scale(0.96);
}

/* --- Author Filter --- */

.author-filter-pill {
  position: fixed;
  top: calc(86px + var(--safe-top));
  right: calc(24px + var(--safe-right));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: min(280px, calc(100vw - 180px));
  min-height: 40px;
  padding: 10px 16px;
  background: oklch(0 0 0 / 0.55);
  border: none;
  border-radius: 100px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1);
  color: oklch(1 0 0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition-property: background, box-shadow, scale;
  transition-duration: 0.2s, 0.2s, 0.15s;
  transition-timing-function: ease-out;
  user-select: none;
}

.author-filter-pill:hover {
  background: oklch(0 0 0 / 0.7);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.15);
}

.author-filter-pill-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-filter-pill[hidden] {
  display: none;
}

#author-filter-pill-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-hud {
  position: fixed;
  right: calc(24px + var(--safe-right));
  bottom: calc(24px + var(--safe-bottom));
  z-index: 60;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 16px;
  background: oklch(0 0 0 / 0.72);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.12);
  backdrop-filter: blur(12px);
  color: oklch(1 0 0 / 0.86);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.debug-hud.visible {
  opacity: 1;
  transform: translateY(0);
}

.debug-hud.warning {
  background: oklch(0.22 0.02 75 / 0.88);
  box-shadow: 0 0 0 1px oklch(0.78 0.16 75 / 0.75);
}

.debug-status {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: oklch(0.68 0.14 145 / 0.22);
  color: oklch(0.9 0.12 145);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.debug-hud.warning .debug-status {
  background: oklch(0.78 0.16 75 / 0.22);
  color: oklch(0.9 0.11 75);
}

.author-filter-pill:active {
  scale: 0.96;
}

/* --- Focus-visible --- */

.lightbox-control-button:focus-visible,
.manual-note-button:focus-visible,
.manual-note-edit:focus-visible,
.clip-add-button:focus-visible,
.board-create-button:focus-visible,
.clip-close:focus-visible,
.clip-button:focus-visible,
.board-header-actions button:focus-visible,
.board-selection-item:focus-within,
.grid-author-pill:focus-visible,
.filter-chip:focus-visible,
.author-filter-pill:focus-visible {
  outline: 2px solid oklch(1 0 0 / 0.6);
  outline-offset: 2px;
}

/* --- Reduced Motion --- */

@media (max-width: 900px) {
  .design-topbar {
    top: calc(12px + var(--safe-top));
    left: 0;
    right: 0;
  }

  .design-topbar::before,
  .design-topbar::after {
    width: 58px;
  }

  .filter-scroll {
    min-width: 0;
    padding-inline: calc(12px + var(--safe-left)) calc(72px + var(--safe-right));
    scroll-padding-inline: calc(12px + var(--safe-left)) calc(72px + var(--safe-right));
  }

  .filter-chips {
    gap: 4px;
  }

  .filter-chip {
    padding: 12px 18px;
  }

  .search-bar {
    bottom: calc(12px + var(--safe-bottom));
    width: min(420px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  }

  .search-bar:focus-within {
    width: min(420px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  }

  .clip-add-button {
    right: calc(12px + var(--safe-right));
    bottom: calc(68px + var(--safe-bottom));
    left: auto;
  }

  .board-create-button {
    right: calc(64px + var(--safe-right));
    bottom: calc(68px + var(--safe-bottom));
    left: auto;
  }

  .board-header {
    top: calc(64px + var(--safe-top));
    left: 0;
    right: 0;
    padding-right: calc(14px + var(--safe-right));
    padding-left: calc(14px + var(--safe-left));
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .board-header-name {
    max-width: calc(100vw - 28px);
    font-size: 14px;
  }

  .board-header-actions {
    gap: 3px;
    width: 100%;
  }

  .board-header-actions button {
    min-width: 0;
    min-height: 32px;
    flex: 1 1 0;
    padding: 0 6px;
    font-size: 11px;
  }

  .board-unavailable-repairs {
    top: calc(180px + var(--safe-top));
    right: calc(14px + var(--safe-right));
    width: min(360px, calc(100vw - 28px - var(--safe-left) - var(--safe-right)));
    max-height: min(40dvh, 320px);
  }

  .grid-author-pill {
    bottom: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    font-size: 12px;
  }

  .grid-author-avatar {
    width: 24px;
    height: 24px;
  }

  .grid-author-label {
    height: 24px;
    padding: 0 10px;
  }

  .author-filter-pill {
    top: calc(64px + var(--safe-top));
    right: calc(14px + var(--safe-right));
    max-width: calc(100vw - 32px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
