/* 淫魔ちゃんねる — 5ch/専ブラダーク調の軽量掲示板スタイル */
:root {
  --bg: #101014;
  --surface: #17171c;
  --surface-2: #1e1e24;
  --surface-hover: #222229;
  --border: #2b2b34;
  --border-strong: #3d3d4a;

  --text: #e2e2e7;
  --text-sub: #9595a3;
  --text-muted: #6c6c7a;

  --accent: #d9537f;
  --accent-hover: #e5648e;
  --link: #7aa6dc;
  --anchor: #e07b9a;
  --danger: #d94c5c;

  /* 種族カラー（目に刺さらない落ち着いた配色） */
  --race-succubus: #e86b95;
  --race-angel: #dfd08a;
  --race-human: #6ec088;
  --race-other: #b39ddb;

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "MS Gothic", monospace;
  --sans: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 2px solid var(--accent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f2f2f5;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-sub);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main */
.main-content {
  flex: 1;
  padding-top: 12px;
  padding-bottom: 40px;
}

.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.box-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: #272730;
  text-decoration: none;
}

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

.btn-sm {
  padding: 4px 9px;
  font-size: 0.78rem;
}

.btn-primary {
  background: #9f2d55;
  border-color: #c2406d;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #b53663;
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-danger {
  background: #6e232d;
  border-color: var(--danger);
  color: #f8d4d9;
}

.btn-danger:hover:not(:disabled) {
  background: #872b37;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
}

.text-btn:hover {
  color: var(--text);
  text-decoration: underline;
}

.input,
.textarea,
.select {
  width: 100%;
  background: #101014;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 6px 8px;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
}

.textarea {
  resize: vertical;
  min-height: 108px;
  line-height: 1.55;
}

/* Toolbar */
.toolbar {
  padding: 8px 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.race-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.race-tab {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-sub);
  padding: 3px 10px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}

.race-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.race-tab.active {
  background: var(--surface-2);
  border-color: var(--text-sub);
  color: #fff;
  font-weight: 700;
}

.race-tab.tab-succubus.active { border-color: var(--race-succubus); color: var(--race-succubus); }
.race-tab.tab-angel.active { border-color: var(--race-angel); color: var(--race-angel); }
.race-tab.tab-human.active { border-color: var(--race-human); color: var(--race-human); }
.race-tab.tab-other.active { border-color: var(--race-other); color: var(--race-other); }

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.toolbar-controls .select {
  width: auto;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.search-box {
  flex: 1;
  min-width: 170px;
  display: flex;
  gap: 4px;
}

.search-input {
  padding: 4px 8px;
  font-size: 0.82rem;
}

/* Race Tag (控えめな角型) */
.race-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  line-height: 1.45;
  vertical-align: baseline;
  background: #131318;
}

.race-tag.race-succubus { color: var(--race-succubus); border-color: rgba(232, 107, 149, 0.45); }
.race-tag.race-angel { color: var(--race-angel); border-color: rgba(223, 208, 138, 0.42); }
.race-tag.race-human { color: var(--race-human); border-color: rgba(110, 192, 136, 0.42); }
.race-tag.race-other { color: var(--race-other); border-color: rgba(179, 157, 219, 0.42); }
.race-tag.race-abone { color: var(--text-muted); border-color: var(--border); }

/* Thread List (高密度な1行リスト) */
.thread-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.thread-item:last-child {
  border-bottom: none;
}

.thread-item:hover {
  background: var(--surface-hover);
}

.thread-item-main {
  flex: 1;
  min-width: 0;
}

.thread-item-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.thread-idx {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.thread-link {
  color: #e9e9ef;
  font-weight: 600;
  font-size: 0.93rem;
  overflow-wrap: anywhere;
}

.thread-link:visited {
  color: #b4a9c4;
}

.thread-link:hover {
  color: var(--race-succubus);
}

.thread-count-inline {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-sub);
}

.thread-count-inline.is-full {
  color: #e88490;
}

.thread-status-tag {
  font-size: 0.7rem;
  color: #e88490;
  border: 1px solid rgba(217, 76, 92, 0.45);
  padding: 0 4px;
}

.thread-item-meta {
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--mono);
}

.thread-item-right {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.state-msg {
  padding: 28px 14px;
  text-align: center;
  color: var(--text-sub);
  font-size: 0.86rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 12px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-family: var(--mono);
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-sub);
  text-decoration: none;
  cursor: pointer;
}

.page-btn:hover:not(:disabled):not(.is-disabled) {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.page-btn.active {
  background: #9f2d55;
  border-color: #c2406d;
  color: #fff;
  font-weight: 700;
}

.page-btn:disabled,
.page-btn.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-info {
  margin-left: 8px;
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

/* Forms */
.form-panel {
  padding: 12px 14px;
  margin-bottom: 12px;
}

.post-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1.5fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.form-label {
  font-size: 0.76rem;
  color: var(--text-sub);
}

.label-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-count {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

.race-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.race-opt {
  padding: 5px 14px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: #101014;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.race-opt:hover {
  color: var(--text);
  background: var(--surface-2);
}

.race-opt.active {
  font-weight: 700;
  background: var(--surface-2);
}

.race-opt.active[data-race="succubus"] { border-color: var(--race-succubus); color: var(--race-succubus); }
.race-opt.active[data-race="angel"] { border-color: var(--race-angel); color: var(--race-angel); }
.race-opt.active[data-race="human"] { border-color: var(--race-human); color: var(--race-human); }
.race-opt.active[data-race="other"] { border-color: var(--race-other); color: var(--race-other); }

.custom-race-wrap {
  margin-top: 4px;
}

.sage-row {
  padding-bottom: 6px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  accent-color: var(--accent);
}

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

.form-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.turnstile-box:empty {
  display: none;
}

/* Thread Detail View */
.thread-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.thread-nav-right {
  display: flex;
  gap: 6px;
}

.thread-header-box {
  padding: 12px 14px;
  margin-bottom: 10px;
}

.thread-detail-title {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  color: #f4f4f7;
  overflow-wrap: anywhere;
}

.thread-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--text-sub);
  font-family: var(--mono);
}

.thread-race-filters {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.mini-filter {
  background: none;
  border: none;
  color: var(--text-sub);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 1px 4px;
  cursor: pointer;
}

.mini-filter:hover {
  color: var(--text);
  text-decoration: underline;
}

.mini-filter.active {
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
}

/* Posts (5ch / 専ブラダーク風の連続タイムライン) */
.post-list {
  margin-bottom: 12px;
}

.post-item {
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border);
}

.post-item:last-child {
  border-bottom: none;
}

.post-item.is-deleted {
  color: var(--text-muted);
}

.post-item.highlight {
  background: #221b22;
}

.post-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--text-sub);
}

.post-no-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-sub);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.post-no-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-author {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.post-author.race-succubus { color: var(--race-succubus); }
.post-author.race-angel { color: var(--race-angel); }
.post-author.race-human { color: var(--race-human); }
.post-author.race-other { color: var(--race-other); }
.post-author.race-abone { color: var(--text-muted); font-weight: 400; }
.post-author.is-admin,
.author-admin { color: #f06a98; font-weight: 700; }

.cap-star {
  color: #e6c465;
  font-weight: 700;
  font-size: 0.82em;
}

.post-trip {
  color: #caa45c;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-id-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-sub);
  cursor: pointer;
}

.post-id-btn:hover {
  color: var(--link);
  text-decoration: underline;
}

.post-id-btn.many {
  color: #e07b88;
}

.post-sage-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.backref-btn {
  background: none;
  border: none;
  padding: 0 2px;
  color: var(--anchor);
  font-size: 0.74rem;
  font-family: var(--mono);
  cursor: pointer;
}

.backref-btn:hover {
  text-decoration: underline;
}

.post-header-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 8px;
}

.post-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}

.post-action-btn:hover {
  color: #e88490;
  text-decoration: underline;
}

.post-body {
  font-size: 0.93rem;
  line-height: 1.7;
  color: #e8e8ed;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: 1.1em;
}

.post-item.is-deleted .post-body {
  color: var(--text-muted);
}

.anchor-link {
  color: var(--anchor);
  font-family: var(--mono);
  cursor: pointer;
}

.anchor-link:hover {
  text-decoration: underline;
}

.ext-link {
  color: var(--link);
  word-break: break-all;
}

.thread-bottom-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Corner Nav (角型ミニバー) */
.float-nav {
  position: fixed;
  right: 12px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  background: rgba(23, 23, 28, 0.94);
  z-index: 25;
}

.float-btn {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 6px 8px;
  cursor: pointer;
}

.float-btn:last-child {
  border-bottom: none;
}

.float-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Popups */
.popup-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.post-popup {
  position: fixed;
  pointer-events: auto;
  width: min(560px, calc(100vw - 24px));
  max-height: 60vh;
  overflow-y: auto;
  background: #1b1b22;
  border: 1px solid var(--border-strong);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
}

.popup-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-sub);
  padding: 4px 10px;
  background: #141419;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  position: relative;
  width: min(400px, 100%);
  padding: 14px;
  z-index: 1;
}

.modal-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-sub);
}

/* Toast */
.toast-container {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 7px 12px;
  border-radius: 2px;
  font-size: 0.8rem;
  background: #1e1e26;
  border: 1px solid var(--border-strong);
  color: var(--text);
  max-width: 320px;
}

.toast.success {
  border-left: 3px solid var(--race-human);
}

.toast.error {
  border-left: 3px solid var(--danger);
  color: #f5b8c0;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsive */
@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .thread-item {
    flex-direction: column;
    gap: 3px;
  }

  .thread-item-right {
    text-align: left;
  }

  .post-body {
    padding-left: 0.4em;
  }
}
