/* AVIC411 Static Archive Stylesheet - IPS4 Inspired */
:root {
  --bg-page: #edf0f4;
  --bg-card: #ffffff;
  --bg-subtle: #f7fafc;
  --bg-accent: #ebf4f9;
  --bg-header: #1265a1;
  --bg-header-dark: #0d4d7c;
  --brand: #177ec9;
  --brand-hover: #1265a1;
  --text-main: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border: #dde3ea;
  --border-light: #edf2f7;
  --quote-bg: #f8fafc;
  --quote-border: #177ec9;
  --badge-pin-bg: #e6fffa;
  --badge-pin-fg: #234e52;
  --badge-lock-bg: #fed7d7;
  --badge-lock-fg: #822727;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 6px;
}

[data-theme="dark"] {
  --bg-page: #0f141c;
  --bg-card: #18202c;
  --bg-subtle: #1e2938;
  --bg-accent: #1d334a;
  --bg-header: #0f3d63;
  --bg-header-dark: #092942;
  --brand: #4da6ff;
  --brand-hover: #79bcff;
  --text-main: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border: #283446;
  --border-light: #202b3a;
  --quote-bg: #141b26;
  --quote-border: #4da6ff;
  --badge-pin-bg: #1d4044;
  --badge-pin-fg: #81e6d9;
  --badge-lock-bg: #4a2323;
  --badge-lock-fg: #feb2b2;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 18px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg-page);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header & Navigation */
.site-header {
  background: linear-gradient(135deg, var(--bg-header) 0%, var(--bg-header-dark) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding-top: 8px;
  padding-bottom: 8px;
  flex-wrap: wrap;
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff !important;
  text-decoration: none !important;
}
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.5px;
  border: 1px solid rgba(255,255,255,0.25);
}
.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.15;
}
.brand-text span {
  display: block;
  font-size: 11.5px;
  opacity: 0.85;
  font-weight: 400;
}

.search-bar-wrap {
  flex: 1;
  max-width: 520px;
  min-width: 240px;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 9px 70px 9px 36px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(0,0,0,0.22);
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.15s;
}
.search-input::placeholder { color: rgba(255,255,255,0.72); }
.search-input:focus {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}
.search-input:focus::placeholder { color: var(--text-muted); }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.8;
  font-size: 14px;
}
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.18);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  pointer-events: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.archive-badge {
  font-size: 12px;
  background: rgba(255,255,255,0.14);
  padding: 5px 10px;
  border-radius: 14px;
  white-space: nowrap;
}
.theme-btn {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 6px 11px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.theme-btn:hover { background: rgba(255,255,255,0.26); }

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  margin: 14px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
}
.breadcrumbs .sep { color: var(--text-muted); user-select: none; }
.breadcrumbs .current { color: var(--text-secondary); font-weight: 600; }

/* Category & Forum Cards */
.category-block {
  margin-bottom: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.category-header {
  background: var(--bg-header);
  color: #fff;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.category-header a { color: #fff; }
.category-desc {
  font-size: 12.5px;
  font-weight: 400;
  opacity: 0.88;
}

.forum-list {
  divide-y: 1px solid var(--border-light);
}
.forum-row {
  display: grid;
  grid-template-columns: 44px 1fr 150px 270px;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}
.forum-row:last-child { border-bottom: none; }
.forum-row:hover { background: var(--bg-subtle); }

.forum-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-accent);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
}
.forum-info h3 {
  margin: 0 0 3px 0;
  font-size: 16px;
  font-weight: 700;
}
.forum-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 2px 0 0 0;
}
.forum-desc p { margin: 0; }

.subforums-wrap {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.subforum-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 14px;
  color: var(--text-main);
  font-weight: 500;
}
.subforum-chip:hover {
  border-color: var(--brand);
  background: var(--bg-accent);
  text-decoration: none;
}
.subforum-chip .cnt {
  color: var(--text-muted);
  font-size: 11px;
}
.subforum-group {
  margin-top: 8px;
  padding: 8px 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 6px;
}
.subforum-group-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.forum-stats {
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
}
.forum-stats strong {
  color: var(--text-main);
  font-size: 14.5px;
}
.forum-lastpost {
  font-size: 12.5px;
  color: var(--text-secondary);
  overflow: hidden;
}
.forum-lastpost .lp-title {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.forum-lastpost .lp-meta {
  color: var(--text-muted);
  font-size: 12px;
}

/* Page Header & Pagination */
.page-header-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.page-header-box h1 {
  margin: 0 0 6px 0;
  font-size: 22px;
  line-height: 1.3;
}
.page-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}
.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}
.page-link:hover {
  background: var(--bg-accent);
  border-color: var(--brand);
  text-decoration: none;
}
.page-link.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.page-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Topic Listing Table */
.topic-row {
  display: grid;
  grid-template-columns: 1fr 130px 210px;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
}
.topic-row:last-child { border-bottom: none; }
.topic-row:hover { background: var(--bg-subtle); }
.topic-row.pinned { background: rgba(23, 126, 201, 0.04); }

.topic-main { min-width: 0; }
.topic-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 3px;
}
.topic-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.badge-pin { background: var(--badge-pin-bg); color: var(--badge-pin-fg); }
.badge-lock { background: var(--badge-lock-bg); color: var(--badge-lock-fg); }
.badge-attach { background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-secondary); }

.mini-pages {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}
.mini-pages a {
  font-size: 11px;
  padding: 1px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
}
.mini-pages a:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  text-decoration: none;
}
.topic-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Posts in Topic View */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.post-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.post-card:target {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand);
}
.post-author {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-light);
  padding: 18px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.author-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
  margin-bottom: 4px;
}
.author-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.author-role.admin { color: #e53e3e; }
.author-role.mod { color: #2b6cb0; }

.avatar-wrap {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 10px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.author-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.post-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12.5px;
  color: var(--text-muted);
}
.post-num {
  font-weight: 600;
  color: var(--text-secondary);
}
.post-body {
  padding: 18px 22px;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: break-word;
  word-break: break-word;
  flex: 1;
}
.post-body p { margin: 0 0 12px 0; }
.post-body p:last-child { margin-bottom: 0; }
.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.post-body img[data-emoticon],
.post-body img[src*="emoticons/"] {
  vertical-align: middle;
  max-height: 24px;
  width: auto;
}
.post-body blockquote,
.post-body .ipsQuote {
  margin: 12px 0;
  padding: 12px 16px;
  background: var(--quote-bg);
  border-left: 4px solid var(--quote-border);
  border-radius: 4px;
  font-size: 14px;
}
.ipsQuote_citation,
.quote-header {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.post-body pre,
.post-body .ipsCode {
  background: #1a202c;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

/* Attachments Box */
.post-attachments {
  margin: 8px 22px 16px 22px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.post-attachments-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
}
.attach-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.attach-file-card,
a.ipsAttachLink:not(.ipsAttachLink_image) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}
.attach-file-card:hover,
a.ipsAttachLink:not(.ipsAttachLink_image):hover {
  border-color: var(--brand);
  background: var(--bg-accent);
  text-decoration: none;
}
.attach-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
}
.attach-img-card {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
  max-width: 240px;
}
.attach-img-card img {
  display: block;
  max-width: 240px;
  max-height: 180px;
  object-fit: cover;
}
.attach-img-caption {
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-edit-note {
  margin: 0 22px 12px 22px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}
.post-signature {
  margin: 0 22px 14px 22px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  max-height: 120px;
  overflow: hidden;
}

/* Search Modal */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 50px 16px 24px 16px;
  overflow-y: auto;
}
.search-modal-backdrop.open { display: flex; }
.search-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 880px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.search-modal-header {
  padding: 14px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.search-select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
}
.search-close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
}
.search-results-body {
  max-height: 70vh;
  overflow-y: auto;
  divide-y: 1px solid var(--border-light);
}
.search-result-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  display: block;
}
.search-result-item:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}
.sr-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 4px;
}
.sr-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sr-forum {
  background: var(--bg-accent);
  color: var(--brand);
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 600;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 94vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.lightbox-bar {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
  color: #fff;
  font-size: 14px;
}
.lightbox-bar a, .lightbox-bar button {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}

.site-footer {
  margin-top: 40px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 820px) {
  .forum-row {
    grid-template-columns: 38px 1fr;
  }
  .forum-stats, .forum-lastpost {
    grid-column: 2;
    text-align: left;
  }
  .topic-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .post-card {
    grid-template-columns: 1fr;
  }
  .post-author {
    flex-direction: row;
    text-align: left;
    padding: 12px 16px;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }
  .avatar-wrap {
    width: 48px;
    height: 48px;
    font-size: 20px;
    margin-bottom: 0;
  }
  .archive-badge { display: none; }
}
