/* === Hidden utility === */
.hidden { display: none !important; }

/* === モーダル共通 === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal {
  background: #36393f;
  border-radius: 8px;
  padding: 24px;
  max-width: 560px;
  width: 100%;
  position: relative;
  animation: modalIn 0.3s ease;
  color: #dcddde;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: #72767d;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
}

.terms-modal {
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.terms-modal h2 {
  font-size: 20px;
  margin-bottom: 16px;
  color: #fff;
}

.terms-content {
  overflow-y: auto;
  flex: 1;
  font-size: 13px;
  line-height: 1.7;
  color: #b9bbbe;
}

.terms-content h3 {
  font-size: 14px;
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 6px;
  color: #dcddde;
}

.terms-content h3:first-child {
  margin-top: 0;
}

.terms-content ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

.terms-content li {
  margin-bottom: 4px;
}

.modal-ok-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #5865f2;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}

.modal-ok-btn:hover {
  background: #4752c4;
}

.footer-links {
  margin: 8px 0;
}

.footer-links a {
  color: #00aff4;
  text-decoration: none;
  font-size: 12px;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* === Discord BBS - Authentic Discord Dark Theme === */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg-primary: #36393f;
  --bg-secondary: #2f3136;
  --bg-tertiary: #202225;
  --bg-sidebar: #202225;
  --bg-input: #40444b;
  --bg-hover: #32353b;
  --bg-message-hover: #32353b;
  --blurple: #5865F2;
  --blurple-hover: #4752c4;
  --green: #57F287;
  --yellow: #FEE75C;
  --red: #ED4245;
  --white: #ffffff;
  --text-normal: #dcddde;
  --text-muted: #a3a6aa;
  --text-link: #00b0f4;
  --header-primary: #ffffff;
  --header-secondary: #b9bbbe;
  --channel-text: #8e9297;
  --divider: #42454a;
  --scrollbar-thin: #202225;
  --scrollbar-auto: #2e3338;
  --font: 'Noto Sans JP', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-normal);
  line-height: 1.5;
  min-height: 100vh;
}

/* === Header === */
.discord-header {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--divider);
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(4,4,5,0.2), 0 1.5px 0 rgba(6,6,7,0.05), 0 2px 0 rgba(4,4,5,0.05);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--header-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  font-size: 20px;
}

.header-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--header-secondary);
}

/* === App Layout === */
.app-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 48px - 60px);
}

/* === Sidebar === */
.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  padding: 12px 8px;
  flex-shrink: 0;
  border-right: 1px solid var(--divider);
  position: sticky;
  top: 48px;
  height: calc(100vh - 48px);
  overflow-y: auto;
}

.sidebar-header {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--channel-text);
  letter-spacing: 0.02em;
}

.sidebar-divider {
  height: 1px;
  background: var(--divider);
  margin: 8px 0;
}

.channel-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--channel-text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}

.channel-btn:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}

.channel-btn.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--white);
}

.channel-hash {
  color: var(--channel-text);
  font-size: 18px;
  font-weight: 400;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.channel-icon {
  font-size: 14px;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blurple);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* === Main Content === */
.main-content {
  flex: 1;
  padding: 16px;
  min-width: 0;
  overflow-x: hidden;
}

/* === Board Title Bar === */
.board-title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}

.board-hash {
  font-size: 24px;
  color: var(--channel-text);
  font-weight: 700;
}

#boardTitle {
  font-size: 16px;
  font-weight: 700;
  color: var(--header-primary);
}

.board-description {
  font-size: 13px;
  color: var(--header-secondary);
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--divider);
}

/* === Affiliate Section === */
.affiliate-section {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.affiliate-label {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.affiliate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.affiliate-card {
  display: block;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 12px;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, transform 0.15s;
  position: relative;
}

.affiliate-card:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.affiliate-badge {
  display: inline-block;
  background: var(--blurple);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-bottom: 6px;
}

.affiliate-text {
  font-size: 12px;
  color: var(--text-normal);
  font-weight: 500;
}

/* === Post Form === */
.post-form-wrapper {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--divider);
}

.form-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--header-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--header-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.required {
  color: var(--red);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: none;
  border-radius: 4px;
  color: var(--text-normal);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  border: 1px solid transparent;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blurple);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23b9bbbe' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-group select option {
  background: var(--bg-input);
  color: var(--text-normal);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--blurple);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  justify-content: center;
}

.submit-btn:hover {
  background: var(--blurple-hover);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 16px;
}

/* === Posts Section === */
.posts-section {
  margin-bottom: 16px;
}

.posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.posts-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--header-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.refresh-btn {
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.refresh-btn:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}

/* === Post Card (Discord Message Style) === */
.post-card {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  margin: 0 -16px;
  border-radius: 0;
  transition: background 0.1s;
}

.post-card:hover {
  background: var(--bg-message-hover);
}

.post-card + .post-card {
  margin-top: 0;
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin-top: 2px;
}

.avatar-male { background: var(--blurple); }
.avatar-female { background: #EB459E; }
.avatar-other { background: var(--green); }
.avatar-default { background: #747f8d; }

.post-body {
  flex: 1;
  min-width: 0;
}

.post-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.post-nickname {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-primary);
  cursor: pointer;
}

.post-nickname:hover {
  text-decoration: underline;
}

.post-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  vertical-align: middle;
}

.badge-age {
  background: rgba(88,101,242,0.2);
  color: #8ea1fc;
}

.badge-gender {
  background: rgba(235,69,158,0.2);
  color: #f47bbc;
}

.badge-area {
  background: rgba(87,242,135,0.2);
  color: #81f5ac;
}

.badge-board {
  background: var(--blurple);
  color: white;
}

.post-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.post-message {
  font-size: 14px;
  color: var(--text-normal);
  line-height: 1.375;
  word-break: break-word;
  white-space: pre-wrap;
  margin-bottom: 4px;
}

.post-contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px 10px;
  background: rgba(88,101,242,0.15);
  border-radius: 4px;
  font-size: 13px;
  color: var(--blurple);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.post-contact:hover {
  background: rgba(88,101,242,0.25);
}

.post-contact-icon {
  font-size: 14px;
}

.post-divider {
  height: 1px;
  background: var(--divider);
  margin: 2px 0 2px 56px;
  opacity: 0.5;
}

/* === Loading & Empty States === */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-input);
  border-top-color: var(--blurple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--header-secondary);
}

.empty-sub {
  font-size: 13px;
  margin-top: 4px;
}

/* === Load More === */
.load-more-wrap {
  text-align: center;
  padding: 12px;
}

.load-more-btn {
  padding: 8px 32px;
  background: var(--bg-secondary);
  color: var(--text-normal);
  border: 1px solid var(--divider);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.load-more-btn:hover {
  background: var(--bg-hover);
}

/* === Ad Container === */
.ad-container {
  max-width: 1200px;
  margin: 12px auto;
  padding: 0 16px;
}

.ad-unit {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  min-height: 50px;
}

/* === Footer === */
.discord-footer {
  background: var(--bg-tertiary);
  border-top: 1px solid var(--divider);
  text-align: center;
  padding: 20px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--channel-text);
}

/* === Toast / Notification === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: #000;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* === Copied tooltip === */
.copied-tooltip {
  position: fixed;
  background: var(--bg-tertiary);
  color: var(--green);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  z-index: 999;
  pointer-events: none;
  animation: fadeOut 0.3s ease 1s forwards;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-auto);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thin);
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 48px;
    height: calc(100vh - 48px);
    z-index: 150;
    transition: left 0.2s ease;
    box-shadow: none;
  }

  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 16px rgba(0,0,0,0.3);
  }

  .sidebar-toggle {
    display: block;
  }

  .app-layout {
    flex-direction: column;
  }

  .main-content {
    padding: 12px 8px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .affiliate-grid {
    grid-template-columns: 1fr;
  }

  .board-title-bar {
    padding: 8px;
    flex-wrap: wrap;
  }

  .board-description {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    width: 100%;
    margin-top: 4px;
  }

  .post-card {
    padding: 8px;
    margin: 0;
    gap: 12px;
  }

  .post-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .post-divider {
    margin-left: 44px;
  }

  .header-title {
    font-size: 14px;
  }

  .header-sub {
    display: none;
  }

  .toast {
    right: 12px;
    bottom: 80px;
    left: 12px;
    text-align: center;
  }
}

/* === Overlay for mobile sidebar === */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 140;
}

.sidebar-overlay.show {
  display: block;
}
