/* ThreadFeed — dense, responsive, no framework */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --text: #14181d;
  --muted: #5d6a78;
  --border: #d9dfe6;
  --border-strong: #c3ccd6;
  --accent: #0b62c4;
  --accent-soft: #e5effc;
  --ok: #137a4b;
  --ok-soft: #e3f6ec;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --radius: 8px;
}
html[data-theme="dark"] {
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1c232c;
  --text: #e7ecf2;
  --muted: #93a1b1;
  --border: #262f3a;
  --border-strong: #34404e;
  --accent: #6fa8ff;
  --accent-soft: #17263c;
  --ok: #5cd39a;
  --ok-soft: #10281e;
  --danger: #ff8a80;
  --danger-soft: #2d1615;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #0e1116;
    --panel: #151a21;
    --panel-2: #1c232c;
    --text: #e7ecf2;
    --muted: #93a1b1;
    --border: #262f3a;
    --border-strong: #34404e;
    --accent: #6fa8ff;
    --accent-soft: #17263c;
    --ok: #5cd39a;
    --ok-soft: #10281e;
    --danger: #ff8a80;
    --danger-soft: #2d1615;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--panel-2); padding: .1em .35em; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--panel); padding: .6rem 1rem; border: 1px solid var(--border);
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* layout */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1rem .75rem; gap: 1.1rem;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 0 .4rem; }
.brand { font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav-block { display: flex; flex-direction: column; gap: .3rem; }
.nav-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 0 .5rem; margin-bottom: .2rem; font-weight: 600;
}
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .42rem .5rem; border-radius: 6px; color: var(--text); font-size: .92rem;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav.sub a { padding: .32rem .5rem; font-size: .86rem; }
.nav-source-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-empty { padding: .3rem .5rem; color: var(--muted); font-size: .82rem; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.4rem; padding: .05rem .38rem; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .72rem; font-weight: 600;
}
.badge.small { background: var(--panel-2); color: var(--muted); }
.nav a.active .badge.small { background: var(--accent); color: #fff; }
.sidebar-footer {
  margin-top: auto; border-top: 1px solid var(--border); padding: .8rem .5rem 0;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .82rem;
}
.main { padding: 1.4rem clamp(1rem, 3vw, 2.4rem) 3rem; min-width: 0; max-width: 1180px; }
.nav-toggle { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }

/* buttons */
.btn, .btn-secondary, .icon-btn, .link-btn {
  font: inherit; cursor: pointer; border-radius: 6px; transition: background .12s, border-color .12s;
}
.btn {
  display: inline-block; padding: .45rem .85rem; background: var(--accent); color: #fff;
  border: 1px solid var(--accent); font-weight: 600; font-size: .9rem;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn-secondary {
  display: inline-block; padding: .38rem .75rem; background: var(--panel);
  color: var(--text); border: 1px solid var(--border-strong); font-size: .87rem;
}
.btn-secondary:hover { background: var(--panel-2); text-decoration: none; }
.btn-secondary[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  width: 1.9rem; height: 1.9rem; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.link-btn { background: none; border: none; color: var(--accent); padding: .15rem .2rem; font-size: .85rem; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.inline { display: inline; margin: 0; }
.inline-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }

/* flashes / pills */
.flash {
  padding: .6rem .85rem; border-radius: var(--radius); margin-bottom: 1rem;
  border: 1px solid var(--border); font-size: .9rem;
}
.flash.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.flash.err { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.flash ul { margin: 0; padding-left: 1.1rem; }
.pill {
  display: inline-block; padding: .05rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: var(--panel-2); color: var(--muted);
  border: 1px solid transparent; white-space: nowrap;
}
.pill.links { background: var(--accent-soft); color: var(--accent); }
.pill.images { background: var(--ok-soft); color: var(--ok); }
.pill.rss { background: var(--accent-soft); color: var(--accent); }
.pill.error { background: var(--danger-soft); color: var(--danger); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.text-error { color: var(--danger); }

/* page chrome */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.1rem;
}
.page-title h1 { font-size: 1.5rem; letter-spacing: -.02em; }
.page-title p { margin: .2rem 0 0; font-size: .9rem; }
.toolbar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.toolbar input[type="search"] { min-width: 210px; }
.list-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: .6rem; padding: 0 .2rem;
}

/* inputs */
input[type="text"], input[type="url"], input[type="number"], input[type="password"],
input[type="search"], input[type="file"], select, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: .4rem .55rem;
  max-width: 100%;
}
input[type="search"] { padding-left: .6rem; }
textarea { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
button[type="submit"] { font: inherit; }
.toolbar button, .list-toolbar button {
  padding: .4rem .7rem; border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--panel); color: var(--text); cursor: pointer; font-size: .87rem;
}
.toolbar button:hover { background: var(--panel-2); }

/* thread list */
.thread-list { display: flex; flex-direction: column; gap: .4rem; }
.thread {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto;
  align-items: center; gap: .7rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem .75rem; box-shadow: var(--shadow);
}
.thread.unread { border-left: 3px solid var(--accent); padding-left: .65rem; }
.unread-dot {
  width: 7px; height: 7px; border-radius: 50%; background: transparent; justify-self: center;
}
.thread.unread .unread-dot { background: var(--accent); }
.thread-title { font-size: .98rem; font-weight: 600; line-height: 1.3; }
.thread-title a { color: var(--text); }
.thread-title a:hover { color: var(--accent); text-decoration: none; }
.fav-mark { color: #d9a406; margin-left: .25rem; font-size: .85rem; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; margin-top: .15rem; font-size: .79rem; color: var(--muted); }
.source-name { font-weight: 600; color: var(--muted); }
.sep { opacity: .5; }
.counts { margin-left: .15rem; }
.thumb { display: block; width: 52px; height: 40px; border-radius: 5px; overflow: hidden; background: var(--panel-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-actions { display: flex; align-items: center; gap: .05rem; }
.row-actions form { display: flex; }

/* detail */
.breadcrumb { font-size: .85rem; margin-bottom: .8rem; display: flex; gap: .4rem; align-items: center; }
.thread-head { margin-bottom: 1rem; }
.thread-head h1 { font-size: 1.55rem; letter-spacing: -.02em; margin-bottom: .35rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.detail-actions form { display: inline-flex; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a {
  padding: .45rem .8rem; color: var(--muted); font-size: .9rem; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.posts { display: flex; flex-direction: column; gap: .8rem; }
.post { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .85rem; }
.post-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding-bottom: .45rem; border-bottom: 1px dashed var(--border); margin-bottom: .55rem;
  font-size: .8rem; color: var(--muted);
}
.author { font-weight: 600; color: var(--text); }
.post-link { margin-left: auto; font-size: .8rem; }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.link-list li {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  padding: .25rem .4rem; border-radius: 5px; font-size: .92rem;
}
.link-list li.is-new { background: var(--accent-soft); }
.new-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: none; align-self: center; }
.is-new > .new-dot { background: var(--accent); }
.link-list a { overflow-wrap: anywhere; }
.domain { color: var(--muted); font-size: .76rem; }
.copy {
  font: inherit; font-size: .72rem; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 4px; padding: .05rem .35rem; cursor: pointer;
}
.copy:hover { color: var(--text); }
.image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .55rem; margin-top: .55rem;
}
.image-grid figure { margin: 0; position: relative; border-radius: 6px; overflow: hidden; background: var(--panel-2); }
.image-grid figure.is-new { outline: 2px solid var(--accent); outline-offset: -2px; }
.image-grid a { display: block; aspect-ratio: 4 / 3; }
.image-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-grid figcaption {
  position: absolute; right: .3rem; bottom: .3rem; font-size: .68rem;
  background: rgba(0, 0, 0, .65); border-radius: 4px; padding: .05rem .3rem;
}
.image-grid figcaption a { color: #fff; }
.image-grid figure.broken img { display: none; }
.image-grid figure.broken a[data-lightbox] { display: none; }
.image-grid figure.broken { max-height: 180px; }
.image-fallback { display: none; }
.image-grid figure.broken .image-fallback {
  display: flex; align-items: center; justify-content: center; gap: .25rem;
  min-height: 64px; max-height: 180px; padding: .6rem; color: var(--muted);
  font-size: .78rem; text-align: center; flex-wrap: wrap;
}

/* lightbox */
.lightbox {
  border: none; border-radius: 10px; padding: 0; background: rgba(10, 12, 15, .96);
  color: #fff; max-width: min(96vw, 1400px); width: auto;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .75); }
.lightbox-inner { position: relative; display: flex; align-items: center; gap: .4rem; padding: .6rem; }
.lightbox img { max-width: min(88vw, 1200px); max-height: 80vh; object-fit: contain; display: block; border-radius: 6px; }
.lightbox-close, .lightbox-prev, .lightbox-next {
  background: rgba(255, 255, 255, .12); color: #fff; border: none; border-radius: 50%;
  width: 2.2rem; height: 2.2rem; font-size: 1.2rem; cursor: pointer; flex: none;
}
.lightbox-close { position: absolute; top: .4rem; right: .4rem; z-index: 2; }
.lightbox-caption { margin: 0; padding: 0 .9rem .7rem; font-size: .8rem; text-align: center; }
.lightbox-caption a { color: #9cc4ff; }

/* empty state */
.empty-state {
  text-align: center; padding: 3rem 1rem; background: var(--panel);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty-state h2 { font-size: 1.1rem; margin-bottom: .4rem; }
.empty-state p { color: var(--muted); margin: .4rem 0; }

/* pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.2rem; font-size: .88rem; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td { padding: .55rem .65rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.data-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table.compact th, .data-table.compact td { padding: .35rem .5rem; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.actions-cell { white-space: nowrap; display: flex; flex-wrap: wrap; gap: .1rem .35rem; align-items: baseline; }
.actions-cell form { display: inline; }
.url-cell { overflow-wrap: anywhere; }
.test-slot:not(:empty) { margin-top: .3rem; }
.test-result { margin: .2rem 0 0; font-size: .8rem; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: var(--danger); }

/* cards / forms */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.card h2 { font-size: 1.02rem; margin-bottom: .5rem; }
.section-title { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; }
.field > span { font-weight: 600; font-size: .84rem; }
.span-2 { grid-column: 1 / -1; }
.hint { color: var(--muted); font-size: .76rem; }
.checks { border: 1px solid var(--border); border-radius: 6px; padding: .6rem .8rem; display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; }
.checks legend { font-weight: 600; font-size: .84rem; padding: 0 .3rem; }
.checks label { display: inline-flex; align-items: center; gap: .35rem; font-size: .87rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.file-field { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }

/* auth */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.6rem; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.35rem; margin-bottom: 1rem; letter-spacing: -.02em; }
.auth-form { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1rem; }
.auth-form .btn { margin-top: .3rem; }

/* responsive */
@media (max-width: 900px) {
  html { font-size: 14.5px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50;
    transform: translateX(-102%); transition: transform .18s ease;
    height: 100dvh; box-shadow: 0 0 30px rgba(0, 0, 0, .2);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: .35rem; position: fixed; top: .6rem; left: .6rem;
    z-index: 60; background: var(--panel); color: var(--text); border: 1px solid var(--border-strong);
    border-radius: 6px; padding: .35rem .6rem; font: inherit; font-size: .85rem; cursor: pointer;
  }
  .main { padding-top: 3.2rem; padding-left: 1rem; padding-right: 1rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .thread { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .thumb { display: none; }
  .toolbar { width: 100%; }
  .toolbar input[type="search"] { flex: 1 1 100%; }
  .data-table { min-width: 720px; }
  .detail-actions { gap: .3rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------- STU-9 enhancements */
.sort-form { display: flex; align-items: center; gap: .45rem; font-size: .87rem; }
.sort-label { color: var(--muted); font-weight: 600; }
.info-tip { color: var(--muted); cursor: help; font-size: .9rem; }

.pill.repaired {
  background: var(--panel-2); color: var(--muted); border: 1px dashed var(--border-strong);
  cursor: help;
}
.image-pill { position: absolute; left: .3rem; top: .3rem; z-index: 2; }

.hide-btn {
  font: inherit; font-size: .78rem; line-height: 1; color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: 4px; padding: .1rem .28rem; cursor: pointer;
  opacity: .45; transition: opacity .12s, background .12s, color .12s;
}
.hide-btn:hover, .hide-btn:focus-visible { color: var(--danger); background: var(--danger-soft); }
.link-list li:hover .hide-btn,
.link-list li:focus-within .hide-btn,
.image-grid figure:hover .hide-btn,
.image-grid figure:focus-within .hide-btn { opacity: 1; }
.image-hide { position: absolute; right: .3rem; top: .3rem; z-index: 3; margin: 0; }
.image-hide .hide-btn { opacity: .7; background: rgba(0, 0, 0, .55); color: #fff; }
.image-grid figure:hover .image-hide .hide-btn,
.image-grid figure:focus-within .image-hide .hide-btn { opacity: 1; }

/* message-to-message navigation */
.detail-nav {
  position: sticky; top: 0; z-index: 22; display: flex; flex-direction: column;
  gap: .4rem; margin: 0 0 .8rem;
}
.detail-nav > .post-nav { position: static; margin: 0; }
.thread-nav {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .35rem .45rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.thread-nav-link {
  font-size: .84rem; font-weight: 600; padding: .3rem .55rem; border-radius: 6px;
  border: 1px solid transparent; color: var(--text); text-decoration: none;
  max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-nav-link:hover { border-color: var(--accent); color: var(--accent); }
.thread-nav-spacer { flex: 0 0 1px; }
.thread-nav-status { display: flex; flex-direction: column; align-items: center; gap: .05rem; min-width: 0; }
.thread-counter { font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; }
.thread-nav-hint { font-size: .72rem; white-space: nowrap; }
.thread.row-target { outline: 2px solid var(--accent); outline-offset: 2px; }

.post-nav {
  position: sticky; top: 0; z-index: 22; display: flex; align-items: center;
  justify-content: space-between; gap: .5rem; margin: 0 0 .8rem; padding: .35rem .45rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.post-nav-btn {
  font: inherit; font-size: .86rem; font-weight: 600; min-height: 38px; padding: .35rem .7rem;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; cursor: pointer;
}
.post-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.post-nav-btn:disabled { opacity: .45; cursor: default; }
.post-nav-status { display: flex; flex-direction: column; align-items: center; gap: .05rem; min-width: 0; }
.post-counter { font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; }
.post-position { font-size: .76rem; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post.post-target, .post-anchor.post-target { outline: 2px solid var(--accent); outline-offset: 2px; }
.post-anchor:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* carousel dialog */
.lightbox.carousel {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
  border-radius: 0; background: rgba(8, 10, 14, .97); overflow: hidden;
}
.carousel-shell { display: flex; flex-direction: column; height: 100%; padding: .6rem; gap: .4rem; }
.carousel-main { flex: 1; display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 0; }
.carousel-stage { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .35rem; min-width: 0; min-height: 0; }
.carousel #lightbox-img { max-width: min(94vw, 1500px); max-height: calc(100dvh - 190px); object-fit: contain; }
.carousel-arrow {
  flex: none; width: 2.8rem; height: 2.8rem; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.5rem; cursor: pointer;
}
.carousel-arrow:hover { background: rgba(255, 255, 255, .26); }
.carousel-close { position: absolute; top: .5rem; right: .5rem; z-index: 4; }
.carousel-meta {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: .4rem 1rem; padding: .15rem .5rem; color: #d7e2ef; font-size: .82rem;
}
.carousel-meta a { color: #9cc4ff; }
.carousel-counter { font-weight: 700; font-variant-numeric: tabular-nums; }
.carousel-thumbs {
  display: flex; gap: .4rem; justify-content: center; overflow-x: auto; padding: .2rem .2rem .4rem;
  flex: none;
}
.carousel-thumbs button {
  flex: none; width: 62px; height: 46px; padding: 0; border: 2px solid transparent;
  border-radius: 5px; overflow: hidden; background: #1a222c; cursor: pointer;
}
.carousel-thumbs button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carousel-thumbs button[aria-current="true"] { border-color: var(--accent); }

@media (hover: none) {
  .hide-btn { opacity: 1; }
  .image-hide .hide-btn { opacity: 1; }
}
@media (max-width: 900px) {
  .main:has(.post-nav) { padding-bottom: 5.4rem; }
  .detail-nav > .post-nav {
    position: fixed; left: .5rem; right: .5rem; bottom: .5rem; top: auto; margin: 0;
    padding: .4rem; box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
  }
  .post-nav {
    position: fixed; left: .5rem; right: .5rem; bottom: .5rem; top: auto; margin: 0;
    padding: .4rem; box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
  }
  .thread-nav-link { max-width: 28vw; }
  .post-nav-btn { min-height: 46px; flex: 1; }
  .post-position { max-width: 38vw; }
  .hide-btn { opacity: 1; }
  .image-hide .hide-btn { opacity: 1; }
  .lightbox.carousel { width: 100vw; }
}
@media (max-width: 560px) {
  .thread-nav-hint { display: none; }
}
