/* Collections on the web (docs/COLLECTIONS.md): the library rows, the one create dialog, the
   "Add to collection" sheet, the collection page with its staged editor, the delete and discard
   confirmations and the Add memories picker. Semantic tokens only (design-system/AI_RULES.md):
   one primary action per view, the dark label on the orange fill, a 48px target for every
   control, and names clamped with the shared .mb-clamp-* utilities (home/css/home.css, repeated below). */

/* The shared clamps of home/css/home.css, repeated here: home.css loads without blocking the
   page, and the collection page measures its clamped title and description ("Show full name")
   as soon as its script runs, so the rules must be in the stylesheet the page links itself. */
.mb-clamp-1 {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mb-clamp-2,
.mb-clamp-3 {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
}

.mb-clamp-2 {
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.mb-clamp-3 {
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.collection-dialog [hidden],
.collections-panel [hidden],
.collection-page [hidden],
.collection-editor[hidden],
.collection-editor [hidden] {
    display: none !important;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.collection-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ds-space-2);
    min-height: var(--ds-space-12);
    padding: var(--ds-space-3) var(--ds-space-5);
    border: 1px solid transparent;
    border-radius: var(--ds-radius-md);
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-sans);
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}

.collection-button--primary {
    background: var(--ds-brand);
    color: var(--ds-on-cta);
}

.collection-button--primary:hover {
    background: var(--ds-brand-hover);
    color: var(--ds-on-cta);
}

.collection-button--secondary {
    background: var(--ds-card);
    border-color: var(--ds-line);
    color: var(--ds-link);
}

.collection-button--secondary:hover {
    background: var(--ds-surface);
    color: var(--ds-link-hover);
}

.collection-button--destructive {
    background: var(--ds-destructive);
    color: var(--ds-on-brand);
}

.collection-button:disabled,
.collection-button[aria-disabled="true"] {
    cursor: default;
    opacity: 0.55;
}

.collection-button[aria-busy="true"] {
    cursor: progress;
}

.collection-button .material-icons-outlined,
.collection-icon-button .material-icons-outlined,
.collection-menu__item .material-icons-outlined {
    font-size: var(--ds-font-size-h3);
}

.collection-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--ds-space-12);
    height: var(--ds-space-12);
    padding: 0;
    border: 0;
    border-radius: var(--ds-radius-pill);
    background: transparent;
    color: var(--ds-ink-soft);
    cursor: pointer;
}

.collection-icon-button:hover {
    background: var(--ds-surface);
    color: var(--ds-ink);
}

.collection-text-button {
    display: inline-flex;
    align-items: center;
    min-height: var(--ds-space-12);
    padding: 0;
    border: 0;
    background: none;
    color: var(--ds-link);
    font: 600 var(--ds-font-size-bodySm)/var(--ds-line-height-bodySm) var(--ds-font-sans);
    cursor: pointer;
}

.collection-text-button:hover {
    color: var(--ds-link-hover);
    text-decoration: underline;
}

:is(.collection-dialog, .collections-panel, .collection-page, .collection-editor, .memory-collections-info)
    :is(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 3px solid var(--ds-focus);
    outline-offset: 2px;
}

/* A series label ("Biography") above the rest of a "Series | Subject | Detail" name. */
.collection-eyebrow {
    margin: 0;
    color: var(--ds-eyebrow);
    font: 600 var(--ds-font-size-overline)/var(--ds-line-height-overline) var(--ds-font-sans);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Name and description fields (counted in code points, never cut) ─────── */
.collection-field {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    min-width: 0;
}

.collection-field__label {
    color: var(--ds-ink);
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-sans);
}

.collection-field__input,
.collection-search {
    width: 100%;
    min-height: var(--ds-space-12);
    box-sizing: border-box;
    padding: var(--ds-space-3);
    border: 1px solid var(--ds-input-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-card);
    color: var(--ds-ink);
    font: var(--ds-font-size-body)/var(--ds-line-height-body) var(--ds-font-sans);
}

textarea.collection-field__input {
    min-height: calc(var(--ds-space-16) + var(--ds-space-8));
    resize: vertical;
}

.collection-field__input:focus,
.collection-search:focus {
    border-color: var(--ds-focus);
}

.collection-field--invalid .collection-field__input {
    border-color: var(--ds-error-text);
}

.collection-field__meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ds-space-3);
}

.collection-field__error {
    margin: 0;
    color: var(--ds-error-text);
    font-size: var(--ds-font-size-bodySm);
    line-height: var(--ds-line-height-bodySm);
    overflow-wrap: anywhere;
}

.collection-field__counter {
    margin: 0 0 0 auto;
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-caption);
    line-height: var(--ds-line-height-caption);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.collection-field--invalid .collection-field__counter {
    color: var(--ds-error-text);
    font-weight: 600;
}

/* ── Dialogs (native <dialog>, so they sit above every reader layer) ──────── */
.collection-dialog {
    width: min(460px, calc(100vw - var(--ds-space-8)));
    max-width: none;
    max-height: calc(100dvh - var(--ds-space-8));
    box-sizing: border-box;
    padding: 0;
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-radius-xl);
    background: var(--ds-elevated);
    color: var(--ds-ink);
    box-shadow: var(--ds-shadow-elevated);
    font: var(--ds-font-size-body)/var(--ds-line-height-body) var(--ds-font-sans);
    overflow: hidden;
}

.collection-dialog[open] {
    display: flex;
    flex-direction: column;
}

.collection-dialog::backdrop {
    background: var(--ds-overlay);
}

.collection-dialog__body {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
    min-height: 0;
    padding: var(--ds-space-6);
    overflow-y: auto;
}

.collection-dialog__header {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
}

.collection-dialog__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    color: var(--ds-ink);
    font: 700 var(--ds-font-size-h3)/var(--ds-line-height-h3) var(--ds-font-display);
    overflow-wrap: anywhere;
}

.collection-dialog__title:focus {
    outline: none;
}

.collection-dialog__text {
    margin: 0;
    color: var(--ds-ink-soft);
}

.collection-dialog__error {
    margin: 0;
    color: var(--ds-error-text);
    font-size: var(--ds-font-size-bodySm);
}

.collection-dialog__actions {
    display: flex;
    flex-wrap: wrap-reverse;
    justify-content: flex-end;
    gap: var(--ds-space-3);
}

/* ── The "Add to collection" sheet ───────────────────────────────────────── */
.collection-sheet {
    width: min(480px, calc(100vw - var(--ds-space-8)));
    height: min(680px, calc(100dvh - var(--ds-space-8)));
}

.collection-sheet__handle {
    display: none;
}

.collection-sheet__header {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-3) var(--ds-space-2) var(--ds-space-6);
}

.collection-sheet__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font: 700 var(--ds-font-size-h4)/var(--ds-line-height-h4) var(--ds-font-display);
}

.collection-sheet__title:focus {
    outline: none;
}

.collection-sheet__memory {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    padding: 0 var(--ds-space-6) var(--ds-space-3);
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-bodySm);
    line-height: var(--ds-line-height-bodySm);
}

.collection-sheet__memory-thumb {
    flex: none;
    width: var(--ds-space-10);
    height: var(--ds-space-10);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface) center / cover no-repeat;
}

.collection-sheet__tools {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    padding: 0 var(--ds-space-6) var(--ds-space-2);
    border-bottom: 1px solid var(--ds-line);
}

.collection-sheet__new-button {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    width: 100%;
    min-height: var(--ds-space-12);
    padding: 0;
    border: 0;
    background: none;
    color: var(--ds-link);
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-sans);
    text-align: left;
    cursor: pointer;
}

.collection-sheet__new-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--ds-space-10);
    height: var(--ds-space-10);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-brand-tint);
    color: var(--ds-eyebrow);
}

.collection-sheet__create {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
    padding-bottom: var(--ds-space-2);
}

.collection-sheet__create-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
}

.collection-sheet__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--ds-space-2) 0;
}

.collection-sheet__rows {
    margin: 0;
    padding: 0;
    list-style: none;
}

.collection-sheet__loading {
    margin: 0;
    padding: var(--ds-space-4) var(--ds-space-6);
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-bodySm);
    text-align: center;
}

.collection-sheet__more {
    display: flex;
    margin: var(--ds-space-3) auto;
}

/* Status lines wrap to 3 lines; the script quotes at most 40 code points of a title, so the verb
   (last in de, ja, ko and zh) is never the part cut (docs/COLLECTIONS.md "Clamps"). */
.collection-sheet__status {
    display: -webkit-box;
    margin: 0;
    padding: var(--ds-space-3) var(--ds-space-6);
    border-top: 1px solid var(--ds-line);
    color: var(--ds-ink);
    font-size: var(--ds-font-size-bodySm);
    line-height: var(--ds-line-height-bodySm);
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.collection-sheet__status:empty {
    padding: 0;
    border-top: 0;
}

.collection-sheet__empty {
    padding: var(--ds-space-8) var(--ds-space-6);
    color: var(--ds-ink-soft);
    text-align: center;
    overflow-wrap: anywhere;
}

.collection-sheet__empty strong {
    display: block;
    margin-bottom: var(--ds-space-1);
    color: var(--ds-ink);
}

/* One collection in the sheet: a toggle (aria-pressed), like the post-publish panel. */
.collection-choice {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    width: 100%;
    min-height: var(--ds-space-12);
    box-sizing: border-box;
    padding: var(--ds-space-2) var(--ds-space-6);
    border: 0;
    background: transparent;
    color: var(--ds-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.collection-choice:hover {
    background: var(--ds-surface);
}

.collection-choice[aria-pressed="true"] {
    background: var(--ds-brand-tint);
}

.collection-choice[aria-busy="true"] {
    cursor: progress;
    opacity: 0.6;
}

.collection-choice:focus-visible {
    outline-offset: -3px;
}

.collection-choice__thumb,
.coll-thumb,
.collection-picker__thumb,
.collection-editor__thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--ds-space-12);
    height: var(--ds-space-12);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface) center / cover no-repeat;
    color: var(--ds-ink-soft);
}

.collection-choice__text,
.coll-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--ds-space-1);
    min-width: 0;
}

.collection-choice__title,
.coll-name {
    color: var(--ds-ink);
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-display);
}

.collection-choice__count,
.coll-sub {
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-caption);
    line-height: var(--ds-line-height-caption);
}

.collection-choice__check {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--ds-space-6);
    height: var(--ds-space-6);
    border: 2px solid var(--ds-input-border);
    border-radius: var(--ds-radius-pill);
    background: var(--ds-card);
    color: transparent;
}

.collection-choice__check .material-icons-outlined {
    font-size: var(--ds-font-size-body);
    font-weight: 700;
}

/* The dark check on the brand fill (5.4:1); white on orange fails AA. */
.collection-choice[aria-pressed="true"] .collection-choice__check {
    border-color: var(--ds-brand);
    background: var(--ds-brand);
    color: var(--ds-ink);
}

.collection-choice__retry {
    display: flex;
    margin: 0 var(--ds-space-6) var(--ds-space-2) auto;
}

/* ── Library (profile Collections tab and the phone library) ──────────────── */
.collections-panel {
    width: 100%;
    max-width: 640px;
    box-sizing: border-box;
    color: var(--ds-ink);
    font-family: var(--ds-font-sans);
}

.mm-tab-content .collections-panel {
    padding: var(--ds-space-3) var(--ds-space-4) calc(var(--ds-space-16) + var(--ds-space-10));
}

.collection-library__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-3);
    margin-bottom: var(--ds-space-4);
}

.collection-library__search {
    flex: 1 1 220px;
    min-width: 0;
    margin: 0;
}

.collection-library__toolbar .collection-button {
    flex: none;
}

.collection-library__rows {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-1);
}

.coll-row {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    min-height: var(--ds-space-12);
    padding: var(--ds-space-2);
    border-radius: var(--ds-radius-md);
    color: var(--ds-ink);
    text-decoration: none;
}

.coll-row:hover {
    background: var(--ds-surface);
    color: var(--ds-ink);
}

.coll-row .coll-thumb {
    width: calc(var(--ds-space-12) + var(--ds-space-2));
    height: calc(var(--ds-space-12) + var(--ds-space-2));
    border-radius: var(--ds-radius-md);
}

.coll-arrow {
    flex: none;
    color: var(--ds-ink-soft);
}

.collection-library__message {
    margin: 0;
    padding: var(--ds-space-6) var(--ds-space-2);
    color: var(--ds-ink-soft);
    overflow-wrap: anywhere;
}

.collection-library__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--ds-space-3);
    padding: var(--ds-space-10) var(--ds-space-4);
    text-align: center;
}

.collection-library__empty-icon {
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-display);
}

.collection-library__empty-title {
    margin: 0;
    font: 700 var(--ds-font-size-h4)/var(--ds-line-height-h4) var(--ds-font-display);
}

.collection-library__empty-text {
    max-width: 32rem;
    margin: 0;
    color: var(--ds-ink-soft);
}

/* ── Collection page (/collection/<ref>) ─────────────────────────────────── */
.collection-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--ds-card);
    color: var(--ds-ink);
    font: var(--ds-font-size-body)/var(--ds-line-height-body) var(--ds-font-sans);
}

.collection-page__view {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.collection-page__bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--ds-space-1);
    padding: var(--ds-space-1) var(--ds-space-2);
    border-bottom: 1px solid var(--ds-line);
    background: var(--ds-card);
}

.collection-page__bar-title {
    flex: 1;
    min-width: 0;
    margin: 0 var(--ds-space-2);
    color: var(--ds-ink);
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-display);
}

.collection-page__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.collection-page__header {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    padding: var(--ds-space-5) var(--ds-space-5) var(--ds-space-4);
}

.collection-page__cover {
    height: 200px;
    margin-bottom: var(--ds-space-2);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface) center / cover no-repeat;
}

.collection-page__title {
    margin: 0;
    color: var(--ds-ink);
    font: 700 var(--ds-font-size-h2)/var(--ds-line-height-h2) var(--ds-font-display);
}

.collection-page__count {
    margin: 0;
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-bodySm);
    line-height: var(--ds-line-height-bodySm);
}

.collection-page__description {
    margin: 0;
    color: var(--ds-ink);
    white-space: pre-line;
}

.collection-page__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-3);
    margin-top: var(--ds-space-2);
}

.collection-page__status {
    margin: 0;
    padding: var(--ds-space-3) var(--ds-space-4);
    border-radius: var(--ds-radius-md);
    background: var(--ds-calm);
    color: var(--ds-ink);
    font-size: var(--ds-font-size-bodySm);
    line-height: var(--ds-line-height-bodySm);
    overflow-wrap: anywhere;
}

.collection-page__status:empty {
    display: none;
}

/* Follow (place_following) as the visitor's secondary action. */
.collection-page .col-detail-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-1);
    min-height: var(--ds-space-12);
    padding: 0 var(--ds-space-4);
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-radius-pill);
    background: var(--ds-card);
    color: var(--ds-ink-soft);
    font: 600 var(--ds-font-size-bodySm)/var(--ds-line-height-bodySm) var(--ds-font-sans);
    cursor: pointer;
}

.collection-page .col-detail-follow-btn.place-follow-active {
    border-color: var(--ds-brand);
    color: var(--ds-link);
}

.collection-page .col-detail-follow-btn .place-follow-icon {
    font-size: var(--ds-font-size-body);
}

.collection-page .col-detail-follow-btn .place-follow-count {
    padding-left: var(--ds-space-2);
    border-left: 1px solid var(--ds-line);
}

/* The overflow menu: Edit collection, Delete collection, Audio walking tour. */
.collection-menu {
    position: relative;
}

.collection-menu__list {
    position: absolute;
    top: calc(100% + var(--ds-space-1));
    right: 0;
    z-index: 3;
    min-width: 232px;
    max-width: calc(100vw - var(--ds-space-8));
    padding: var(--ds-space-1) 0;
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-radius-md);
    background: var(--ds-elevated);
    box-shadow: var(--ds-shadow-elevated);
}

.collection-menu__item {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    width: 100%;
    min-height: var(--ds-space-12);
    box-sizing: border-box;
    padding: 0 var(--ds-space-4);
    border: 0;
    background: none;
    color: var(--ds-ink);
    font: var(--ds-font-size-body)/var(--ds-line-height-body) var(--ds-font-sans);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.collection-menu__item:hover,
.collection-menu__item:focus-visible {
    background: var(--ds-surface);
    color: var(--ds-ink);
}

.collection-menu__item--destructive,
.collection-menu__item--destructive:hover {
    color: var(--ds-error-text);
}

/* The reading list: a sort control and the memories as a timeline. */
.col-detail-sort-bar {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    padding: var(--ds-space-2) var(--ds-space-5);
    border-top: 1px solid var(--ds-line);
    border-bottom: 1px solid var(--ds-line);
    background: var(--ds-bg);
}

.col-detail-sort-label {
    flex: none;
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-bodySm);
}

.col-detail-sort-select {
    min-width: 0;
    min-height: var(--ds-space-10);
    padding: 0 var(--ds-space-3);
    border: 1px solid var(--ds-input-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-card);
    color: var(--ds-ink);
    font: var(--ds-font-size-bodySm)/var(--ds-line-height-bodySm) var(--ds-font-sans);
}

.col-detail-body {
    padding: var(--ds-space-5) var(--ds-space-5) var(--ds-space-10);
}

.col-detail-list {
    display: flex;
    flex-direction: column;
}

.col-detail-item {
    display: flex;
    align-items: stretch;
    min-height: 0;
}

.col-detail-timeline {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    width: var(--ds-space-5);
    margin-right: var(--ds-space-4);
}

.col-detail-timeline-dot {
    flex: none;
    width: var(--ds-space-3);
    height: var(--ds-space-3);
    margin-top: var(--ds-space-5);
    border-radius: var(--ds-radius-pill);
    background: var(--ds-brand);
}

.col-detail-timeline-line {
    flex: 1;
    width: 2px;
    margin-top: var(--ds-space-1);
    background: var(--ds-brand-tint);
}

.col-detail-item:last-child .col-detail-timeline-line {
    background: transparent;
}

.col-detail-card {
    display: flex;
    flex: 1;
    gap: var(--ds-space-3);
    min-width: 0;
    margin-bottom: var(--ds-space-3);
    padding: var(--ds-space-3);
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-card);
    box-shadow: var(--ds-shadow-card);
    color: inherit;
    text-decoration: none;
    transition: box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.col-detail-card:hover {
    box-shadow: var(--ds-shadow-elevated);
    color: inherit;
}

.col-detail-card-img {
    flex: none;
    width: calc(var(--ds-space-16) + var(--ds-space-6));
    height: calc(var(--ds-space-16) + var(--ds-space-6));
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface) center / cover no-repeat;
}

.col-detail-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: var(--ds-space-1);
    min-width: 0;
}

.col-detail-card-title {
    color: var(--ds-ink);
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-sans);
}

.col-detail-card-date,
.col-detail-card-location {
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-caption);
    line-height: var(--ds-line-height-caption);
}

.col-detail-card-location {
    display: flex;
    align-items: center;
    gap: var(--ds-space-1);
}

.col-detail-card-location-icon {
    color: var(--ds-eyebrow);
    font-size: var(--ds-font-size-bodySm);
}

.collection-page__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--ds-space-3);
    padding: var(--ds-space-10) var(--ds-space-5);
    text-align: center;
}

.collection-page__empty-title {
    margin: 0;
    font: 700 var(--ds-font-size-h4)/var(--ds-line-height-h4) var(--ds-font-display);
}

.collection-page__empty-text {
    max-width: 30rem;
    margin: 0;
    color: var(--ds-ink-soft);
}

/* ── The staged editor (copied from the Featured memories editor) ─────────── */
.collection-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--ds-card);
    color: var(--ds-ink);
    font: var(--ds-font-size-body)/var(--ds-line-height-body) var(--ds-font-sans);
}

.collection-editor__form {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    margin: 0;
}

.collection-editor__bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--ds-space-2);
    min-height: calc(var(--ds-space-12) + var(--ds-space-2));
    padding: 0 var(--ds-space-5);
    border-bottom: 1px solid var(--ds-line);
}

.collection-editor__title {
    flex: 1;
    margin: 0;
    font: 700 var(--ds-font-size-h4)/var(--ds-line-height-h4) var(--ds-font-display);
}

.collection-editor__title:focus {
    outline: none;
}

.collection-editor__scroll {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--ds-space-5);
    min-height: 0;
    padding: var(--ds-space-5);
    overflow-y: auto;
}

.collection-editor__heading {
    margin: 0;
    font: 600 var(--ds-font-size-label)/var(--ds-line-height-label) var(--ds-font-sans);
}

.collection-editor__help {
    margin: calc(var(--ds-space-1) * -1) 0 0;
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-bodySm);
    line-height: var(--ds-line-height-bodySm);
}

.collection-editor__list {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.collection-editor__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-3);
    padding: var(--ds-space-3);
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-radius-md);
    background: var(--ds-card);
    touch-action: pan-y;
}

.collection-editor__row.is-dragging {
    position: relative;
    z-index: 2;
    box-shadow: var(--ds-shadow-elevated);
}

.collection-editor__handle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--ds-space-10);
    height: var(--ds-space-12);
    color: var(--ds-ink-soft);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.collection-editor__row.is-dragging .collection-editor__handle {
    cursor: grabbing;
}

.collection-editor__line {
    display: flex;
    flex: 1 1 220px;
    align-items: center;
    gap: var(--ds-space-2);
    min-width: 0;
}

.collection-editor__main {
    display: flex;
    flex: 1;
    align-items: center;
    gap: var(--ds-space-3);
    min-width: 0;
}

.collection-editor__position {
    flex: none;
    min-width: var(--ds-space-5);
    color: var(--ds-ink-soft);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.collection-editor__memory-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.collection-editor__controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-1);
}

/* Link text on the card with a hairline, like the secondary button: link on surface is 4.44:1, below AA. */
.collection-editor__controls button {
    min-height: var(--ds-space-12);
    padding: var(--ds-space-2) var(--ds-space-3);
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-card);
    color: var(--ds-link);
    font: var(--ds-font-size-bodySm)/var(--ds-line-height-bodySm) var(--ds-font-sans);
    cursor: pointer;
}

.collection-editor__controls button:hover:not(:disabled) {
    border-color: var(--ds-link);
}

.collection-editor__controls button:disabled {
    color: var(--ds-ink-soft);
    cursor: default;
    opacity: 0.65;
}

.collection-editor__empty {
    margin: 0;
    color: var(--ds-ink-soft);
}

/* Status lines wrap to 3 lines around a quoted title of at most 40 code points, so "Save to keep
   this change." is never cut (docs/COLLECTIONS.md "Clamps"). */
.collection-editor__status {
    display: -webkit-box;
    min-height: var(--ds-line-height-body);
    margin: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: var(--ds-ink-soft);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.collection-editor__actions {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5) calc(var(--ds-space-4) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--ds-line);
    background: var(--ds-card);
}

/* ── The Add memories picker ─────────────────────────────────────────────── */
.collection-picker {
    width: min(640px, calc(100vw - var(--ds-space-8)));
    height: min(760px, calc(100dvh - var(--ds-space-8)));
}

.collection-picker__header {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-3) var(--ds-space-2) var(--ds-space-6);
}

.collection-picker__search {
    margin: 0;
    padding: 0 var(--ds-space-6) var(--ds-space-3);
    border-bottom: 1px solid var(--ds-line);
}

.collection-picker__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--ds-space-2) var(--ds-space-3);
}

.collection-picker__rows {
    margin: 0;
    padding: 0;
    list-style: none;
}

.collection-picker__choice {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    min-height: var(--ds-space-12);
    padding: var(--ds-space-2) var(--ds-space-3);
    border-radius: var(--ds-radius-md);
    cursor: pointer;
}

.collection-picker__choice:hover {
    background: var(--ds-surface);
}

.collection-picker__choice:has(input:checked) {
    background: var(--ds-brand-tint);
}

.collection-picker__choice input {
    flex: none;
    width: var(--ds-space-5);
    height: var(--ds-space-5);
    margin: 0;
    accent-color: var(--ds-brand-strong);
}

.collection-picker__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--ds-space-1);
    min-width: 0;
}

.collection-picker__title {
    font-weight: 600;
}

.collection-picker__meta {
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-caption);
    line-height: var(--ds-line-height-caption);
}

.collection-picker__message {
    margin: 0;
    padding: var(--ds-space-8) var(--ds-space-5);
    color: var(--ds-ink-soft);
    text-align: center;
    overflow-wrap: anywhere;
}

.collection-picker__message .collection-button {
    margin-top: var(--ds-space-3);
}

.collection-picker__more {
    display: flex;
    margin: var(--ds-space-3) auto;
}

.collection-picker__footer {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ds-space-3);
    padding: var(--ds-space-3) var(--ds-space-6) calc(var(--ds-space-3) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--ds-line);
}

.collection-picker__status {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--ds-ink-soft);
    font-size: var(--ds-font-size-bodySm);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Phones (the one web breakpoint, 813px) ──────────────────────────────── */
@media screen and (max-width: 812px) {
    .collection-dialog--sheet {
        width: 100%;
        max-width: 100%;
        max-height: 88dvh;
        margin: auto 0 0;
        border-width: 1px 0 0;
        border-radius: var(--ds-radius-xl) var(--ds-radius-xl) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .collection-sheet {
        height: auto;
        min-height: 60dvh;
    }

    .collection-sheet__handle {
        display: block;
        width: var(--ds-space-10);
        height: var(--ds-space-1);
        margin: var(--ds-space-2) auto 0;
        border-radius: var(--ds-radius-pill);
        background: var(--ds-line);
    }

    .collection-sheet__header,
    .collection-picker__header {
        padding-left: var(--ds-space-4);
    }

    .collection-sheet__memory,
    .collection-sheet__tools,
    .collection-picker__search {
        padding-left: var(--ds-space-4);
        padding-right: var(--ds-space-4);
    }

    .collection-choice {
        padding-left: var(--ds-space-4);
        padding-right: var(--ds-space-4);
    }

    .collection-picker {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .collection-dialog__body {
        padding: var(--ds-space-5) var(--ds-space-4);
    }

    .collection-dialog__actions .collection-button {
        flex: 1 1 auto;
    }

    .collection-page__header {
        padding: var(--ds-space-4) var(--ds-space-4) var(--ds-space-3);
    }

    .collection-page__cover {
        height: 160px;
    }

    .collection-page__title {
        font-size: var(--ds-font-size-h3);
        line-height: var(--ds-line-height-h3);
    }

    .col-detail-sort-bar {
        padding: var(--ds-space-2) var(--ds-space-4);
    }

    .col-detail-body {
        padding: var(--ds-space-4) var(--ds-space-4) var(--ds-space-10);
    }

    .col-detail-card-img {
        width: calc(var(--ds-space-16) + var(--ds-space-3));
        height: calc(var(--ds-space-16) + var(--ds-space-3));
    }

    .col-detail-timeline {
        width: var(--ds-space-4);
        margin-right: var(--ds-space-3);
    }

    .collection-editor__scroll {
        padding: var(--ds-space-4);
    }

    .collection-editor__row {
        flex-direction: column;
        align-items: stretch;
    }

    .collection-editor__line {
        flex-basis: auto;
    }

    .collection-editor__controls {
        justify-content: space-between;
    }

    .collection-editor__controls button {
        flex: 1 1 0;
    }

    .collection-editor__actions {
        padding-left: var(--ds-space-4);
        padding-right: var(--ds-space-4);
    }

    .collection-editor__actions .collection-button {
        flex: 1 1 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .col-detail-card {
        transition: none;
    }
}
