*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg: #f9f9f7;
    --fg: #111;
    --border: #ccc;
    --tag-active-bg: #111;
    --tag-active-fg: #f9f9f7;
    --col-width: 216px;
    --font: 'Overpass Mono', 'Courier New', monospace;
    --transition: 0.35s ease;
    --sb-w: 12px;
    --bar-h: 20px;
  }

  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 11px;
  }

  /* ── SIDEBAR ── */
  #sidebar {
    width: var(--col-width);
    height: 100vh;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    flex-shrink: 0;
    overflow: hidden;
  }

  #site-title { font-size: 10px; word-break: break-all; margin-bottom: 12px; text-align: center; }
  #site-title a { color: var(--fg); text-decoration: none; }
  #site-title a:hover { text-decoration: underline; }

  #media-frame {
    width: 100%; aspect-ratio: 1/1;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    background: #eee;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: #999;
    position: relative;
  }

  #media-frame-lock {
    position: absolute;
    bottom: 6px;
    right: 6px;
    pointer-events: none;
  }

  #nav a.nav-locked {
    color: #bbb;
    cursor: default;
  }
  #nav a.nav-locked:hover { text-decoration: none; }

  #nav { display: flex; flex-direction: column; gap: 10px; }
  #nav a { color: var(--fg); text-decoration: none; font-size: 11px; letter-spacing: 0.05em; }
  #nav a:hover, #nav a.active { text-decoration: underline; }

  /* ── MAIN ── */
  #content { flex: 1; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

  /* ── CONTROLS ── */
  #controls {
    padding: 10px 16px;
    display: flex; flex-direction: column; gap: 8px;
    flex-shrink: 0;
    position: relative;
  }

  #controls::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 0;
    height: 1px;
    background: var(--border);
  }

  #search-bar input {
    width: 100%; font-family: var(--font); font-size: 11px;
    border: 1px solid var(--border); padding: 4px 8px;
    background: var(--bg); color: var(--fg); outline: none;
  }
  #search-bar input:focus { border-color: var(--fg); }

  #scalar-row { display: flex; align-items: center; gap: 8px; }

  .scale-icon {
    cursor: pointer; padding: 3px;
    border: 1px solid transparent; user-select: none;
    display: flex; align-items: center; justify-content: center;
    border-radius: 1px;
  }
  .scale-icon:hover { border-color: var(--border); }
  .scale-icon.active { border-color: var(--fg); }

  .dot-grid circle {
    fill: #aaa;
  }
  .scale-icon.active .dot-grid circle,
  .scale-icon:hover .dot-grid circle {
    fill: var(--fg);
  }

  /* Slider styled like the card scrollbar track */
  #scale-slider-wrap {
    flex: 1; height: 14px;
    display: flex; align-items: center;
    position: relative;
    margin-left: 1em; /* ~2 spaces extra gap from rightmost icon */
  }

  .scale-arrow-btn {
    font-size: 6px;
    color: var(--fg);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    padding: 0 3px;
    line-height: 1;
  }
  .scale-arrow-btn:hover { color: var(--fg); }

  #scale-track {
    flex: 1; height: 1px;
    background: var(--border);
    position: relative;
    cursor: pointer;
    align-self: center;
  }

  #scale-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--fg);
    cursor: grab;
    box-sizing: border-box;
  }
  #scale-thumb:hover { border-width: 1.5px; }
  #scale-thumb:active { cursor: grabbing; }

  /* Hide native range input — replaced by custom track */
  #scale-slider { display: none; }

  /* ── HASHTAG BAR ── */
  #hashtag-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    padding: 2px 0;
    font-size: 9.5px;
  }

  .tag {
    cursor: pointer;
    user-select: none;
    padding: 1px 4px;
    font-family: var(--font);
    font-size: 9.5px;
    color: rgb(115, 115, 115);
    background: transparent;
    transition: background 0.1s, font-weight 0.1s, color 0.1s;
  }
  .tag:hover { color: var(--fg); }
  .tag.active {
    background: transparent;
    font-weight: 700;
    color: var(--fg);
    -webkit-text-stroke: 0.4px var(--fg);
  }

  .prose-discipline.inactive:hover { color: var(--fg); opacity: 1; }

  /* Each row: [child-zone?] [pill] — consistent at every level */
  .sq-row {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0;
    position: relative;
  }

  .prose-discipline-wrap:hover .sq-pill,
  .prose-discipline-wrap.open .sq-pill {
    opacity: 1;
    pointer-events: all;
  }

  .sq-pill.selected {
    color: var(--fg);
    font-weight: 600;
    opacity: 1;
    pointer-events: all;
  }

  /* ── GALLERY ── */
  #gallery {
    flex: 1; overflow-x: auto; overflow-y: hidden;
    padding: 12px 12px 0 12px; min-height: 0;
    scrollbar-width: none;
  }
  #gallery::-webkit-scrollbar { display: none; }

  #gallery-inner {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 8px;
    height: 100%;
    width: max-content;
    align-content: start;
  }

  /* ── CARD ── */
  .card {
    border: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
    cursor: pointer;
    /* box-shadow: 4px 4px 6px rgba(0,0,0,0.15); */
  }

  /* Fixed title */
  .card-title {
    font-size: 11px;
    font-weight: 400;
  }

  .scale-4 .card-title {
    font-weight: 400;
    padding-left: 6px;
    background: #fff;
  }

  .scale-4 .card-tags {
    background: #fff;
  }

  /* Fixed title */
  .card-title {
    height: var(--bar-h); line-height: var(--bar-h); padding: 0 6px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex-shrink: 0;
    background: var(--bg);
    z-index: 2;
    position: relative;
    user-select: none;
  }

  /* Scrollable zone */
  .card-scroll-zone {
    flex: 1; overflow: hidden;
    position: relative; min-height: 0;
  }

  /* Moving content */
  .card-scroll-content {
    position: absolute;
    top: 0;
    left: var(--sb-w);
    right: var(--sb-w);
    padding-bottom: 0;
  }

  .card-image {
    width: 100%; flex-shrink: 0;
    background: #ddd;
    display: flex; align-items: center; justify-content: center;
    color: #999; overflow: hidden;
    margin-top: var(--sb-w);
    font-size: 9px;
  }
  .card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .scale-1 .card-image,
  .scale-2 .card-image,
  .scale-3 .card-image { margin-top: 0; }
  .scale-4 .card-image {
    padding: 3px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    background: white;
  }
  .scale-4 .card-summary-sheet { margin-top: 0; border-top: none; }
  .card-image-cell {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    padding: 3px;
    box-sizing: border-box;
  }

  .card-image-cell .card-image {
    margin: 0 !important;
    width: 100%;
  }

  /* Summary — shown at scale 3, clipped with ellipsis */
  .card-summary {
    font-size: 9px;
    color: rgb(35, 35, 35);
    padding: 5px 8px 5px;
    line-height: 1.45;
    flex-shrink: 0;
    display: none;
    overflow: hidden;
    -webkit-box-orient: vertical;
    background: white;
    border-radius: 0;
    border: 1px solid var(--border);
    margin-top: 3px;
  }

  .card-summary-sheet {
    display: none;
    grid-template-columns: 115px 1fr;
    grid-auto-rows: auto;
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    margin-top: 3px;
  }

  .card-summary-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    height: var(--bar-h);
    padding: 0 5px;
    font-size: 9px;
    display: flex; align-items: center;
  }

  .card-summary-label {
    color: rgb(140, 140, 140);
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
  }

  .card-summary-value {
    color: rgb(35, 35, 35);
  }

  .card-summary-link {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .card-summary-link:hover { color: rgb(0, 0, 0); }

  .card-content {
    display: none;
    flex-shrink: 0;
    padding-top: var(--bar-h);
    padding-bottom: var(--bar-h);
  }

  .content-group-sep {
    height: var(--bar-h);
  }

  .content-group {
    margin-top: 0;
  }

  /* ── MATRIX MODULE ── */
  .content-matrix {
    border: 1px solid var(--border);
  }

  .matrix-grid-wrap {
    padding: 3px;
  }

  .matrix-grid {
    display: grid;
    gap: 12px;
    background: black;
    padding: 12px;
  }

  .matrix-img {
    width: 100%;
    height: auto;
    display: block;
  }

  .matrix-caption-bar {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-size: 9px;
    color: rgb(140, 140, 140);
    border-top: 1px solid var(--border);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* ── SLIDESHOW MODULE ── */
  .content-slideshow {
    border: 1px solid var(--border);
  }

  .slideshow-img {
    width: 100%;
    display: block;
  }

  .slideshow-caption-bar {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-size: 9px;
    color: rgb(140, 140, 140);
    border-top: 1px solid var(--border);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* ── CAROUSEL MODULE ── */
  .content-carousel-module {
    border: 1px solid var(--border);
  }

  .carousel-module-img-area {
    aspect-ratio: 16 / 9;
    overflow: hidden;
    padding: 3px;
  }

  .carousel-module-img-area.strip {
    aspect-ratio: 5 / 1;
  }

  .carousel-module-img-area.square {
    aspect-ratio: 1 / 1;
  }

  .carousel-module-img-area.square .carousel-module-img {
    aspect-ratio: 1 / 1;
    width: auto;
    object-fit: cover;
  }

  .carousel-module-track {
    display: flex;
    height: 100%;
    animation: carousel-module-pan 20s linear infinite;
  }

  .carousel-module-img {
    height: 100%;
    width: auto;
    flex-shrink: 0;
    display: block;
  }

  .carousel-caption-bar {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-size: 9px;
    color: rgb(140, 140, 140);
    border-top: 1px solid var(--border);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  @keyframes carousel-module-pan {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
  }

  /* ── MONO MODULE ── */
  .content-mono {
    border: 1px solid var(--border);
  }

  .module-img-pad {
    padding: 3px;
    line-height: 0;
  }

  .module-img-pad.square {
    aspect-ratio: 1 / 1;
    overflow: hidden;
  }

  .module-img-pad.square img {
    height: 100%;
    object-fit: cover;
  }

  .img-overlay-wrap {
    position: relative;
    line-height: 0;
  }

  .img-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
  }

  .module-img-pad img,
  .module-img-pad video {
    width: 100%;
    display: block;
    transform: translateZ(0);
  }

  .module-img-pad video {
    clip-path: inset(0 1px 1px 0);
  }

  .module-meta-sheet {
    display: grid;
    grid-template-columns: 115px 1fr;
    border-top: 1px solid var(--border);
  }

  .module-meta-cell {
    height: var(--bar-h);
    padding: 0 5px;
    font-size: 9px;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .module-meta-label {
    color: rgb(140, 140, 140);
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
  }

  .module-meta-value {
    color: rgb(35, 35, 35);
    border-right: none;
  }

  .module-meta-cell:nth-last-child(-n+2) {
    border-bottom: none;
  }

  .module-title-bar {
    height: var(--bar-h);
    line-height: var(--bar-h);
    padding: 0 8px;
    font-size: 11px;
    color: rgb(35, 35, 35);
    border-bottom: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
  }

  .content-mono-text {
    padding: 8px;
    font-size: 11px;
    line-height: 1.6;
    color: rgb(35, 35, 35);
    white-space: pre-wrap;
  }

  .has-figure {
    position: relative;
  }
  .figure-label {
    position: absolute;
    left: 5px;
    font-size: 9px;
    color: rgb(140, 140, 140);
    white-space: nowrap;
    pointer-events: none;
  }

  .toc-module {
    display: grid;
    grid-template-columns: 115px 1fr;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
  }

  .toc-header {
    grid-column: 1 / -1;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: rgb(35, 35, 35);
  }

  .toc-col-label {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    padding: 0 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: rgb(140, 140, 140);
    text-transform: uppercase;
  }

  .toc-row-num,
  .toc-row-caption {
    min-height: var(--bar-h);
    display: flex;
    align-items: center;
    padding: 0 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: rgb(35, 35, 35);
    cursor: pointer;
  }

  .toc-row-num:hover,
  .toc-row-caption:hover {
    background: #f5f5f5;
  }

  .mono-citation-bar {
    display: grid;
    grid-template-columns: 115px 1fr;
  }

  .mono-citation-label {
    min-height: var(--bar-h);
    display: flex;
    align-items: center;
    padding: 0 6px;
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    color: rgb(140, 140, 140);
    text-transform: uppercase;
    font-size: 9px;
  }

  .mono-citation-text {
    min-height: var(--bar-h);
    display: flex;
    align-items: center;
    padding: 0 6px;
    border-top: 1px solid var(--border);
    color: rgb(140, 140, 140);
    font-size: 9px;
  }

  .mono-citation-link {
    color: inherit;
    text-decoration: none;
  }
  .mono-citation-link:hover { text-decoration: underline; }

  .mono-caption-bar {
    min-height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3px 5px;
    font-size: 9px;
    color: rgb(140, 140, 140);
    border-top: 1px solid var(--border);
    white-space: pre-line;
    flex-shrink: 0;
  }
  .mono-caption-bar--multiline {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    padding: 4px 5px;
    gap: 1px;
  }

  /* ── DIPTYCH / TRIPTYCH MODULE ── */
  .content-triptych {
    display: flex;
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
  }

  .content-diptych {
    display: flex;
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
  }

  .diptych-col {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
  }

  .diptych-col-img-area {
    flex: 1;
    overflow: hidden;
  }

  .diptych-col-text {
    flex: 1;
    padding: 8px;
    font-size: 11px;
    line-height: 1.6;
    color: rgb(35, 35, 35);
    white-space: pre-wrap;
    min-width: 0;
  }

  .diptych-caption-bar {
    flex-shrink: 0;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-size: 9px;
    color: rgb(140, 140, 140);
    border-top: 1px solid var(--border);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* ── CONTENT SPREADSHEET ── */

  /* All content blocks share a single continuous border system */
  .content-sheet-block {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  /* Empty separator row */
  .content-sheet-sep {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-height: 18px;
  }

  /* Image inside a cell: 3px inset on all sides */
  .content-image-cell {
    padding: 3px;
    display: flex;
    flex-direction: column;
  }

  .content-image-cell .content-image {
    margin: 0;
    display: block;
    width: 100%;
  }

  .content-image-caption-row {
    border-top: 1px solid var(--border);
    font-size: 9px;
    color: rgb(140, 140, 140);
    padding: 3px 5px 1px;
    line-height: 1.4;
    margin: 3px -3px -3px;
    text-transform: lowercase;
  }

  /* Columns block */
  .content-columns {
    display: flex;
    gap: 0;
    align-items: flex-start;
  }

  .content-column {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border);
  }

  .content-column:last-child { border-right: none; }

  .content-column .content-image-cell {
    padding: 3px;
  }

  .content-column .content-image-cell .content-image {
    display: block;
    width: 100%;
  }

  .content-column .content-text {
    padding: 5px;
    font-size: 10px;
    line-height: 1.6;
  }

  /* Carousel */
  .content-carousel { overflow: visible; }

  .content-carousel-inner {
    padding: 3px;
    overflow: hidden;
  }

  .content-carousel-caption-row {
    border-top: 1px solid var(--border);
    font-size: 9px;
    color: rgb(140, 140, 140);
    padding: 3px 5px 1px;
    line-height: 1.4;
    text-transform: lowercase;
  }

  .content-carousel-track {
    display: flex;
    animation: carousel-pan 40s linear infinite;
    width: max-content;
  }

  .content-carousel-img {
    width: auto;
    flex-shrink: 0;
    display: block;
  }

  /* Plain text block */
  .content-text {
    font-size: 10px;
    padding: 5px;
    line-height: 1.6;
  }

  @keyframes carousel-pan {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
  }

  .content-text-old-remove {
    font-size: 10px;
    padding: 8px 0 6px;
    line-height: 1.6;
  }

  .content-image {
    width: 100%;
    display: block;
    margin: 8px 0;
  }

  .content-figure {
    margin: 8px 0;
  }

  .content-caption {
    font-size: 9px;
    color: #999;
    padding-top: 3px;
    line-height: 1.4;
  }

  /* Fixed tags — single row, clips right, expands into thumbnail on hover */
  .card-tags {
    height: var(--bar-h); padding: 0 6px;
    display: flex; flex-wrap: nowrap; align-items: center;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg);
    z-index: 10;
    position: relative;
    overflow: hidden;
  }

  /* Only expand if JS has detected overflow and added .tags-overflow */
  .card.tags-overflow:hover .card-tags {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: calc(2 * var(--bar-h));
    padding: 5px 6px;
    flex-wrap: wrap;
    row-gap: 10px;
    background: var(--bg);
    z-index: 2;
  }

  .card-tag {
    color: #666;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Comma trails the tag, so it stays on the same line when wrapping */
  .card-tag:not(:last-child)::after {
    content: ',';
    color: #aaa;
    margin-right: 0.3em;
  }

  /* ── ISOMETRIC DICE ── */
  #shuffle-btn svg { overflow: visible; }

  /* ── LOCK OVERLAY ── */
  .card-lock {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
  }
  .card-lock svg { opacity: 0.7; }
  .card.locked .card-image { filter: blur(6px); }
  .card.locked .card-description { filter: blur(6px); }
  .card.locked .card-summary { filter: blur(4px); }

  /* ── PASSWORD MODAL ── */
  #pw-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    align-items: center; justify-content: center;
  }
  #pw-modal.open { display: flex; }

  #pw-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.18);
  }

  #pw-box {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 20px 24px;
    display: flex; flex-direction: column; gap: 10px;
    min-width: 220px;
    font-family: var(--font);
    font-size: 11px;
    z-index: 1;
  }

  #pw-box input {
    font-family: var(--font);
    font-size: 11px;
    border: 1px solid var(--border);
    padding: 4px 8px;
    background: var(--bg);
    color: var(--fg);
    outline: none;
    width: 100%;
  }
  #pw-box input:focus { border-color: var(--fg); }

  #pw-error {
    font-size: 10px;
    color: #c00;
    display: none;
  }

  #pw-actions {
    display: flex; gap: 8px; justify-content: flex-end;
  }

  #pw-actions button {
    font-family: var(--font);
    font-size: 10px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    color: var(--fg);
  }
  #pw-actions button:hover { border-color: var(--fg); }
  #pw-submit { border-color: var(--fg) !important; }

  /* ── ABOUT PAGE ── */
  #about-page {
    display: none;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
  }

  #about-page.visible {
    display: flex;
  }

  #about-tabs {
    padding: 16px 16px 10px;
    display: flex;
    gap: 20px;
    flex-shrink: 0;
    position: relative;
  }

  #about-tabs::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 0;
    height: 1px;
    background: var(--border);
  }

  .about-tab {
    font-family: var(--font);
    font-size: 11px;
    cursor: pointer;
    color: #999;
    user-select: none;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
  }

  .about-tab:hover { color: var(--fg); }
  .about-tab.tab-disabled { color: #bbb; cursor: default; pointer-events: none; }

  .about-tab.active {
    color: var(--fg);
    border-bottom: 1px solid var(--fg);
  }

  #about-date-bar {
    padding: 6px 16px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    position: relative;
  }

  .date-tag {
    font-family: var(--font);
    font-size: 10px;
    padding: 2px 5px;
    border: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), color var(--transition);
  }
  .date-tag:hover { border-color: var(--fg); }
  .date-tag.active {
    background: var(--tag-active-bg);
    color: var(--tag-active-fg);
    border-color: var(--tag-active-bg);
  }

  #about-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;   /* top padding set by JS alignment */
    max-width: 640px;
    font-size: 11px;
    line-height: 1;    /* reset — individual elements set their own */
    color: var(--fg);
  }

  .about-entry {
    margin-bottom: 24px;
    padding-bottom: 24px;
  }

  .about-entry-date {
    font-size: 10px;
    line-height: 1;    /* match nav link rendering */
    color: #999;
    display: block;
    /* margin-bottom set by JS to space text to ARCHIVE link level */
  }

  .about-entry-text {
    white-space: pre-wrap;
    font-size: 11px;
    line-height: 1.8;
    display: block;
  }

  .about-entry-locked {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #999;
    font-size: 10px;
  }

  /* ── CONTACT PAGE ── */
  #contact-page {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  #contact-page.visible { display: flex; }

  #contact-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .contact-item {
    font-family: var(--font);
    font-size: 11px;
    color: var(--fg);
    text-decoration: none;
  }

  .contact-item:hover { text-decoration: underline; }

  /* ── ABOUT FOOTER ── */
  #about-footer {
    flex-shrink: 0;
    padding: 8px 16px 12px;
    font-size: 10px;
    color: #999;
    font-family: var(--font);
  }

  /* ── LIST MODE ── */
  #list-controls {
    display: flex; align-items: center; gap: 8px;
  }

  #list-btn {
    font-family: var(--font);
    font-size: 10px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: #999;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
  }
  #list-btn:hover { border-color: var(--fg); color: var(--fg); }
  #list-btn.active { border-color: var(--fg); color: var(--fg); background: var(--fg); color: var(--bg); }

  #list-copied {
    font-size: 10px;
    color: #999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
  }
  #list-copied.show { opacity: 1; }

  /* ── LIST MODE ── */
  #search-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  #search-bar { flex: 1; }

  #list-select-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    white-space: nowrap;
    font-size: 9px;
    background: var(--fg);
    color: var(--bg);
    padding: 2px 6px;
    pointer-events: none;
    z-index: 20;
  }
  #list-select-btn { position: relative; }

  #list-select-btn, #list-cancel-btn, #list-complete-btn {
    font-family: var(--font);
    font-size: 10px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
  }
  #list-select-btn:hover, #list-cancel-btn:hover, #list-complete-btn:hover { border-color: var(--fg); }
  #list-select-btn.active {
    background: var(--tag-active-bg);
    color: var(--tag-active-fg);
    border-color: var(--tag-active-bg);
  }
  #list-complete-btn {
    border-color: var(--fg);
  }

  /* Sequence number badge — square, right side of title bar, 3px margin */
  .card-seq {
    position: absolute;
    top: 3px;
    right: 3px;
    width: calc(var(--title-h, 22px) - 6px);
    height: calc(var(--title-h, 22px) - 6px);
    font-size: 8px;
    font-family: var(--font);
    background: var(--fg);
    color: var(--bg);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: 2px solid white;
  }

  /* List meta bar */
  #list-meta-bar {
    display: none;
    padding: 4px 0;
    font-size: 10px;
    color: #666;
    align-items: center;
    gap: 12px;
  }

  #list-meta-bar.visible { display: flex; }

  #list-copy-btn {
    font-family: var(--font);
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    cursor: pointer;
    flex-shrink: 0;
  }
  #list-copy-btn:hover { border-color: var(--fg); }
  #list-copy-btn.copied { color: #999; }

  /* ── SIDEBAR LEGAL LINK ── */
  #nav-legal-wrap {
    margin-top: auto;
    padding-top: 16px;
  }

  #nav-legal-wrap a {
    color: #999;
    text-decoration: none;
    font-size: 10px;
    font-family: var(--font);
    letter-spacing: 0.05em;
  }
  #nav-legal-wrap a:hover,
  #nav-legal-wrap a.active { color: var(--fg); text-decoration: underline; }

  /* ── LEGAL PAGE ── */
  #legal-page {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  #legal-page.visible { display: flex; }

  #legal-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px;
    max-width: 640px;
    font-size: 11px;
    line-height: 1.8;
    color: var(--fg);
  }

  .legal-section {
    margin-bottom: 24px;
  }

  .legal-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    color: #999;
  }

  /* ── PROSE SCROLL BAR ── */
  #prose-scroll-wrap {
    display: none; /* shown by JS when prose overflows */
    align-items: center;
    gap: 0;
    height: 0;           /* sits on the border line */
    position: relative;
    margin-top: -1px;    /* centre on the controls bottom border */
    z-index: 5;
  }

  #prose-scroll-wrap.visible { display: flex; }

  .prose-scroll-btn {
    font-size: 6px;
    color: var(--fg);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    line-height: 1;
    padding: 0 3px;
  }
  .prose-scroll-btn:hover { color: var(--fg); }

  #prose-scroll-track {
    flex: 1;
    height: 1px;
    background: var(--border);
    position: relative;
  }

  #prose-scroll-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    cursor: grab;
    border: 1px solid var(--fg);
    box-sizing: border-box;
  }
  #prose-scroll-thumb:hover { border-width: 1.5px; }
  #prose-scroll-thumb:active { cursor: grabbing; }

  /* ── UPDATED CARD SCROLLBAR ── */
  .card-scrollbar {
    position: absolute;
    top: 0; right: 0;
    width: var(--sb-w);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent; /* superimposed, no background */
    border-left: none;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    user-select: none;
  }

  .card-scrollbar.visible {
    opacity: 1;
    pointer-events: all;
  }

  .sb-btn {
    width: 100%;
    flex-shrink: 0;
    height: var(--sb-w);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    color: var(--fg);
    font-size: 6px;
    line-height: 1;
    border: none;
  }
  .sb-btn:first-child { padding-top: 3px; }
  .sb-btn:last-child  { padding-bottom: 3px; }
  .sb-btn:hover { color: var(--fg); }

  .sb-track {
    flex: 1;
    position: relative;
    width: 1px;
    background: transparent; /* card right border IS the rail */
    margin: 2px 0;
  }

  .sb-thumb {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--fg);
    cursor: grab;
    display: none;
    box-sizing: border-box;
  }
  .sb-thumb:hover { border-width: 1.5px; }
  .sb-thumb:active { cursor: grabbing; }

  /* ── GALLERY SCROLLBAR ── */
  #gallery-scroll-wrap {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 12px;
    flex-shrink: 0;
    visibility: hidden;
    pointer-events: none;
  }
  #gallery-scroll-wrap.visible {
    visibility: visible;
    pointer-events: auto;
  }

  .gallery-scroll-btn {
    font-size: 6px;
    color: var(--fg);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    padding: 0 3px;
    line-height: 1;
  }
  .gallery-scroll-btn:hover { color: var(--fg); }

  #gallery-scroll-track {
    flex: 1;
    height: 1px;
    background: var(--border);
    position: relative;
  }

  #gallery-scroll-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--fg);
    cursor: grab;
    box-sizing: border-box;
  }
  #gallery-scroll-thumb:hover { border-width: 1.5px; }
  #gallery-scroll-thumb:active { cursor: grabbing; }

  /* ── LIST MODE HINT OVERLAY ── */
  #list-hint-overlay {
    position: fixed;
    pointer-events: none;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s;
  }
  #list-hint-overlay.visible { opacity: 1; }
  #list-hint-overlay svg {
    width: 36px;
    height: 36px;
    display: block;
    filter: drop-shadow(0 0 0 black);
  }
  #list-hint-text {
    font-family: var(--font);
    font-size: 10px;
    background: white;
    color: black;
    padding: 3px 8px;
    white-space: nowrap;
    border: 1px solid black;
    order: -1; /* text above icon */
  }

  /* ── CV PAGE ── */
  #cv-page {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  #cv-page.visible { display: flex; }

  #cv-header-wrap {
    padding: 10px 16px;
    flex-shrink: 0;
  }

  #cv-header {
    display: flex;
    flex-direction: row;
    border: 1px solid var(--border);
    gap: 0;
  }

  .cv-col {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-right: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #cv-header .cv-col:last-child { border-right: none; }

  .cv-col-year     { flex: 1; }
  .cv-col-title    { flex: 3; }
  .cv-col-location { flex: 3; }
  .cv-col-content  { flex: 1.5; }
  .cv-col-type     { flex: 1.5; }

  #cv-spacer {
    flex-shrink: 0;
    height: calc(11px * 1.6 + 10px);
  }

  #cv-body {
    overflow: hidden;
    padding: 0 16px;
  }

  .cv-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    gap: 0;
  }

  .cv-row:first-child {
    border-top: 1px solid var(--border);
  }

  .cv-row .cv-col {
    font-weight: 400;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    border-right: 1px solid var(--border) !important;
  }

  .cv-row .cv-col:last-child { border-right: none !important; }

  /* ── IMAGE LIGHTBOX ── */
  #summary-tooltip {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    display: none;
    max-width: 220px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-family: var(--font);
    font-size: 9px;
    color: rgb(35, 35, 35);
    line-height: 1.45;
    padding: 4px 6px;
  }

  #img-lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.18);
  }

  #img-lightbox.open { display: block; }

  #img-lightbox-inner {
    position: absolute;
    background: var(--bg);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #img-lightbox-title-bar {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 400;
    font-family: var(--font);
  }

  #img-lightbox-figure {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-right: 1px solid var(--border);
    color: rgb(140, 140, 140);
    white-space: nowrap;
    flex-shrink: 0;
  }

  #img-lightbox-title {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 4px 6px;
    text-transform: uppercase;
  }

  #img-lightbox-controls {
    display: flex;
    align-items: stretch;
    border-left: 1px solid var(--border);
  }

  #img-lightbox-prev,
  #img-lightbox-next,
  #img-lightbox-maximize,
  #img-lightbox-close {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    color: var(--fg);
    padding: 0 8px;
    border-right: 1px solid var(--border);
  }
  #img-lightbox-close { border-right: none; }
  #img-lightbox-prev:hover,
  #img-lightbox-next:hover,
  #img-lightbox-maximize:hover,
  #img-lightbox-close:hover { opacity: 0.6; }

  #img-lightbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    min-height: 0;
    overflow: hidden;
  }

  #img-lightbox-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }

  /* ── IMAGE GRID BLOCK ── */
  .content-image-grid-wrap {
    /* outer border handled by content-sheet-block */
  }

  .content-image-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
  }

  .content-image-grid-cell {
    aspect-ratio: 17 / 22;
    overflow: hidden;
    background: #ddd;
  }

  .content-image-grid-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }

  .content-info-sheet {
    display: grid;
    grid-template-columns: 115px 1fr;
    border-top: 1px solid var(--border);
  }

  .content-image-grid-wrap .content-image-caption-row {
    margin: 0;
  }

  .content-image-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
  }

  .content-image-grid-cell {
    aspect-ratio: 17 / 22;
    overflow: hidden;
    background: #ddd;
  }

  .content-image-grid-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }

  .content-info-sheet {
    display: grid;
    grid-template-columns: 115px 1fr;
    border-top: 1px solid var(--border);
  }

  .content-info-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-height: 18px;
    padding: 3px 5px 1px;
    font-size: 9px;
    line-height: 1.4;
  }

  .content-info-label {
    color: rgb(140, 140, 140);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .content-info-value {
    color: rgb(35, 35, 35);
  }

  /* ── EMPTY STATE ── */
  #empty-state {
    display: none; padding: 24px 16px;
    font-size: 11px; color: #999;
  }

  /* ── CANVAS NAV LINK ── */
  #nav-legal-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* ── CANVAS PAGE ── */
  #canvas-page {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  #canvas-page.visible { display: flex; }

  #canvas-top-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--bar-h);
  }

  .canvas-hdr-label {
    font-size: 9px;
    color: rgb(140,140,140);
    letter-spacing: 0.05em;
    flex-shrink: 0;
  }

  #canvas-preset-list {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow: hidden;
  }

  .canvas-preset-chip {
    font-family: var(--font);
    font-size: 9px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    color: #666;
    background: var(--bg);
    white-space: nowrap;
    flex-shrink: 0;
  }
  .canvas-preset-chip:hover { border-color: var(--fg); color: var(--fg); }
  .canvas-preset-chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

  #canvas-save-preset-btn {
    font-family: var(--font);
    font-size: 9px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    color: #999;
    background: var(--bg);
    flex-shrink: 0;
  }
  #canvas-save-preset-btn:hover { border-color: var(--fg); color: var(--fg); }

  #canvas-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* ── LEFT PANEL ── */
  #canvas-left {
    width: 192px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
  }
  #canvas-left::-webkit-scrollbar { display: none; }

  .canvas-section-hdr {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 9px;
    color: rgb(140,140,140);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 1;
  }
  .canvas-section-hdr[data-scope] {
    background: rgba(255, 210, 0, 0.12);
    color: rgb(160, 130, 0);
  }

  #canvas-project-sel {
    width: 100%;
    font-family: var(--font);
    font-size: 10px;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 4px 8px;
    background: var(--bg);
    color: var(--fg);
    outline: none;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
  }
  #canvas-project-sel:focus { background: #f2f2f0; }

  #canvas-image-browser {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    max-height: 260px;
    flex-shrink: 0;
    scrollbar-width: none;
  }
  #canvas-image-browser::-webkit-scrollbar { display: none; }

  .canvas-tree-folder {
    font-family: var(--font);
    font-size: 9px;
    color: #999;
    padding: 5px 8px 2px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    user-select: none;
  }

  .canvas-tree-file {
    font-family: var(--font);
    font-size: 9px;
    color: #666;
    padding: 2px 8px 2px 14px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
  }
  .canvas-tree-file:hover { background: #f2f2f0; color: var(--fg); }
  .canvas-tree-file.carousel-strip-selected { background: #f2f2f0; }
  .canvas-tree-file.in-use { color: var(--fg); }
  .canvas-tree-file.in-use .canvas-tree-conn { color: var(--fg); }

  .canvas-tree-conn {
    color: #ccc;
    flex-shrink: 0;
    margin-right: 3px;
    letter-spacing: 0;
  }

  /* ── CANVAS FILE HOVER PREVIEW ── */
  #canvas-file-preview {
    position: fixed;
    z-index: 3000;
    display: none;
    width: 200px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 3px;
    pointer-events: none;
    box-shadow: 2px 3px 10px rgba(0,0,0,0.14);
  }
  #canvas-file-preview img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* minimap */
  #canvas-minimap-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
  }
  #canvas-minimap {
    position: relative;
    border: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
  }
  .canvas-minimap-zone {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: 7px;
    color: #bbb;
    cursor: pointer;
    user-select: none;
  }
  .canvas-minimap-zone:hover { background: #f2f2f0; color: var(--fg); }
  .canvas-minimap-zone.active { background: var(--fg); color: var(--bg); }

  /* split buttons */
  #canvas-split-btns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .canvas-split-btn {
    font-family: var(--font);
    font-size: 8px;
    padding: 4px 2px;
    border: none;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    color: #999;
    cursor: pointer;
    letter-spacing: 0.02em;
    text-align: center;
  }
  .canvas-split-btn:nth-child(3),
  .canvas-split-btn:nth-child(6) { border-right: none; }
  .canvas-split-btn:nth-child(4),
  .canvas-split-btn:nth-child(5),
  .canvas-split-btn:nth-child(6) { border-bottom: none; }
  .canvas-split-btn:hover { color: var(--fg); background: #f2f2f0; }

  /* merge row */
  #canvas-merge-row {
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  #canvas-merge-btn {
    width: 100%;
    font-family: var(--font);
    font-size: 8px;
    padding: 4px;
    border: none;
    background: var(--bg);
    color: #999;
    cursor: pointer;
    letter-spacing: 0.02em;
  }
  #canvas-merge-btn:hover:not(:disabled) { color: var(--fg); background: #f2f2f0; }
  #canvas-merge-btn:disabled { opacity: 0.3; cursor: default; }

  /* slot tabs */
  #canvas-slot-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .canvas-slot-tab {
    flex: 1;
    font-family: var(--font);
    font-size: 8px;
    padding: 4px 2px;
    border: none;
    border-right: 1px solid var(--border);
    background: var(--bg);
    color: #999;
    cursor: pointer;
  }
  .canvas-slot-tab:last-child { border-right: none; }
  .canvas-slot-tab:hover { color: var(--fg); background: #f2f2f0; }
  .canvas-slot-tab.active { color: var(--fg); font-weight: 600; }

  /* reset row */
  #canvas-reset-row {
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  #canvas-reset-btn {
    width: 100%;
    font-family: var(--font);
    font-size: 8px;
    padding: 4px;
    border: none;
    background: var(--bg);
    color: #999;
    cursor: pointer;
    letter-spacing: 0.02em;
  }
  #canvas-reset-btn:hover { color: var(--fg); background: #f2f2f0; }

  /* slot bg btns */
  #cp-slot-bg-btns {
    display: flex;
    flex: 1;
    gap: 2px;
  }

  .canvas-param-row {
    display: flex;
    align-items: center;
    height: var(--bar-h);
    padding: 0 8px;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .canvas-param-row--auto { height: auto; padding: 4px 8px; }

  .canvas-param-label {
    font-size: 8px;
    color: rgb(140,140,140);
    letter-spacing: 0.04em;
    flex-shrink: 0;
    width: 48px;
  }

  .canvas-param-row input[type="range"] {
    flex: 1;
    accent-color: var(--fg);
    cursor: pointer;
    height: 2px;
  }

  .canvas-param-val {
    font-size: 8px;
    color: #888;
    flex-shrink: 0;
    width: 22px;
    text-align: right;
  }

  #cp-bg-btns, .canvas-slot-bg-wrap {
    display: flex;
    flex: 1;
    gap: 2px;
  }

  .canvas-bg-btn, .canvas-fmt-btn, .canvas-scale-btn, .canvas-slot-bg-btn {
    flex: 1;
    font-family: var(--font);
    font-size: 8px;
    padding: 2px 3px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: #999;
    cursor: pointer;
  }
  .canvas-bg-btn:hover, .canvas-fmt-btn:hover, .canvas-scale-btn:hover, .canvas-slot-bg-btn:hover {
    border-color: var(--fg); color: var(--fg);
  }
  .canvas-bg-btn.active, .canvas-fmt-btn.active, .canvas-scale-btn.active, .canvas-slot-bg-btn.active {
    background: var(--fg); color: var(--bg); border-color: var(--fg);
  }

  .canvas-slot.shadowed {
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  }

  .canvas-toggle-btn {
    font-family: var(--font);
    font-size: 8px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: #999;
    cursor: pointer;
  }
  .canvas-toggle-btn:hover { border-color: var(--fg); color: var(--fg); }
  .canvas-toggle-btn.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

  /* scroll controls */
  #cp-scroll-controls {
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  #cp-scroll-controls .canvas-param-row {
    border-bottom: none;
  }
  .canvas-scroll-btn-group {
    display: flex;
    flex: 1;
    gap: 2px;
  }
  .canvas-scroll-dir-btn, .canvas-scroll-mode-btn, .canvas-gif-speed-btn {
    flex: 1;
    font-family: var(--font);
    font-size: 8px;
    padding: 2px 3px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: #999;
    cursor: pointer;
  }
  .canvas-scroll-dir-btn:hover, .canvas-scroll-mode-btn:hover, .canvas-gif-speed-btn:hover { border-color: var(--fg); color: var(--fg); }
  .canvas-scroll-dir-btn.active, .canvas-scroll-mode-btn.active, .canvas-gif-speed-btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
  .canvas-gif-speed-btns { display: flex; gap: 2px; flex: 1; }
  #cp-scroll-speed {
    flex: 1;
    font-family: var(--font);
    font-size: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    padding: 1px 4px;
    outline: none;
    width: 0;
  }
  #cp-scroll-speed:focus { border-color: var(--fg); }
  #cp-figure-input {
    flex: 1;
    font-family: var(--font);
    font-size: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    padding: 1px 4px;
    outline: none;
    width: 0;
  }
  #cp-figure-input::placeholder { color: #bbb; }
  #cp-figure-input:focus { border-color: var(--fg); }

  /* scroll slot container (reuses .canvas-slot styles for border/shadow/active) */
  .canvas-slot--scroll { cursor: pointer; }

  /* carousel frame strip */
  #cp-carousel-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .carousel-thumb {
    position: relative;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
  }
  .carousel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .carousel-thumb.active { border-color: var(--fg); }
  .carousel-thumb-del {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    font-size: 9px;
    line-height: 14px;
    text-align: center;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 0;
    display: none;
  }
  .carousel-thumb:hover .carousel-thumb-del { display: block; }

  .carousel-strip-row {
    overflow: hidden;
  }
  .carousel-strip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
  }
  .carousel-strip-delay {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    margin-left: auto;
  }
  .carousel-strip-delay-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 9px;
    color: #666;
    padding: 0 2px;
    line-height: 1;
    font-family: var(--font);
  }
  .carousel-strip-delay-btn:hover { color: var(--fg); }
  .carousel-strip-delay-num {
    font-size: 8px;
    color: #666;
    padding: 0 1px;
    line-height: 1;
    font-family: var(--font);
    white-space: nowrap;
  }
  .carousel-strip-delay--custom .carousel-strip-delay-num { color: var(--fg); }
  .canvas-tree-file:hover .carousel-strip-delay-num { color: var(--fg); }
  .canvas-tree-file:hover .carousel-strip-delay-btn { color: var(--fg); }
  .canvas-tree-file.in-use .carousel-strip-delay-num,
  .canvas-tree-file.in-use .carousel-strip-delay-btn { color: var(--fg); }

  .carousel-strip-del {
    display: none;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 9px;
    color: #aaa;
    padding: 0 2px;
    line-height: 1;
    font-family: var(--font);
  }
  .carousel-strip-del:hover { color: var(--fg); }
  .canvas-tree-file:hover .carousel-strip-del { display: block; }

  #cp-caption-fields {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    display: none;
  }

  .canvas-caption-input {
    display: block;
    width: 100%;
    font-family: var(--font);
    font-size: 9px;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 5px 8px;
    background: var(--bg);
    color: var(--fg);
    outline: none;
    resize: none;
    height: 42px;
    line-height: 1.4;
    box-sizing: border-box;
  }
  .canvas-caption-input:last-child { border-bottom: none; }
  .canvas-caption-input::placeholder { color: #bbb; }
  .canvas-caption-input:focus { background: #f2f2f0; }

  /* ── CENTER PANEL ── */
  #canvas-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
  }

  #canvas-aspect-bar {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 2px;
    height: var(--bar-h);
  }

  .canvas-ar-chip {
    font-family: var(--font);
    font-size: 9px;
    padding: 2px 7px;
    border: 1px solid transparent;
    cursor: pointer;
    color: #999;
    user-select: none;
    letter-spacing: 0.03em;
  }
  .canvas-ar-chip:hover { color: var(--fg); border-color: var(--border); }
  .canvas-ar-chip.active { color: var(--fg); border-color: var(--fg); }

  #canvas-preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    background: #ebebea;
  }

  #canvas-preview {
    position: relative;
    border: 1px solid var(--border);
    overflow: hidden;
    background: #fff;
    box-shadow: 2px 3px 10px rgba(0,0,0,0.12);
    flex-shrink: 0;
  }

  .canvas-slot {
    position: absolute;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1px dashed #ccc;
  }
  .canvas-slot:hover { border-color: #999; }
  .canvas-slot.active { border: 1px solid #999 !important; }

  .canvas-slot.filled {
    border: 1px solid var(--border);
    display: block;
  }
  .canvas-slot.filled.active { border: 1px solid #999 !important; }

  .canvas-slot-img-wrap {
    padding: 3px;
    line-height: 0;
    overflow: hidden;
  }
  .canvas-slot-img-wrap img,
  .canvas-slot-img-wrap video {
    width: 100%;
    display: block;
    transform: translateZ(0);
    pointer-events: none;
  }

  .canvas-slot-meta {
    position: relative;
    border-top: 1px solid var(--border);
    height: var(--bar-h);
    padding: 0 5px;
    font-family: var(--font);
    font-size: 9px;
    color: rgb(140, 140, 140);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .canvas-slot-label {
    font-family: var(--font);
    font-size: 9px;
    color: #ccc;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.04em;
  }

  .canvas-slot-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
    color: var(--fg);
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-family: var(--font);
    line-height: 1;
  }
  .canvas-slot.filled:hover .canvas-slot-del { display: flex; }

  .canvas-slot-pause {
    position: absolute;
    top: 4px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
    color: var(--fg);
    font-size: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-family: var(--font);
    line-height: 1;
  }
  .canvas-slot.filled:hover .canvas-slot-pause { display: flex; }
  .canvas-slot-pause--active { display: flex !important; }

  .canvas-slot-frame-btn {
    position: absolute;
    top: 4px;
    width: 16px;
    height: 16px;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
    color: var(--fg);
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-family: var(--font);
    line-height: 1;
    user-select: none;
  }
  .canvas-slot.filled:hover .canvas-slot-frame-btn { display: flex; }

  .canvas-caption-bar {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: 9px;
    color: rgb(140,140,140);
    border-top: 1px solid var(--border);
    padding: 0 5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
    pointer-events: none;
  }

  /* ── RIGHT PANEL ── */
  #canvas-right {
    width: 148px;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
  }
  #canvas-right::-webkit-scrollbar { display: none; }

  .canvas-btn-row {
    display: flex;
    gap: 3px;
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  #canvas-size-display {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 9px;
    color: #999;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    letter-spacing: 0.02em;
  }

  #canvas-export-btn {
    margin: 8px;
    font-family: var(--font);
    font-size: 10px;
    padding: 6px;
    border: 1px solid var(--fg);
    background: var(--fg);
    color: var(--bg);
    cursor: pointer;
    letter-spacing: 0.08em;
    flex-shrink: 0;
  }
  #canvas-export-btn:hover { opacity: 0.75; }
