* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #eef2f7;
  --text: #172033;
  --text-muted: #65758b;
  --text-soft: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --black: #26364d;
  --black-hover: #1d293b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #eff6ff;
  --white: #ffffff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --focus: rgba(59, 130, 246, 0.18);
  --shadow: rgba(15, 23, 42, 0.08);
  --header-bg: rgba(255, 255, 255, 0.86);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -10%, rgba(59, 130, 246, 0.12), transparent 34%),
    radial-gradient(circle at 92% 4%, rgba(20, 184, 166, 0.09), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(226, 232, 240, 0.82);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(18px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1160px, calc(100% - 80px));
  min-height: 56px;
  margin: 0 auto;
}

.brand {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.site-nav a:hover,
.nav-button:hover {
  color: var(--text);
}

.notification-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--white);
  font-size: 11px;
  font-weight: 800;
}

.nav-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}

.page {
  width: min(1080px, calc(100% - 96px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.page-narrow {
  width: min(520px, calc(100% - 32px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
  color: var(--text);
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-actions-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 24px;
  min-height: 96px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.form-actions-left,
.form-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-actions-left {
  align-self: end;
  justify-content: flex-start;
}

.form-actions-right {
  align-self: end;
  justify-content: flex-end;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px var(--shadow);
}

.panel-body {
  padding: 28px;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

input[readonly] {
  background: var(--surface-strong);
  color: var(--text-muted);
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
}

.input-with-button .btn {
  flex: 0 0 auto;
}

.form-message {
  min-height: 18px;
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 700;
}

.form-message-success {
  color: #404040;
}

.form-message-error {
  color: #111111;
}

.form-help {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary,
.btn-save {
  background: var(--accent);
  color: var(--white);
}

.btn-primary:hover,
.btn-save:hover {
  background: var(--accent-hover);
}

.btn-secondary,
.btn-cancel {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover,
.btn-cancel:hover {
  background: var(--surface-muted);
}

.btn-success,
.btn-edit {
  background: #14b8a6;
  color: var(--white);
}

.btn-danger,
.btn-delete {
  background: var(--danger);
  color: var(--white);
}

.btn-purple,
.btn-signup {
  background: #6366f1;
  color: var(--white);
}

.table-wrap {
  overflow: hidden;
}

.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.search-form input {
  max-width: 360px;
}

.result-count {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  white-space: nowrap;
}

.sort-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.sort-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.sort-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.sort-tabs button {
  cursor: pointer;
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-tile {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.summary-tile span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-tile strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 28px;
}

.admin-tabs {
  margin-top: 6px;
}

.admin-section select {
  width: auto;
  min-width: 96px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.admin-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table tbody tr:hover {
  background: #f1f7ff;
}

.table tbody tr.notice-row {
  background: #f8fbff;
}

.table tbody tr.notice-row:hover {
  background: #edf6ff;
}

.table tbody tr.unread-row {
  background: var(--accent-soft);
}

.title-link {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.notice-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  margin-right: 8px;
  padding: 0 8px;
  border-radius: 999px;
  background: #172033;
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.writer-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.title-link:hover {
  color: var(--accent-hover);
}

.content-box {
  min-height: 180px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  white-space: pre-wrap;
}

.attachments {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.attachment-image {
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  aspect-ratio: 4 / 3;
}

.attachment-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 14px;
}

.attachment-list a {
  color: var(--accent-hover);
  font-weight: 700;
  text-decoration: none;
}

.reaction-bar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 96px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}

.reaction-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.meta {
  margin: 8px 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.time-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.time-cell {
  color: var(--text-muted);
  white-space: nowrap;
}

.author-line,
.reply-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 17px;
  font-weight: 700;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-small {
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.avatar-tiny {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar-large {
  width: 72px;
  height: 72px;
  font-size: 26px;
}

.profile-preview {
  display: flex;
  margin-top: 10px;
}

.notice {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: center;
}

.reply-list {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}

.reply-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.reply-author {
  margin-bottom: 2px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.reply-time {
  color: var(--text-soft);
  font-size: 12px;
}

.reply-text {
  margin: 8px 0 0 44px;
  color: var(--text-muted);
  line-height: 1.6;
}

.reply-actions {
  display: flex;
  gap: 10px;
  margin: 10px 0 0 44px;
}

.text-link {
  color: var(--accent-hover);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.text-link-danger {
  color: var(--danger);
}

.edit-form {
  display: none;
  margin: 12px 0 0 44px;
}

.child-reply-form {
  display: none;
  margin: 12px 0 0 44px;
}

.child-reply-form textarea {
  min-height: 96px;
}

.child-reply-list {
  list-style: none;
  margin: 16px 0 0 44px;
  padding: 0 0 0 16px;
  border-left: 2px solid var(--border);
}

.child-reply-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.empty {
  padding: 32px;
  color: var(--text-muted);
  text-align: center;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.page-link.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--white);
}

.page-link.disabled {
  color: var(--text-soft);
  pointer-events: none;
}

.page-jump {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.page-jump label {
  margin: 0;
}

.page-jump input {
  width: 76px;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1160px, calc(100% - 80px));
  min-height: 72px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  .site-header-inner,
  .site-footer-inner {
    width: min(100% - 28px, 1080px);
  }

  .site-header-inner,
  .site-footer-inner,
  .site-nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .site-header-inner {
    padding: 12px 0;
  }

  .page {
    width: min(100% - 28px, 1080px);
    padding: 24px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .form-actions-split {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    min-height: 84px;
  }

  .btn {
    min-width: 84px;
  }

  .panel-body {
    padding: 20px;
  }

  .list-tools,
  .search-form {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form input {
    max-width: none;
  }

  .sort-tabs,
  .reaction-bar,
  .page-jump {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .admin-summary {
    grid-template-columns: 1fr 1fr;
  }
}
