.timeline-post-discussion {
  margin-top: 1rem;
  border: 1px solid var(--app-border);
  border-radius: .75rem;
  background: var(--app-card);
  overflow: clip;
}

.timeline-post-discussion > summary {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 2.9rem;
  padding: .65rem .85rem;
  color: var(--app-text);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.timeline-post-discussion > summary::-webkit-details-marker { display: none; }
.timeline-post-discussion > summary::before {
  content: "›";
  display: inline-grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--app-surface);
  color: var(--app-accent);
  font-size: 1.25rem;
  line-height: 1;
  transition: transform .15s ease;
}
.timeline-post-discussion[open] > summary::before { transform: rotate(90deg); }
.timeline-post-discussion > summary:hover { background: var(--app-surface); }
.timeline-post-discussion > summary:focus-visible {
  outline: 3px solid var(--app-focus);
  outline-offset: -3px;
}
.timeline-post-discussion > :not(summary) { margin-right: .85rem; margin-left: .85rem; }
.timeline-post-discussion > summary + .muted { margin-top: .55rem; }
.timeline-post-discussion .timeline-post-comments { margin-top: .65rem; }
.timeline-post-discussion .timeline-post-comment-form { padding: .75rem 0 .85rem; }
.timeline-post-discussion .timeline-post-comment-form { display: grid; gap: .65rem; }
.timeline-post-comment-form label { display: grid; gap: .4rem; margin: 0; font-weight: 600; }
.timeline-post-comment-form textarea { box-sizing: border-box; display: block; width: 100%; min-height: 6rem; resize: vertical; padding: .75rem; font: inherit; color: var(--app-text); background: var(--app-field); border: 1px solid var(--app-border); border-radius: .6rem; }
.timeline-post-comment-form button[type="submit"] { justify-self: start; min-height: 44px; padding: .6rem 1rem; color: var(--app-accent-text); background: var(--app-accent); border: 1px solid var(--app-accent); border-radius: .55rem; font: inherit; font-weight: 650; }

/* The compact toggle sits on the card's bottom border. */
.timeline-card .timeline-post-discussion { overflow: visible; background: transparent; }
.timeline-card .timeline-post-discussion > summary { display: inline-flex; min-height: 1.8rem; padding: .2rem .75rem; gap: .25rem; }
.timeline-card .timeline-post-discussion > summary::before { content: none; }
.timeline-post-comment-form textarea:focus-visible { outline: 3px solid var(--app-accent); outline-offset: 2px; }

/* The queue below the drop zone is the single attachment preview list. */
.timeline-post-dialog .ft-file-previews { display: none; }
.ft-modal-tabpanel.timeline-post-panel-media { gap: .5rem; }
.timeline-retained-media { display: grid; gap: .5rem; }
/* The thumbnail spans every row; the last row absorbs spare height so the name, people and actions stay together. */
.timeline-retained-file {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) auto auto auto;
  grid-template-rows: auto auto auto 1fr;
  align-items: center;
  column-gap: .65rem;
  row-gap: .3rem;
  padding: .65rem;
  border: 1px solid var(--app-border);
  border-radius: .55rem;
  background: var(--app-card);
}
.timeline-retained-thumbnail {
  grid-column: 1; grid-row: 1 / -1;
  width: 7.5rem;
  height: 5.5rem;
  object-fit: contain;
  border-radius: .35rem;
  background: var(--app-soft);
}
.timeline-retained-file-name { grid-column: 2; grid-row: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.timeline-retained-file-size { grid-column: 3; grid-row: 1; color: var(--app-muted); font-size: .85rem; white-space: nowrap; }
.timeline-headline-choice { grid-column: 4; grid-row: 1; display: flex; align-items: center; gap: .35rem; font-size: .85rem; white-space: nowrap; }
.timeline-headline-choice input { width: 1rem; height: 1rem; margin: 0; }
.timeline-remove-file { grid-column: 5; grid-row: 1; padding: .35rem .55rem; }
.timeline-media-group-actions { grid-column: 2 / -1; grid-row: 3; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.timeline-media-group-actions .quiet, .timeline-media-group-actions select { padding: .25rem .55rem; font-size: .85rem; min-height: 0; }
/* A back image sits indented under its front. */
.timeline-retained-file.is-back { margin-left: 2rem; grid-template-columns: 4.5rem auto minmax(0, 1fr) auto auto auto; background: var(--app-soft); }
.timeline-retained-file.is-back .timeline-retained-thumbnail { width: 4.5rem; height: 3.5rem; }
.timeline-retained-file.is-back .timeline-back-label { grid-column: 2; grid-row: 1; }
.timeline-retained-file.is-back .timeline-retained-file-name { grid-column: 3; }
.timeline-retained-file.is-back .timeline-retained-file-size { grid-column: 4; }
.timeline-retained-file.is-back .timeline-media-group-actions { grid-column: 5; grid-row: 1; }
.timeline-retained-file.is-back .timeline-remove-file { grid-column: 6; }
.timeline-retained-file.is-back .timeline-media-tag-pills { grid-column: 2 / -1; grid-row: 2; }
.timeline-back-label { display: inline-block; padding: .1rem .45rem; border-radius: var(--app-radius-pill); background: var(--app-card); border: 1px solid var(--app-border); color: var(--app-muted); font-size: .75rem; font-weight: 650; white-space: nowrap; }
.timeline-retained-file[draggable="true"] { cursor: grab; }
.timeline-retained-file.is-dragging { opacity: .45; }
.timeline-retained-file.is-back-drop-target { outline: 2px dashed var(--app-accent); outline-offset: 2px; background: color-mix(in srgb, var(--app-accent) 8%, var(--app-card)); }
.timeline-photo-tag-host { position: relative; }
.timeline-media-thumb[role="button"],.timeline-retained-thumbnail[role="button"] { cursor: pointer; }
.timeline-media-thumb[role="button"]:focus-visible,.timeline-retained-thumbnail[role="button"]:focus-visible { outline: 3px solid var(--app-accent); outline-offset: 3px; }
.timeline-media-tag-pills { display:flex; flex-wrap:wrap; gap:.3rem; margin-top:.35rem; }
.timeline-media-tag-pill { display:inline-flex; padding:.15rem .5rem; border:1px solid var(--app-border); border-radius:var(--app-radius-pill); font-size:.85rem; color:var(--app-text); background:var(--app-soft); text-decoration:none; }
.timeline-photo-date-choice { max-width:100%; }
.timeline-retained-file > .timeline-media-tag-pills { grid-column:2 / -1; grid-row:2; margin-top:0; }
.timeline-media-tag-pills:empty { display:none; }
.timeline-post-view-all { display:block; margin:.65rem 0; }
@media (max-width: 680px) {
  .timeline-retained-file, .timeline-retained-file.is-back { grid-template-columns: 4.5rem minmax(0, 1fr) auto; grid-template-rows: none; }
  .timeline-retained-file.is-back { margin-left: 1rem; }
  .timeline-retained-file .timeline-retained-thumbnail { width: 4.5rem; height: 3.5rem; grid-row: 1 / span 4; }
  .timeline-retained-file > :not(.timeline-retained-thumbnail), .timeline-retained-file.is-back > :not(.timeline-retained-thumbnail) { grid-row: auto; grid-column: 2; }
  .timeline-retained-file > .timeline-remove-file, .timeline-retained-file.is-back > .timeline-remove-file { grid-column: 3; grid-row: 1; }
  .timeline-retained-file > .timeline-media-tag-pills, .timeline-retained-file > .timeline-media-group-actions,
  .timeline-retained-file.is-back > .timeline-media-tag-pills, .timeline-retained-file.is-back > .timeline-media-group-actions { grid-column: 2 / -1; }
}
.timeline-create-person-dialog select {
  display: block;
  width: 100%;
  margin-top: .35rem;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  padding: .75rem;
  font: inherit;
  color: var(--app-text);
  background: var(--app-card);
}

/* Existing media data table with drag handles and back image indicator */
.timeline-existing-media-section {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--app-border);
}
.timeline-existing-media-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.timeline-existing-media-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--app-text);
}
.timeline-existing-media-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-card);
}
.timeline-existing-media-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: .9rem;
}
.timeline-existing-media-table th,
.timeline-existing-media-table td {
  padding: .5rem .65rem;
  border-bottom: 1px solid var(--app-border);
  vertical-align: middle;
}
.timeline-existing-media-table tbody tr:last-child td {
  border-bottom: none;
}
.timeline-existing-media-table th {
  background: var(--app-surface, var(--app-soft));
  color: var(--app-muted);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.timeline-existing-media-row.is-dragging {
  opacity: .4;
  background: var(--app-soft);
}
.timeline-existing-media-row.drag-over-above {
  border-top: 2px solid var(--app-accent);
}
.timeline-existing-media-row.drag-over-below {
  border-bottom: 2px solid var(--app-accent);
}
.timeline-existing-media-row.is-back-drop-target {
  outline: 2px dashed var(--app-accent);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--app-accent) 8%, var(--app-card));
}
.timeline-existing-media-table .col-preview { width: 160px; }
.timeline-existing-media-table .col-back { min-width: 9rem; }
/* While a photo is dragged, every cell that can take it as a back image shows a dashed target. */
.timeline-existing-media-tbody.is-grouping-drag .col-back[data-accepts-back="true"] {
  outline: 2px dashed var(--app-border-strong, var(--app-muted)); outline-offset: -4px; border-radius: var(--app-radius);
}
.timeline-existing-media-table .col-back.is-back-drop-target {
  outline: 3px solid var(--app-accent); outline-offset: -4px; border-radius: var(--app-radius);
  background: color-mix(in srgb, var(--app-accent) 14%, var(--app-card));
}
.timeline-existing-media-table .col-back.is-back-drop-target::after {
  content: "Drop to use as the back image"; display: block; margin-top: .35rem; font-weight: 600; color: var(--app-accent);
}
@media (max-width: 640px) {
  .timeline-media-thumb { width: 96px; height: 96px; }
  .timeline-existing-media-table .col-preview { width: 112px; }
  .timeline-existing-media-table .col-size { display: none; }
}
.timeline-existing-media-row.is-back { background: var(--app-soft); }
.timeline-existing-media-row.is-back .col-preview, .timeline-existing-media-row.is-back .col-name { padding-left: 1.5rem; }
.timeline-existing-media-row.is-back .col-preview { padding-left: 1.75rem; }
.timeline-existing-media-row.is-back .col-name .timeline-back-label { margin-bottom: .2rem; }
.timeline-existing-media-table .timeline-media-group-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.timeline-existing-media-table .col-actions .timeline-headline-choice { margin-bottom: .35rem; }
.timeline-drag-controls {
  display: flex;
  align-items: center;
  gap: .25rem;
}
.timeline-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .25rem .35rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--app-muted);
  cursor: grab;
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
}
.timeline-drag-handle:hover,
.timeline-drag-handle:focus-visible {
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-border);
}
.timeline-drag-handle:active {
  cursor: grabbing;
}
.timeline-reorder-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: 1px solid var(--app-border);
  border-radius: 3px;
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: .65rem;
  cursor: pointer;
}
.timeline-reorder-btn:hover:not(:disabled) {
  color: var(--app-text);
  border-color: var(--app-accent);
}
.timeline-reorder-btn:disabled {
  opacity: .35;
  cursor: default;
}
.timeline-media-thumb {
  width: 144px;
  height: 144px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  background: var(--app-soft);
  border: 1px solid var(--app-border);
}
.timeline-media-doc-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background: var(--app-soft);
  font-size: 1.5rem;
}
.timeline-media-filename {
  font-weight: 600;
  color: var(--app-text);
  word-break: break-word;
}
.timeline-media-caption {
  font-size: .8rem;
  color: var(--app-muted);
  margin-top: .15rem;
}
.timeline-media-remove-btn {
  padding: .3rem .6rem;
  font-size: .8rem;
}

.timeline-post-legacy-help{display:block;font-weight:400;opacity:.8;margin:.15rem 0 .35rem}.timeline-post-legacy-badge{display:inline-block;margin:.2rem 0}
.timeline-link-fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(11rem,.45fr);gap:var(--space-4);align-items:start}.timeline-link-fields>.timeline-link-show-all{grid-column:1/-1;justify-self:start;margin:calc(var(--space-1) - var(--space-4)) 0 0;padding:0;border:0;background:none;color:var(--app-accent);font:inherit;font-size:.88rem;text-align:left;cursor:pointer;text-decoration:underline}.timeline-link-fields>.timeline-link-suggestion{grid-column:1/-1;margin:calc(var(--space-1) - var(--space-4)) 0 0}.timeline-link-suggestion{margin:0;font-size:.88rem}
.timeline-empty-state{margin:0;padding:var(--space-4);border:1px dashed var(--app-border);border-radius:var(--app-radius);color:var(--app-muted);text-align:center}@media(max-width:600px){.timeline-link-fields{grid-template-columns:1fr}}.timeline-link-suggestion button{margin-left:.35rem}
.timeline-event-links{display:grid;gap:.15rem;margin:.35rem 0}.timeline-event-link-line{margin:0;color:var(--app-muted);font-size:.88rem}.timeline-event-link{color:var(--app-accent);font-weight:650;text-decoration:none}a.timeline-event-link:hover,a.timeline-event-link:focus-visible{text-decoration:underline}

/* Back toggle under a post photo and in its full-screen view. */
.timeline-photo-back-toggle { margin-top: .35rem; padding: .25rem .6rem; font-size: .85rem; }
.timeline-photo-preview-dialog .timeline-photo-back-toggle { justify-self: center; }
.timeline-photo-tag-host[data-showing-back="true"] .media-region-layer,
.timeline-photo-tag-host[data-showing-back="true"] .media-region-add { display: none !important; }
.timeline-story-mine{display:grid;gap:var(--space-2);margin-top:var(--space-3);padding-top:var(--space-3);border-top:1px solid var(--app-border)}
.timeline-story-mine textarea{width:100%;min-height:6rem;resize:none;overflow:hidden}
.timeline-story-mine-actions{display:flex;flex-wrap:wrap;gap:var(--space-2)}
.timeline-story-item-head{display:flex;align-items:baseline;justify-content:space-between;gap:var(--space-3)}
.timeline-duplicate-hint{display:grid;justify-items:start;gap:var(--space-2);margin:var(--space-2) 0;text-align:left}
.timeline-duplicate-hint[hidden]{display:none}
.timeline-duplicate-heading{margin:0;font-weight:600}
.timeline-duplicate-use,.timeline-duplicate-dismiss{min-height:44px;text-align:left}
