/* Reading-first refinements shared by every appearance. Theme-specific colour
   and decorative accents belong in themes.css; density owns spacing. */

.forum-list, .topic-list, .inbox-list, .search-topic-list,
.search-result-item, .search-entity-card, .history-item {
    box-shadow: none;
}
.forum-row, .topic-row { border-bottom-color: var(--ui-rule, var(--panel-border)); }
.forum-stats { border: 0; }
.forum-last-post { gap: 1px; }
.forum-last-post a { font-weight: 700; }
.forum-last-post small { font-size: .74rem; }
.username-link { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; }
.username-link:hover { color: var(--primary-color); text-decoration-color: currentColor; }

/* Topic indexes need a firm reading order: subject first, supporting data second. */
.topic-title > a {
    font-size: clamp(1rem, .97rem + .12vw, 1.075rem);
    line-height: 1.32;
}
.topic-meta {
    margin-top: 4px;
    font-size: .75rem;
    font-weight: 400;
    line-height: 1.55;
}
.topic-meta a { font-size: inherit; }
.topic-meta .username-link,
.topic-last .username-link {
    font-weight: 500;
    text-decoration: none;
}
.topic-meta .username-link:hover,
.topic-meta .username-link:focus-visible,
.topic-last .username-link:hover,
.topic-last .username-link:focus-visible { text-decoration: underline; }
.topic-stats { font-size: .78rem; font-weight: 500; }
.topic-last { font-size: .75rem; line-height: 1.5; }
.topic-last time { color: var(--text-color); font-weight: 600; }
.topic-page-shortcuts { align-items: center; gap: 2px; margin-left: 8px; font-size: .68rem; }
.topic-page-shortcuts a { min-width: 20px; padding: 0 4px; font-weight: 600; text-decoration: none; }
.topic-meta .topic-moderation-link { font-weight: 500; }
.home-discovery { background: color-mix(in srgb, var(--panel-bg) 82%, var(--bg-color)); }
.forum-highlights .expand-hint { color: var(--text-muted); }

.forum-view .header-actions { flex-wrap: wrap; justify-content: flex-end; }
.forum-view .header-actions > *,
.forum-view .header-actions .btn,
.forum-view .header-actions button { white-space: nowrap; }
.topic-view > .page-heading { margin-bottom: 8px; padding-bottom: 10px; }
.topic-view > .topic-participants { margin: 8px 0; }
.topic-view > .pagination { margin: 8px 0 13px; padding: 7px 10px; }
.topic-view .topic-state .btn-sm:not(.latest-topic-action) { color: var(--text-muted); }
.topic-view .posts-list .post-body { font-size: 13px; line-height: 1.5; }

/* Search uses an immediately useful primary row and optional, wrapping filters. */
.search-filters { min-width: 0; }
.search-filter-primary {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
}
.search-filter-primary .form-group, .search-filter-grid .form-group { min-width: 0; margin: 0; }
.search-filter-primary input, .search-filter-grid input,
.search-filter-grid select { width: 100%; min-width: 0; }
.search-filter-primary .btn { white-space: nowrap; }
.search-more-filters { margin-top: 10px; }
.search-more-filters > summary { width: max-content; padding: 6px 0; color: var(--primary-color); cursor: pointer; font-size: .82rem; font-weight: 700; }
.search-more-filters > summary:hover { text-decoration: underline; }
.search-filter-grid, .search-filter-grid-expanded {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
    gap: 12px;
    align-items: end;
    margin-top: 10px;
}
.search-filter-submit { margin-top: 12px; }
.search-result-item { margin-bottom: 8px; border-left: 0; border-bottom: 1px solid var(--ui-rule); }
.search-topic-list > .search-topic-entry { display: flex; flex-direction: column; gap: 3px; padding: 14px 18px; border-bottom: 1px solid var(--panel-border); }
.search-topic-list > .search-topic-entry:last-child { border-bottom: 0; }
.search-topic-entry > a { text-decoration: none; }
.archive-topic-list > .archive-topic-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 20px; padding: 15px 18px; border-bottom: 1px solid var(--panel-border); }
.archive-topic-list > .archive-topic-entry:last-child { border-bottom: 0; }
.archive-topic-list .archive-topic-entry a { display: inline; padding: 0; border: 0; background: transparent; }
.archive-topic-list .archive-topic-entry a:hover { background: transparent; }
.archive-topic-entry > a { min-width: 0; color: var(--text-color); text-decoration: none; }
.archive-topic-entry > a:hover, .search-topic-entry > a:hover { color: var(--primary-color); text-decoration: underline; }
.archive-topic-entry > span { grid-column: 1; color: var(--text-muted); font-size: .78rem; }
.archive-topic-entry > time { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
@media (max-width: 820px) { .archive-topic-list > .archive-topic-entry { grid-template-columns: 1fr; } .archive-topic-entry > time { grid-column: 1; grid-row: auto; white-space: normal; } }

/* A compact archive timeline, rather than a stack of equal-weight cards. */
.history-list { gap: 0; padding-left: 18px; border-left: 2px solid var(--ui-rule); }
.history-year-heading { margin: 20px 0 3px -19px; padding: 2px 0 2px 16px; border-left: 3px solid var(--accent); color: var(--accent-strong); font: 800 1.08rem/1.3 var(--heading-font); list-style: none; }
.history-year-heading:first-child { margin-top: 0; }
.history-item { display: block; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--ui-rule); border-radius: 0; background: transparent; }
.history-item:hover { border-color: var(--ui-rule); background: color-mix(in srgb, var(--primary-color) 5%, var(--bg-color)); }
.history-item h2 { margin-bottom: 2px; font-size: 1rem; }
.history-item p { margin-top: 4px; }
.history-meta { color: var(--text-muted); font-size: .78rem; }
.history-excerpt { max-width: 80ch; line-height: 1.6; }

.inbox-section { margin-top: 20px; }
.inbox-up-to-date { margin: 0; padding: 8px 0; color: var(--text-muted); font-size: .82rem; }
.inbox-list li { gap: 12px; }
.inbox-list li > div { min-width: 0; }
.inbox-list time { white-space: nowrap; }
.profile-activity .activity-list { margin-top: 7px; }
.profile-activity .activity-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.profile-activity .activity-list li > div { display: grid; justify-items: start; min-width: 0; }
.profile-activity .activity-list li a { min-width: 0; text-align: left; font-weight: 700; }
.activity-context { color: var(--text-muted); font-size: .72rem; }
.activity-date { white-space: nowrap; }

/* Attachments stay discoverable without dominating the editor until needed. */
.composer-attachments { margin: -1px 0 12px; padding: 0; border: 1px solid var(--panel-border); border-radius: 0 0 6px 6px; background: var(--panel-bg); }
.composer-attachments > summary { padding: 9px 12px; cursor: pointer; color: var(--primary-color); font-size: .78rem; font-weight: 750; }
.composer-attachments > summary span { color: var(--text-muted); font-weight: 400; }
.composer-attachments[open] > summary { border-bottom: 1px solid var(--ui-rule); }
.composer-attachments > .form-group { margin: 0; padding: 12px; }
.composer-attachments .file-dropzone { min-height: 44px; }

/* The chooser previews a real hierarchy, and its actions remain available. */
.appearance-dialog { width: min(820px, calc(100% - 20px)); max-height: min(92dvh, 900px); overflow: hidden; }
.appearance-dialog-layout { display: flex; flex-direction: column; max-height: min(92dvh, 900px); }
.appearance-dialog .dialog-heading { flex: 0 0 auto; align-items: center; padding: 16px 18px 12px; border-bottom: 1px solid var(--ui-rule); }
.appearance-dialog .dialog-heading p { max-width: 60ch; color: var(--text-muted); font-size: .82rem; }
.appearance-dialog-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 18px 16px; }
.appearance-groups { gap: 16px; margin-top: 0; }
.appearance-groups legend { margin-bottom: 7px; }
.theme-options { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); grid-auto-rows: 144px; gap: 9px; }
.theme-option { position: relative; gap: 2px; width: 100%; height: 100%; min-width: 0; padding: 8px; border-radius: 5px; }
.theme-option:hover { border-color: var(--primary-color); }
.theme-option.is-selected { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.theme-option.is-selected::after { content: "✓ Selected"; position: absolute; top: 12px; right: 12px; padding: 2px 5px; border-radius: 3px; background: var(--panel-bg); color: var(--text-color); font-size: .63rem; font-weight: 800; }
.theme-option-name { font-size: .84rem; font-weight: 800; }
.theme-option small { color: var(--text-muted); font-size: .7rem; line-height: 1.25; }
.theme-preview { height: 84px; border: 1px solid color-mix(in srgb, var(--preview-text) 26%, transparent); border-radius: 3px; background: var(--preview-bg); color: var(--preview-text); font-family: var(--ui-font); }
.theme-preview .preview-nav { position: absolute; inset: 0 0 auto; height: 17px; padding: 1px 6px; background: var(--preview-text); color: var(--preview-surface); font-size: 9px; font-weight: 800; }
.theme-preview .preview-heading { position: absolute; left: 6px; right: 6px; top: 21px; padding: 2px 5px; background: var(--preview-accent); color: var(--preview-surface); font-size: 9px; font-weight: 800; }
.theme-preview .preview-row { position: absolute; left: 6px; right: 6px; top: 43px; display: flex; flex-direction: column; height: 33px; padding: 3px 5px; background: var(--preview-surface); text-align: left; }
.theme-preview .preview-row strong { overflow: hidden; max-width: 75%; color: var(--preview-text); font-size: 9px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.theme-preview .preview-row small { color: var(--preview-text); font-size: 8px; opacity: .72; }
.theme-preview .preview-button { position: absolute; right: 11px; top: 50px; padding: 2px 4px; background: var(--preview-accent); color: var(--preview-surface); font-size: 8px; font-weight: 800; }
[data-theme-choice="newsprint"] .theme-preview,[data-theme-choice="afterhours"] .theme-preview,[data-theme-choice="jungle"] .theme-preview { font-family: Georgia,serif; }
[data-theme-choice="terminal"] .theme-preview,[data-theme-choice="blueprint"] .theme-preview { font-family: Consolas,monospace; }
[data-theme-choice="y2k"] .theme-preview { border:2px outset #fff; border-radius:0; background:#008080; font-family:Tahoma,Verdana,sans-serif; }
[data-theme-choice="y2k"] .theme-preview .preview-nav { border:1px solid #000080; background:linear-gradient(90deg,#000080,#1084d0); color:#fff; }
[data-theme-choice="y2k"] .theme-preview .preview-heading { border:2px outset #fff; border-radius:0; background:#c0c0c0; color:#000; }
[data-theme-choice="y2k"] .theme-preview .preview-row { border:2px inset #eee; background:#fff; }
[data-theme-choice="y2k"] .theme-preview .preview-button { border:1px outset #fff; background:#c0c0c0; color:#000; }
[data-theme-choice="browser99"] .theme-preview,[data-theme-choice="irc99"] .theme-preview,[data-theme-choice="newsreader99"] .theme-preview { font-family: Tahoma,Verdana,sans-serif; }
[data-theme-choice="browser99"] .theme-preview .preview-nav { border-bottom: 5px solid #c0c0c0; background: #000080; color: #fff; }
[data-theme-choice="browser99"] .theme-preview .preview-nav::after { content: "  File  Edit  View  Go"; font-size: 6px; font-weight: 400; }
[data-theme-choice="browser99"] .theme-preview .preview-heading { top: 25px; border-top: 3px solid #008080; background: #d4d0c8; color: #000080; }
[data-theme-choice="irc99"] .theme-preview .preview-nav { border-bottom: 4px solid #c0c0c0; background: #000080; color: #fff; }
[data-theme-choice="irc99"] .theme-preview .preview-heading { background: #080808; color: #56c7ff; }
[data-theme-choice="irc99"] .theme-preview .preview-heading::before { content: "#"; color: #55ff55; }
[data-theme-choice="newsreader99"] .theme-preview .preview-nav { background: linear-gradient(90deg,#174a8b,#6e91bd); color: #fff; }
[data-theme-choice="newsreader99"] .theme-preview .preview-heading::before { content: "📁 "; }
[data-theme-choice="homepage99"] .theme-preview { border: 2px ridge #ff00ff; font-family: "Comic Sans MS",cursive; }
[data-theme-choice="homepage99"] .theme-preview .preview-nav { background: #ffff00; color: #ff0000; text-align: center; }
[data-theme-choice="homepage99"] .theme-preview .preview-heading { background: linear-gradient(90deg,#f00,#f0f,#00f); color: #fff; text-shadow: 1px 1px #000; }
[data-theme-choice="homepage99"] .theme-preview::after { content: "🚧 NEW!"; position: absolute; top: 18px; right: 9px; color: #00ff00; font: 800 8px "Comic Sans MS",cursive; animation: homepage-preview-blink 1.2s steps(1,end) infinite; }
[data-theme-choice="festive"] .theme-preview::after { content: "❄"; position: absolute; top: 18px; right: 12px; color: #fff; }
[data-theme-choice="spooky"] .theme-preview::after { content: "✦"; position: absolute; top: 17px; right: 12px; color: #f8df9b; }
[data-theme-choice="jungle"] .theme-preview::after { content: "•  ·  •"; position: absolute; top: 17px; right: 9px; color: #f4da76; text-shadow: 0 0 5px #f4da76; }
[data-theme-choice="ocean"] .theme-preview::after { content: "○  ◦"; position: absolute; top: 17px; right: 10px; color: #a5e3de; }
@keyframes homepage-preview-blink { 0%,54% { visibility: visible; } 55%,100% { visibility: hidden; } }
.appearance-dialog-footer { flex: 0 0 auto; padding: 10px 18px 14px; border-top: 1px solid var(--ui-rule); background: var(--panel-bg); }
.appearance-dialog .density-options { margin: 0 0 8px; }
.appearance-dialog .density-options legend { margin-bottom: 5px; font-size: .78rem; }
.appearance-dialog .density-options .btn { min-height: 32px; padding: 5px 9px; font-size: .75rem; }
.theme-motion-toggle:not([hidden]) { display: inline-block; margin-bottom: 8px; padding: 0; border: 0; background: transparent; color: var(--primary-color); cursor: pointer; font-size: .75rem; text-decoration: underline; }
.appearance-dialog-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.appearance-save-status { flex: 1 1 180px; color: var(--danger-color); font-size: .76rem; }
.appearance-dialog-actions .btn { white-space: nowrap; }

@media (max-width: 1100px) {
    .admin-layout { flex-direction: column; gap: 14px; }
    .admin-sidebar { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border-top: 0; border-left: 3px solid var(--accent); }
    .admin-sidebar nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; width: 100%; }
    .admin-sidebar h3 { flex: 0 0 auto; margin: 0; font-size: .9rem; }
    .admin-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
    .admin-nav li { margin: 0; }
    .admin-nav a { padding: 6px 9px; font-size: .76rem; }
    .admin-content { width: 100%; }
    .admin-filters { flex-wrap: wrap; }
    .admin-table-container { max-width: 100%; }
    .responsive-admin-table thead { display: none; }
    .responsive-admin-table, .responsive-admin-table tbody,
    .responsive-admin-table tr, .responsive-admin-table td { display: block; width: 100%; }
    .responsive-admin-table tr { padding: 9px 12px; border-bottom: 1px solid var(--ui-rule); }
    .responsive-admin-table td { display: grid; grid-template-columns: minmax(90px, 120px) minmax(0, 1fr); gap: 8px; padding: 3px 0; border: 0; overflow-wrap: anywhere; }
    .responsive-admin-table td::before { content: attr(data-label); color: var(--text-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
    .responsive-admin-table td[data-label="Topic"] { font-size: .92rem; }
}
@media (max-width: 1000px) {
    .forum-view .header-action { display: flex; flex-wrap: wrap; align-items: start; gap: 10px; }
    .forum-view .header-actions { justify-content: flex-start; width: 100%; }
    .forum-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 7px 12px; }
    .forum-details { grid-column: 2 / -1; }
    .forum-last-post { grid-column: 2; grid-row: 2; min-width: 0; padding: 0; border: 0; font-size: .74rem; }
    .forum-stats { grid-column: 3; grid-row: 2; justify-content: flex-end; align-self: end; display: flex; gap: 7px; padding: 0; white-space: nowrap; }
    .forum-stats span { display: inline; }
    .forum-stats small { margin-left: 2px; }
}
@media (max-width: 700px) {
    .forum-last-post { display: flex; align-items: baseline; gap: 4px; overflow: hidden; white-space: nowrap; }
    .forum-last-post::before { flex: 0 0 auto; }
    .forum-last-post a { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; -webkit-line-clamp: unset; line-clamp: unset; }
    .forum-last-post small { flex: 0 0 auto; white-space: nowrap; }
    .forum-last-post .latest-poster { display: none; }
    .search-filter-primary { grid-template-columns: minmax(0, 1fr) auto; }
    .search-filter-primary .search-keywords { grid-column: 1 / -1; }
    .profile-activity .activity-list li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .inbox-list li { grid-template-columns: minmax(0, 1fr); gap: 3px; }
    .inbox-list time { white-space: normal; }
    .appearance-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); }
    .appearance-dialog-layout { max-height: calc(100dvh - 12px); }
    .theme-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 460px) {
    .search-filter-primary { grid-template-columns: 1fr; }
    .search-filter-primary .search-keywords { grid-column: auto; }
    .forum-stats { gap: 5px; }
    .forum-stats small { font-size: .58rem; }
    .theme-options { grid-template-columns: 1fr; }
    .appearance-dialog .dialog-heading { padding: 12px; }
    .appearance-dialog-content, .appearance-dialog-footer { padding-inline: 12px; }
    .admin-sidebar { align-items: flex-start; flex-direction: column; }
    .admin-sidebar nav { align-items: flex-start; flex-direction: column; }
}
