:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe7f4;
  --text: #202b3a;
  --muted: #5d6b7d;
  --primary: #1f6feb;
  --primary-dark: #184fa7;
  --success: #177f5d;
  --warning: #c38b09;
  --danger: #b64646;
  --shadow: rgba(15, 27, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.board-view {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

header.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  box-shadow: 0 1px 0 var(--shadow);
}

header.topbar.narrow {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

nav a,
button,
input,
select,
textarea {
  font: inherit;
}

nav a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.user-badge {
  background: #edf4ff;
  border: 1px solid #d7e7ff;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

.inline-form {
  display: inline;
}

button {
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-weight: 600;
}

button:hover {
  background: var(--primary-dark);
}

.confirm-dialog {
  width: min(420px, calc(100% - 2rem));
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(15, 27, 42, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(16, 27, 42, 0.48);
  backdrop-filter: blur(3px);
}

.confirm-dialog-content {
  padding: 1.75rem;
}

.confirm-dialog-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: #edf4ff;
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 700;
}

.confirm-dialog h2 {
  margin: 1rem 0 0.5rem;
  font-size: 1.3rem;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.5rem;
}

.confirm-cancel-button {
  background: #eef1f5;
  color: var(--text);
}

.confirm-cancel-button:hover {
  background: #dfe5ed;
}

.confirm-danger-button,
.confirm-danger-button:hover {
  background: var(--danger);
}

.confirm-danger-button:hover {
  background: #913737;
}

.delete-form {
  margin-top: 1rem;
}

.admin-post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.archive-button {
  background: #5d6b7d;
}

.archive-button:hover {
  background: #465365;
}

.delete-button {
  background: var(--danger);
}

.delete-button:hover {
  background: #913737;
}

.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.board-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  max-width: none;
  margin: 0;
}

.board-page > .bulletin-board {
  flex: 1;
}

.bulletin-board > .hero {
  max-width: 1100px;
  margin: 0 auto 1.25rem;
  padding-top: 1rem;
}

.container.small {
  max-width: 700px;
}

.hero {
  margin-bottom: 1.25rem;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(140px, calc((100% - 5rem) / 6)), 1fr));
  gap: 1rem;
  width: 88%;
  margin: 0 auto;
}

.bulletin-board {
  margin-right: -1rem;
  margin-left: -1rem;
  padding: 1rem;
  border: 8px solid #9b6538;
  background-color: #bd8550;
  background-image:
    radial-gradient(ellipse at 18% 28%, rgba(255, 221, 165, 0.2) 0 1px, transparent 2px),
    radial-gradient(ellipse at 73% 61%, rgba(93, 52, 27, 0.14) 0 1px, transparent 2px),
    repeating-linear-gradient(12deg, rgba(255, 224, 178, 0.035) 0 2px, rgba(88, 48, 23, 0.035) 2px 4px);
  background-size: 13px 17px, 19px 23px, auto;
  box-shadow:
    inset 0 0 0 2px rgba(255, 218, 164, 0.34),
    inset 0 0 18px rgba(72, 39, 20, 0.28),
    0 3px 8px rgba(54, 34, 19, 0.22);
}

.board-toast {
  animation: board-toast-fade 700ms ease 5s forwards;
}

@keyframes board-toast-fade {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.post-card,
.panel,
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 25px var(--shadow);
}

.post-card {
  display: flex;
  flex-direction: column;
  padding: 0.7rem;
  border-radius: 0;
  box-shadow: 4px 5px 0 rgba(72, 46, 26, 0.3), 0 8px 14px rgba(42, 30, 18, 0.16);
  background-color: #fffdf5;
  background-image:
    radial-gradient(circle at 17% 23%, rgba(122, 91, 48, 0.055) 0 0.6px, transparent 0.9px),
    radial-gradient(circle at 78% 67%, rgba(122, 91, 48, 0.04) 0 0.7px, transparent 1px),
    linear-gradient(105deg, rgba(255, 255, 255, 0.3), rgba(231, 220, 193, 0.08));
  background-size: 7px 9px, 11px 13px, 100% 100%;
}

.post-card .admin-post-actions {
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 0.8rem;
}

.post-card .admin-post-actions button {
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
}

.post-card .image-thumbnail {
  height: 126px;
}

.post-card .document-thumbnail {
  min-height: 70px;
  gap: 0.7rem;
  padding: 0.525rem;
}

.post-card .document-icon {
  flex-basis: 41px;
  height: 49px;
}

.post-card h3 {
  margin: 0.5rem 0;
}

.post-card h3 a {
  display: block;
  padding: 0.65rem 0.75rem;
  background: #f1e7d2;
  color: #5e472f;
  text-decoration: none;
  transition: background-color 150ms ease;
}

.post-card h3 a:hover,
.post-card h3 a:focus-visible {
  background: #e6d4b5;
}

.post-header,
.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.post-header {
  margin-bottom: 0.5rem;
}

.post-footer {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tag,
.vote-tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.35rem;
}

.tag {
  background: #eef7ff;
  color: var(--primary-dark);
}

.vote-tag {
  background: #eafaf2;
  color: var(--success);
}

.archive-tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #f1f2f4;
  color: #4d5968;
  font-size: 0.75rem;
  font-weight: 700;
  margin: 0.2rem 0.35rem 0.2rem 0;
}

.archive-notice,
.empty-state {
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 1rem;
}

.meta,
.small-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  line-height: 1.6;
  margin: 0.8rem 0 0;
  white-space: pre-wrap;
}

.image-preview-link,
.document-thumbnail {
  display: flex;
  overflow: hidden;
  margin-top: 0.9rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--line);
  text-decoration: none;
}

.image-preview-link {
  flex-direction: column;
  color: var(--primary);
  font-weight: 600;
}

.image-preview-link span {
  padding: 0.65rem 0.75rem;
}

.image-thumbnail {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #eef2f7;
}

.detail-image-preview .image-thumbnail {
  height: auto;
  max-height: 600px;
  object-fit: contain;
}

.document-thumbnail {
  min-height: 100px;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  color: var(--text);
}

.document-thumbnail:hover {
  border-color: var(--primary);
  background: #f1f6ff;
}

.document-icon {
  display: grid;
  flex: 0 0 58px;
  height: 70px;
  place-items: center;
  border-radius: 6px;
  background: #e8effa;
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
}

.document-label {
  display: grid;
  gap: 0.35rem;
}

.document-label span {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.asset-box a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card,
.panel {
  padding: 1.5rem;
}

.auth-card {
  width: min(420px, 100%);
}

label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.checkbox-line input {
  width: auto;
  margin-top: 0;
}

.alert {
  margin: 1rem auto 0;
  max-width: 1100px;
  background: #edf7ff;
  border: 1px solid #cfe4ff;
  color: var(--primary-dark);
  padding: 0.9rem 1rem;
  border-radius: 8px;
}

.admin-layout,
.post-layout {
  display: grid;
  gap: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

.vote-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.comments-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfd;
  padding: 0.9rem;
}

.comment-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

@media (max-width: 640px) {
  header.topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  nav {
    flex-wrap: wrap;
  }

  .bulletin-board {
    padding: 0.7rem;
    border-width: 6px;
  }
}
