/* Event Categorizer — quiet white UI. One accent, lots of air, no chrome. */

:root {
  --ink: #16181d;
  --ink-2: #5a6070;
  --ink-3: #8b91a1;
  --line: #e8eaf0;
  --line-2: #f1f2f6;
  --bg: #ffffff;
  --bg-2: #fbfcfd;
  --accent: #1a1d23;
  --accent-soft: #f4f5f8;
  --danger: #c0392b;
  --ok: #157347;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 32, .04), 0 8px 24px rgba(20, 24, 32, .06);
  --topbar-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
button { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 17px; color: var(--ink); }
.brand-name { font-weight: 600; letter-spacing: -.02em; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* -------------------------------------------------------------- atoms */

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 7px 13px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  transition: background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; }

.btn-ghost { border-color: var(--line); background: #fff; }
.btn-ghost:hover { background: var(--bg-2); border-color: #dcdfe8; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #2c3038; border-color: #2c3038; }

.btn-lg { padding: 11px 22px; font-size: 15px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: #fdf2f1; border-color: #f2d5d1; }

.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: #fff;
  white-space: nowrap;
}
.pill-ok { color: var(--ok); border-color: #cfe7d9; background: #f4faf6; }
.pill-off { color: var(--ink-3); }
.pill-err { color: var(--danger); border-color: #f2d5d1; background: #fdf6f5; }
.pill-muted { color: var(--ink-3); }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus { border-color: #c3c8d4; box-shadow: 0 0 0 3px rgba(26, 29, 35, .05); }
.select { cursor: pointer; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; color: var(--ink-2); font-size: 14px; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; }

.link { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.muted-sm { color: var(--ink-3); font-size: 12.5px; }
.spacer { flex: 1; }

/* ------------------------------------------------------------- upload */

.pane { max-width: 780px; margin: 0 auto; padding: 56px 24px 80px; }

.dropzone {
  border: 1.5px dashed #d8dbe4;
  border-radius: 18px;
  padding: 56px 40px 44px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-2);
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: #b9bece; background: #f8f9fb; outline: none; }
.dropzone.drag { border-color: var(--accent); background: #f4f5f8; }

.dz-icon {
  width: 42px; height: 42px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1.5px solid #d8dbe4;
  display: grid; place-items: center;
  font-size: 18px; color: var(--ink-2);
  background: #fff;
}
.dz-title { font-size: 22px; margin-bottom: 7px; }
.dz-sub { color: var(--ink-2); margin: 0 0 26px; font-size: 14.5px; }

.dz-notes {
  list-style: none;
  margin: 0; padding: 22px 0 0;
  border-top: 1px solid var(--line);
  display: grid; gap: 8px;
  text-align: left;
  max-width: 470px;
  margin-inline: auto;
  color: var(--ink-2);
  font-size: 13.5px;
}
.dz-notes li { padding-left: 20px; position: relative; }
.dz-notes li::before { content: '—'; position: absolute; left: 0; color: var(--ink-3); }

.file-list { margin-top: 20px; display: grid; gap: 6px; }
.file-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: #fff;
}
.file-chip .fc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-meta { color: var(--ink-3); font-size: 12.5px; }
.file-chip .fc-x {
  border: 0; background: transparent; color: var(--ink-3);
  cursor: pointer; font-size: 17px; line-height: 1; padding: 0 3px;
}
.file-chip .fc-x:hover { color: var(--danger); }

.dz-actions { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* ----------------------------------------------------------- progress */

.progress-card { text-align: center; padding: 40px 0; }
.prog-title { font-size: 19px; margin-bottom: 20px; }
.progress-track { height: 4px; background: var(--line-2); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.prog-detail { color: var(--ink-2); font-size: 14px; margin: 0 0 22px; }
.prog-steps { list-style: none; margin: 0 0 26px; padding: 0; display: grid; gap: 7px; text-align: left; max-width: 400px; margin-inline: auto; font-size: 13.5px; }
.prog-steps li { color: var(--ink-3); display: flex; gap: 9px; }
.prog-steps li.done { color: var(--ink); }
.prog-steps li.active { color: var(--ink); font-weight: 500; }
.prog-steps .mark { width: 15px; display: inline-block; }

/* ------------------------------------------------------------ results */

.results { display: grid; grid-template-columns: 288px 1fr; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 14px 20px 20px;
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidebar-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; padding-right: 6px; }
.sidebar-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.sidebar-foot { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.cat-list { display: grid; gap: 2px; }

.cat-row {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background .12s ease;
  /* A double-click pins; without this it would also highlight the account name,
     which looks like a mistake every single time. */
  user-select: none;
  -webkit-user-select: none;
}
.cat-row:hover { background: var(--accent-soft); }
.cat-row.active { background: var(--accent-soft); }
.cat-row.active .cat-name { font-weight: 600; }

/* Anything pinned is held at the top of its list for everyone looking at this
   library - see pins.js. The line under a pinned group is drawn by the first
   unpinned row that follows a pinned one, so nothing has to know which pin is
   last. */
.cat-row.pinned .cat-name,
#eventRows tr.pinned .ev-title { font-weight: 600; }

.pin-crown { font-size: 11px; line-height: 1; opacity: .8; }
.cat-row .pin-crown { flex: none; }
#eventRows tr.pinned .ev-title .pin-crown { margin-right: 5px; }

.cat-row.pinned + .cat-row:not(.pinned) {
  margin-top: 9px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
#eventRows tr.pinned > td { background: var(--accent-soft); }
#eventRows tr.pinned + tr:not(.pinned) > td { border-top: 1px solid var(--line); }

/* A double-tap here is a pin, not a zoom. Without this the browser keeps the
   gesture and the second tap never reaches the page. */
.cat-row,
#eventRows tr { touch-action: manipulation; }

.cat-avatar { width: 30px; height: 30px; border-radius: 8px; flex: none; display: block; }
.cat-all-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
}
.cat-body { min-width: 0; flex: 1; display: block; }
.cat-name {
  display: block; font-size: 13.5px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-meta { display: block; font-size: 11.5px; color: var(--ink-3); }

/* --------------------------------------------------------- content */

.content { padding: 24px 28px 80px; min-width: 0; }
.content-head { margin-bottom: 18px; }

.cat-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.hero-avatar { width: 52px; height: 52px; border-radius: 13px; flex: none; }
.hero-text { min-width: 0; }
.hero-name { font-size: 19px; font-weight: 600; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.hero-handle { color: var(--ink-3); font-size: 13px; font-weight: 400; }
.hero-bio { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; max-width: 640px; }
.hero-edit {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 12px; padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.hero-edit:hover { background: var(--bg-2); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar .select { width: auto; min-width: 130px; }

.stats-bar {
  margin-top: 14px;
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-3);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.stats-bar b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }
.events { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 14px; }
.events thead th {
  text-align: left;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.events tbody tr { border-bottom: 1px solid var(--line-2); transition: background .1s ease; }
.events tbody tr:hover { background: var(--bg-2); }
.events td { padding: 10px 12px; vertical-align: top; overflow: hidden; }

.c-when { width: 124px; }
.c-where { width: 186px; }
.c-cat { width: 156px; }
.c-act { width: 84px; }

.when-date { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.when-time { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.when-past { opacity: .55; }

.ev-main { display: flex; gap: 11px; align-items: flex-start; }
.ev-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex: none; background: var(--line-2); }
.ev-text { min-width: 0; flex: 1; }
.ev-title {
  font-weight: 500; cursor: pointer; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ev-title:hover { text-decoration: underline; text-underline-offset: 2px; }
.ev-blurb {
  color: var(--ink-2); font-size: 12.5px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
/* Tags stay on a single line — a wrapping tag list was tripling row height. */
.ev-tags { display: flex; gap: 5px; flex-wrap: nowrap; overflow: hidden; margin-top: 5px; }
.tag {
  font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.tag-dup { background: #fef6e7; color: #8a6516; }
.tag-series { background: #eef4ff; color: #2f5da8; }
.tag-free { background: #e7f7ec; color: #1c6b39; font-weight: 600; }
.tag-paid { background: #fdeceb; color: #a3352c; font-weight: 600; }
.tag-unknown { background: #f2f2f2; color: #6b6b6b; }
.tag-age { background: #f3ecff; color: #6034a8; font-weight: 600; }

.where-name { overflow: hidden; overflow-wrap: anywhere; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; }
.where-city { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.cat-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  max-width: 100%;
}
.cat-chip:hover { background: var(--bg-2); }
.cat-chip img { width: 18px; height: 18px; border-radius: 5px; flex: none; }
.cat-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center; cursor: pointer;
  font-size: 13px; line-height: 1;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn.danger:hover { background: #fdf2f1; color: var(--danger); border-color: #f2d5d1; }

.empty { padding: 70px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }

/* ------------------------------------------------------------ modals */

.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 24, 32, .28);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .12s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal-wide { max-width: 620px; }
.modal-card h2 { font-size: 17px; margin-bottom: 20px; }

.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field-hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.field .check { margin-top: 8px; }

.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 22px; }
.cfg-result { font-size: 12.5px; margin: 12px 0 0; min-height: 17px; }
.cfg-result.ok { color: var(--ok); }
.cfg-result.err { color: var(--danger); }

.export-grid { display: grid; gap: 8px; }
.export-opt {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  display: grid; gap: 3px;
  transition: background .12s, border-color .12s;
}
.export-opt:hover { background: var(--bg-2); border-color: #dcdfe8; }
.export-opt b { font-weight: 600; font-size: 14px; }
.export-opt span { color: var(--ink-3); font-size: 12.5px; }

/* ------------------------------------------------- detail / account */

.detail-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.detail-img { width: 92px; height: 92px; border-radius: 11px; object-fit: cover; flex: none; background: var(--line-2); }
.detail-title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.detail-when { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.detail-rows { display: grid; gap: 11px; margin-bottom: 18px; }
.detail-row { display: grid; grid-template-columns: 92px 1fr; gap: 12px; font-size: 13.5px; }
.detail-row dt { color: var(--ink-3); font-size: 12.5px; }
.detail-row dd { margin: 0; word-break: break-word; }
.detail-desc { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-2); max-height: 220px; overflow-y: auto; }
.ics-preview {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  max-height: 210px;
  color: var(--ink-2);
}

.acct-head { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.acct-avatar { width: 76px; height: 76px; border-radius: 18px; flex: none; }
.acct-name { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.acct-handle { color: var(--ink-3); font-size: 13px; }
.acct-tagline { color: var(--ink-2); font-size: 13px; margin-top: 3px; font-style: italic; }
.acct-field { margin-bottom: 15px; }
.acct-field .field-label { margin-bottom: 5px; }
.acct-count { font-size: 12.5px; color: var(--ink-3); margin-bottom: 16px; }

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 120;
  background: var(--accent);
  color: #fff;
  padding: 11px 16px;
  border-radius: 11px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
  font-size: 13.5px;
  animation: rise .16s ease;
  max-width: min(90vw, 520px);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast-action {
  border: 0; background: transparent; color: #fff;
  font-weight: 600; cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px; padding: 0;
}

/* ------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .results { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; max-height: 232px;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 16px 20px;
  }
  .content { padding: 20px 18px 70px; }
  .c-where, .c-cat { display: none; }
  .c-when { width: 96px; }
  .c-act { width: 74px; }
  .topbar { padding: 12px 16px; }
  .topbar-actions .btn { padding: 7px 10px; }
  .pane { padding: 32px 18px 60px; }
  .dropzone { padding: 40px 22px 34px; }
}

/* ------------------------------------------------------- media gallery */

.ev-thumb-wrap { position: relative; flex: none; display: block; width: 42px; height: 42px; }
.thumb-next {
  position: absolute; right: -4px; bottom: -4px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 9.5px; line-height: 1; padding: 2px 4px; border-radius: 5px;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.thumb-next:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.gal-item {
  position: relative; padding: 0; cursor: pointer; overflow: hidden;
  border: 2px solid var(--line); border-radius: 9px; background: var(--line-2);
  aspect-ratio: 4 / 3;
}
.gal-item:hover { border-color: #c3c8d4; }
.gal-item.active { border-color: var(--accent); }
.gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-src {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.62));
  color: #fff; font-size: 9.5px; padding: 10px 5px 3px; text-align: left;
}

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.video-box { margin-bottom: 12px; }
.video-box iframe {
  width: 100%; aspect-ratio: 16 / 9; border: 0;
  border-radius: 10px; background: #000; display: block;
}

.acct-photo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.field-hint-inline { font-weight: 400; color: var(--ink-3); }
.sidebar-foot .btn + .btn { margin-top: 6px; }

/* Photo avatars are real images — keep them cropped and consistent. */
.cat-avatar, .hero-avatar, .acct-avatar { object-fit: cover; background: var(--line-2); }

/* ------------------------------------------------------------- history */

.modal-sub { color: var(--ink-2); font-size: 13px; margin: -10px 0 18px; }

.hist-actions {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}

.hist-list { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }

.hist-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid; gap: 6px;
  background: #fff;
}
.hist-item.current { border-color: #cfe7d9; background: #f7fbf8; }
.hist-top { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.hist-label { font-weight: 600; font-size: 14px; }
.hist-when { color: var(--ink-3); font-size: 12px; }
.hist-badge {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--line-2); color: var(--ink-2);
}
.hist-badge.pin { background: #fef6e7; color: #8a6516; }
.hist-counts { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hist-diff { color: var(--ink-3); font-size: 12px; }
.hist-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.hist-empty { padding: 30px 10px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* ------------------------------------------------------------ lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12, 14, 18, .93);
  display: grid; grid-template-rows: 1fr auto;
  animation: fade .12s ease;
}
.lb-stage {
  display: grid; place-items: center;
  padding: 46px 64px 10px; min-height: 0; overflow: hidden;
}
.lb-stage img, .lb-stage video, .lb-stage iframe {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 8px; display: block;
  background: #000;
}
.lb-stage iframe { width: min(1100px, 92vw); aspect-ratio: 16/9; height: auto; border: 0; }
.lb-stage .lb-missing { color: #cfd3dc; font-size: 14px; text-align: center; max-width: 420px; line-height: 1.6; }

.lb-close, .lb-nav {
  position: absolute; z-index: 2;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08); color: #fff;
  cursor: pointer; border-radius: 999px;
  display: grid; place-items: center;
  transition: background .12s ease;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-close { top: 14px; right: 16px; width: 38px; height: 38px; font-size: 22px; line-height: 1; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 28px; line-height: 1; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }

.lb-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px 16px; color: #e8eaf0; font-size: 12.5px;
}
.lb-bar .btn-ghost {
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff;
  text-decoration: none;
}
.lb-bar .btn-ghost:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); }
.lb-caption { color: #cfd3dc; max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { color: #9aa1ae; font-variant-numeric: tabular-nums; }

/* anything clickable into the lightbox */
.zoomable { cursor: zoom-in; }

@media (max-width: 700px) {
  .lb-stage { padding: 44px 12px 8px; }
  .lb-nav { width: 38px; height: 38px; font-size: 22px; }
  .lb-caption { max-width: 100%; white-space: normal; }
}

/* --------------------------------------------------------- lightbox music */

.lb-music {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08); color: #fff;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; max-width: 340px;
}
.lb-music:hover { background: rgba(255,255,255,.2); }
.lb-music.playing { background: rgba(255,255,255,.26); border-color: rgba(255,255,255,.4); }
.lb-music span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbMusicIcon { font-size: 11px; width: 11px; text-align: center; }

.ev-music {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--ink-3);
  margin-top: 3px;
}

/* ------------------------------------------------------------------ sync */

.modal-tall { max-width: 940px; }

.sync-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px; margin-bottom: 20px;
}
.sync-stat {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px;
}
.sync-stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.sync-stat span { font-size: 11.5px; color: var(--ink-3); }

.sync-grid { display: grid; grid-template-columns: 260px 1fr; gap: 22px; align-items: start; }
.sync-col-wide { min-width: 0; }
.sync-h {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); margin: 22px 0 8px;
}
.sync-col .sync-h:first-child { margin-top: 0; }

.sync-share { display: grid; gap: 6px; font-size: 12.5px; }
.sync-share code {
  display: block; padding: 6px 8px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 12px; word-break: break-all;
}

.sync-editor-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sync-code {
  width: 100%; min-height: 210px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55; white-space: pre; overflow-x: auto;
}
.sync-preview, .sync-code-block {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-top: 10px; max-height: 240px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.55; white-space: pre;
}
.sync-preview.err { color: var(--danger); }

.sync-run { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sync-log {
  max-height: 150px; overflow-y: auto; font-size: 12px; color: var(--ink-2);
  display: grid; gap: 3px;
}
.sync-log-row { display: flex; gap: 8px; }
.sync-log-row b { font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 500; min-width: 62px; }
.sync-log-row.err { color: var(--danger); }

@media (max-width: 860px) {
  .sync-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------- reading over the link */

/* Someone on the share link may pin, and may do nothing else. They were still
   shown Clear all, Settings, the per-row delete and the rest; pressing one
   changed the page - the row vanished, the toast said "Deleted" - while the
   server refused the save, so a reload put it all back. The app was telling
   them something untrue, so what cannot work is not offered. The server
   decides who is a guest, from which listener the request arrived on. */
body.is-guest [data-owner-only] { display: none !important; }

.guest-loading { padding: 90px 24px; text-align: center; color: var(--ink-3); }
.guest-loading p { margin: 0 0 6px; }
.guest-loading-mark {
  width: 30px; height: 30px; margin: 0 auto 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: guest-spin .9s linear infinite;
}
@keyframes guest-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .guest-loading-mark { animation: none; } }
