*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background: #111827;
  color: #e5e7eb;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  padding: 0.3rem 0.35rem 0.75rem;
}
a {
  color: #60a5fa;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
a:visited {
  color: #60a5fa;
}
.nav-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: #60a5fa;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-align: left;
  display: inline;
}
.nav-btn:hover {
  text-decoration: underline;
}
.site-header {
  max-width: 100%;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid #374151;
  padding-bottom: 0.28rem;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.site-header h1 {
  font-size: 1rem;
  color: #f3f4f6;
}
.site-header .sub {
  font-size: 0.78rem;
  color: #9ca3af;
}
.site-header .back {
  font-size: 0.74rem;
  margin-left: auto;
  background: none;
  border: none;
  padding: 0;
  color: #60a5fa;
  font-family: inherit;
  cursor: pointer;
}
.site-header .back:hover {
  text-decoration: underline;
}
.wrap {
  max-width: 100%;
  padding: 0 0.5rem;
}
.cat-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.cat-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.58rem 0.65rem;
  display: block;
  color: inherit;
  transition: border-color 0.15s;
  cursor: pointer;
}
.cat-card:hover {
  border-color: #4b5563;
}
.cat-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f3f4f6;
  margin-bottom: 0.25rem;
}
.cat-desc {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.3rem;
}
.cat-stats {
  font-size: 0.75rem;
  color: #6b7280;
}
.cat-stats .sep {
  margin: 0 0.4rem;
}
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.thread-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.56rem 0.65rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 1rem;
  transition: border-color 0.15s;
  position: relative;
}
.thread-card:hover {
  border-color: #4b5563;
}
.thread-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f3f4f6;
  grid-column: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-title .nav-btn {
  color: inherit;
  font-weight: inherit;
}
.thread-title .nav-btn:hover {
  color: #60a5fa;
  text-decoration: none;
}
/* Themed replacement for the native title="" tooltip - shows the full,
   untruncated title on hover, matching the rest of the forum's dark theme
   instead of the browser's plain default tooltip box. Positioned relative to
   .thread-card, NOT .thread-title - .thread-title needs its own
   overflow:hidden for the ellipsis truncation above, and an element's own
   overflow:hidden clips any absolutely-positioned descendant (including
   ::after) that renders outside its box, even one explicitly positioned to
   escape via bottom: calc(100% + Npx). .thread-card has no overflow rule of
   its own, so it doesn't clip the tooltip. */
.thread-card[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0.65rem;
  background: #1f2937;
  border: 1px solid #374151;
  color: #f3f4f6;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  width: max-content;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  z-index: 20;
  pointer-events: none;
}
.thread-meta {
  font-size: 0.75rem;
  color: #6b7280;
  grid-column: 1;
}
.thread-meta .author {
  color: #9ca3af;
}
.thread-stats {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
}
.cat-header {
  margin-bottom: 0;
}
.cat-header-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f3f4f6;
  margin-bottom: 0.2rem;
}
.cat-header-desc {
  font-size: 0.82rem;
  color: #9ca3af;
}
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-right: 0.25rem;
}
.badge-pin {
  background: #1e3a5f;
  color: #60a5fa;
}
.badge-lock {
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
}
.post-wrap {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  align-items: flex-start;
}
.post-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  flex: 1;
  min-width: 0;
}
.post-card.op {
  border-left: 3px solid #1d4ed8;
}
.post-content {
  min-width: 0;
}
.post-meta {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.6rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.post-body {
  font-size: 0.88rem;
  color: #d1d5db;
  white-space: pre-wrap;
  word-break: break-word;
}
.post-body.deleted {
  color: #4b5563;
  font-style: italic;
}
.post-actions {
  margin-top: 0.65rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.user-card {
  width: 80px;
  flex-shrink: 0;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
}
.pu-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #374151;
  display: block;
}
.pu-avatar-ph {
  line-height: 42px;
  font-size: 1rem;
  color: #9ca3af;
  font-weight: 700;
  user-select: none;
}
.pu-name {
  font-size: 0.72rem;
  color: #d1d5db;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.3;
}
.pu-public {
  color: #60a5fa;
}
.pu-lvl {
  font-size: 0.68rem;
  color: #6b7280;
}
@media (max-width: 480px) {
  .post-wrap {
    flex-direction: column;
  }
  .user-card {
    flex-direction: row;
    width: auto;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    align-items: center;
    text-align: left;
  }
}
.thread-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f3f4f6;
  margin-bottom: 1rem;
  word-break: break-word;
}
.breadcrumb {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}
.breadcrumb a {
  color: #60a5fa;
}
.status-badges {
  margin-bottom: 0.75rem;
}
.forum-form {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.6rem 0.65rem;
  margin-top: 0.5rem;
}
.forum-form h3 {
  font-size: 0.82rem;
  color: #9ca3af;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.forum-input {
  width: 100%;
  background: #111827;
  color: #d1d5db;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 0.35rem;
  transition: border-color 0.15s;
}
.forum-input:focus {
  border-color: #6b7280;
}
textarea.forum-input {
  resize: vertical;
  min-height: 100px;
}
.forum-btn {
  background: #1d4ed8;
  color: #eff6ff;
  border: 1px solid #1e40af;
  border-radius: 6px;
  padding: 0.38rem 0.9rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.forum-btn:hover {
  background: #2563eb;
}
.forum-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.forum-btn-cancel {
  background: transparent;
  color: #6b7280;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.38rem 0.9rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}
.forum-btn-cancel:hover {
  color: #9ca3af;
}
.forum-btn-del {
  background: transparent;
  color: #f87171;
  border: 1px solid #7f1d1d;
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.forum-btn-del:hover {
  background: #7f1d1d;
}
.forum-btn-admin {
  background: transparent;
  color: #fbbf24;
  border: 1px solid #78350f;
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
}
.forum-btn-admin:hover {
  background: #78350f;
}
.forum-err {
  font-size: 0.8rem;
  color: #f87171;
  min-height: 1rem;
}
.forum-btn-edit {
  background: transparent;
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.12s,
    border-color 0.12s;
}
.forum-btn-edit:hover {
  color: #d1d5db;
  border-color: #4b5563;
}
.post-edited {
  color: #4b5563;
  font-style: italic;
  font-size: 0.72rem;
}
.att-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border: 1px dashed #374151;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #6b7280;
  cursor: pointer;
  font-family: inherit;
  background: none;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.att-pick-btn:hover {
  border-color: #4b5563;
  color: #9ca3af;
}
.att-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 0;
}
.att-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 0.18rem 0.4rem;
  font-size: 0.75rem;
  color: #9ca3af;
  max-width: 200px;
}
.att-item.att-uploading {
  color: #6b7280;
}
.att-item.att-error {
  border-color: #ef4444;
  color: #f87171;
}
.att-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.att-item-rm {
  background: none;
  border: none;
  color: #4b5563;
  cursor: pointer;
  padding: 0 0.15rem;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}
.att-item-rm:hover {
  color: #9ca3af;
}
.att-thumb-wrap {
  display: block;
  line-height: 0;
}
.att-thumb {
  max-width: 180px;
  max-height: 130px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid #374151;
}
.att-file-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #60a5fa;
  text-decoration: none;
  padding: 0.18rem 0.45rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
}
.att-file-link:hover {
  text-decoration: underline;
  border-color: #4b5563;
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #111827;
}
::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #374151 #111827;
}
@keyframes forum-unread-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.2);
  }
}
.thread-card.has-unread,
.cat-card.has-unread {
  border-left: 3px solid #16a34a;
  animation: forum-unread-pulse 2s ease-in-out infinite;
}
.post-card.is-new {
  border-left: 3px solid #16a34a;
  animation: forum-unread-pulse 2s ease-in-out infinite;
}
/* Same reduce-motion opt-out as the main app (public/css/base/reduce-motion.css) -
   this page is a separate document (served in its own iframe), so it can't
   see the parent's body.reduce-motion class directly and has to re-check the
   same localStorage flag itself (see the body.reduce-motion.<script> below). */
body.reduce-motion .thread-card.has-unread,
body.reduce-motion .cat-card.has-unread,
body.reduce-motion .post-card.is-new {
  animation: none !important;
}
.unread-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  margin-left: 0.45rem;
  vertical-align: middle;
  flex-shrink: 0;
}
.auth-notice {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #374151;
  border-radius: 6px;
  text-align: center;
}
.auth-notice a {
  color: #60a5fa;
}
.empty {
  color: #6b7280;
  font-size: 0.85rem;
  text-align: center;
  padding: 2.5rem 0;
}
.error-page {
  text-align: center;
  padding: 3rem 0;
  color: #6b7280;
}
.error-page h2 {
  color: #f3f4f6;
  margin-bottom: 0.5rem;
}
.conf-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.conf-box {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 1.25rem 1.25rem 1rem;
  max-width: 380px;
  width: 100%;
}
.conf-msg {
  color: #d1d5db;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.conf-btns {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
@media (max-width: 500px) {
  .thread-card {
    grid-template-columns: 1fr;
  }
  .thread-stats {
    grid-column: 1;
    flex-direction: row;
    justify-content: flex-start;
  }
}
