:root {
  --bg: #14171a;
  --bg-deep: #0c0e10;
  --panel: #1b2024;
  --panel-alt: #20262b;
  --border: #2c3338;
  --border-bright: #3c4751;
  --text: #c9d3d5;
  --text-dim: #8a9598;
  --text-faint: #596164;
  --cyan: #5b94e8;
  --cyan-bright: #a8c8f5;
  --cyan-deep: #1f3f73;
  --danger: #e2583f;
  --cut: 10px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan-bright); text-decoration: underline; }

::selection { background: var(--cyan-deep); color: #eafffb; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- background lattice ---------- */

.lattice-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg, rgba(91, 148, 232, 0.055) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(-45deg, rgba(91, 148, 232, 0.055) 0 1px, transparent 1px 40px),
    radial-gradient(ellipse at 50% -10%, rgba(91, 148, 232, 0.08), transparent 55%);
}

/* ---------- facet (cut-corner) shape, the site's signature shape ---------- */

.facet-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  clip-path: polygon(
    var(--cut) 0%, 100% 0%, 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, 0% 100%, 0% var(--cut)
  );
}

.facet-box.small { --cut: 7px; }

/* ---------- layout shell ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(27, 32, 36, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border-bright);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-mark { width: 42px; height: 38px; object-fit: contain; filter: drop-shadow(0 0 4px rgba(100,149,219,0.6)) drop-shadow(0 0 10px rgba(100,149,219,0.35)); }
.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.01em;
  color: var(--text);
}
.brand-word .accent { color: var(--cyan); }
.brand:hover .brand-word { text-decoration: none; color: var(--text); }

.board-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.board-tab {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 7px 14px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--panel-alt);
}
.board-tab:hover { color: var(--cyan-bright); text-decoration: none; border-color: var(--border-bright); }
.board-tab.active { color: var(--bg-deep); background: var(--cyan); border-color: var(--cyan); font-weight: 600; }

.auth-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-size: 14px;
}
.auth-area .who { font-family: var(--font-mono); color: var(--cyan-bright); }
.auth-area .who-role {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bg-deep);
  background: var(--cyan);
  padding: 1px 5px;
  margin-left: 6px;
  border-radius: 2px;
  vertical-align: middle;
}

main#view {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  min-height: 60vh;
}

.site-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  font-family: var(--font-mono);
  padding: 28px 20px 40px;
}

/* ---------- buttons / forms ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  border: 1px solid var(--border-bright);
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
  clip-path: polygon(8px 0%, 100% 0%, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0% 100%, 0% 8px);
}
.btn:hover { border-color: var(--cyan); color: var(--cyan-bright); }
.btn-cyan { background: var(--cyan); color: var(--bg-deep); border-color: var(--cyan); }
.btn-cyan:hover { background: var(--cyan-bright); color: var(--bg-deep); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger); color: var(--bg-deep); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; font-family: var(--font-mono); }
input[type="text"], input[type="password"], textarea {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 12px;
}
input:focus, textarea:focus { border-color: var(--cyan); }
textarea { resize: vertical; min-height: 72px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.file-row input[type="file"] {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 100%;
}
.file-preview { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--cyan-bright); font-family: var(--font-mono); }
.file-preview img { width: 36px; height: 36px; object-fit: cover; border: 1px solid var(--border-bright); }

.field-error { color: var(--danger); font-size: 12.5px; margin: -6px 0 10px; font-family: var(--font-mono); }

/* ---------- front page ---------- */

.hero {
  text-align: center;
  padding: 30px 0 36px;
}
.hero-mark { width: 150px; height: 130px; object-fit: contain; filter: drop-shadow(0 0 10px rgba(100,149,219,0.55)) drop-shadow(0 0 28px rgba(100,149,219,0.4)); }
.hero h1 {
  font-family: var(--font-display);
  font-size: 40px;
  margin: 14px 0 6px;
  letter-spacing: 0.01em;
}
.hero h1 .accent { color: var(--cyan); }
.hero p { color: var(--text-dim); max-width: 480px; margin: 0 auto; }

.board-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.board-card {
  padding: 18px;
  display: block;
}
.board-card .slug { font-family: var(--font-mono); color: var(--cyan); font-size: 13px; }
.board-card h3 { margin: 6px 0 6px; font-family: var(--font-display); font-size: 19px; color: var(--text); }
.board-card p { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.board-card:hover { border-color: var(--cyan); text-decoration: none; }

.hero-banner {
  margin-top: 28px;
  padding: 0;
  overflow: hidden;
  line-height: 0;
}
.hero-banner img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 1;
  object-fit: cover;
}

.recent-strip { margin-top: 36px; }
.recent-strip h2 { font-family: var(--font-mono); font-size: 13px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.recent-item {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px dashed var(--border);
  font-size: 13.5px;
}
.recent-item .board-pill { font-family: var(--font-mono); color: var(--cyan-deep); background: rgba(91,148,232,0.08); padding: 1px 6px; font-size: 11.5px; }
.empty-note { color: var(--text-faint); font-style: italic; font-size: 13.5px; }

/* ---------- board catalog ---------- */

.board-head { margin-bottom: 20px; }
.board-head h2 { font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; }
.board-head p { color: var(--text-dim); margin: 0; font-size: 13.5px; }

.new-thread-panel { padding: 18px; margin-bottom: 26px; }
.new-thread-panel h3 { margin: 0 0 14px; font-family: var(--font-display); font-size: 16px; color: var(--cyan-bright); }

.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.thread-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  color: var(--text);
}
.thread-card:hover { border-color: var(--cyan); }
.thread-card .thumb-wrap { height: 130px; display: flex; align-items: center; justify-content: center; background: var(--bg-deep); overflow: hidden; margin-bottom: 10px; border: 1px solid var(--border); }
.thread-card .thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.thread-card .thumb-wrap .no-img { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }
.thread-card .subject { font-weight: 600; color: var(--cyan-bright); font-size: 14px; margin-bottom: 4px; }
.thread-card .snippet {
  font-size: 13px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 8px; flex: 1;
}
.thread-card .meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); display: flex; gap: 10px; }

/* ---------- thread view ---------- */

.back-link { display: inline-block; margin-bottom: 16px; font-family: var(--font-mono); font-size: 13px; }

.post {
  display: flex;
  gap: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.post.op { border-color: var(--border-bright); }
.post.reply { margin-left: 28px; }
.post .thumb { flex-shrink: 0; }
.post .thumb img { width: 110px; max-height: 130px; object-fit: cover; border: 1px solid var(--border-bright); cursor: zoom-in; }
.post-body { flex: 1; min-width: 0; }
.post-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
}
.post-meta .name { color: var(--cyan-bright); font-weight: 600; }
.post-meta .postno { color: var(--text-dim); }
.post-meta a.quote-link { font-family: var(--font-mono); }
.post-subject { font-weight: 700; color: var(--text); margin-bottom: 6px; font-family: var(--font-display); }
.post-comment { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.post-comment .greentext { color: var(--cyan); }
.post-comment .backlink { color: var(--cyan-deep); border-bottom: 1px dotted var(--cyan-deep); }
.post-comment .spoiler { background: var(--border-dim); color: transparent; border-radius: 2px; cursor: pointer; user-select: none; padding: 0 2px; }
.post-comment .spoiler.revealed { color: inherit; background: var(--surface-raised); }

.fmt-toolbar { display: flex; gap: 6px; margin-bottom: 6px; }
.fmt-toolbar .fmt-btn { font-size: 12px; padding: 2px 8px; min-width: 32px; }
.post-actions { margin-top: 8px; display: flex; gap: 8px; }
.post:target, .post.highlight { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }

.quick-reply { padding: 18px; margin-top: 24px; }
.quick-reply h3 { margin: 0 0 14px; font-family: var(--font-display); font-size: 16px; color: var(--cyan-bright); }

.post.is-removed { opacity: 0.7; }
.removed-note { color: var(--text-faint); font-style: italic; font-size: 13.5px; }

/* ---------- moderation dashboard ---------- */

.mod-dashboard h2 { font-family: var(--font-display); font-size: 24px; margin: 0 0 20px; }
.mod-section { padding: 18px; margin-bottom: 22px; }
.mod-section h3 { margin: 0 0 14px; font-family: var(--font-display); font-size: 16px; color: var(--cyan-bright); }

.report-row {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  flex-wrap: wrap;
}
.report-row:last-child { border-bottom: none; }
.report-post { flex: 1; min-width: 220px; }
.report-post .name { font-family: var(--font-mono); color: var(--cyan-bright); font-weight: 600; margin-right: 8px; }
.report-post .postno { font-family: var(--font-mono); color: var(--text-dim); font-size: 12px; }
.report-post p { margin: 6px 0 0; font-size: 13.5px; color: var(--text); }
.report-post .thumb { margin-top: 8px; }
.report-post .thumb img { width: 140px; max-height: 140px; object-fit: cover; border: 1px solid var(--border-bright); cursor: zoom-in; }
.report-reason { color: var(--text-dim) !important; font-style: italic; font-size: 12.5px !important; }
.report-actions { display: flex; gap: 8px; flex-shrink: 0; }

.mod-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mod-table th { text-align: left; font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); padding: 6px 10px; border-bottom: 1px solid var(--border-bright); }
.mod-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mod-table select {
  background: var(--bg-deep); color: var(--text); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12.5px; padding: 4px 6px;
}
.tag-banned { color: var(--danger); font-family: var(--font-mono); font-size: 12px; }

.mod-log { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.mod-log-row {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
  padding: 6px 0; border-bottom: 1px dashed var(--border);
}
.mod-log-row:last-child { border-bottom: none; }
.mod-log-time { color: var(--text-faint); }
.mod-log-who { color: var(--cyan-bright); }
.mod-log-action { color: var(--text); font-weight: 600; }
.mod-log-reason { color: var(--text-faint); font-style: italic; }

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 10, 11, 0.78);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-panel {
  width: 100%; max-width: 380px;
  padding: 24px;
}
.modal-panel h2 { margin: 0 0 16px; font-family: var(--font-display); font-size: 20px; }
.modal-close-row { display: flex; justify-content: flex-end; margin-top: 4px; }
.modal-switch { font-size: 13px; color: var(--text-dim); margin-top: 10px; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 6, 7, 0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  padding: 30px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; box-shadow: 0 0 40px rgba(91,148,232,0.15); }

/* ---------- toast ---------- */

.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 70;
  padding: 12px 16px;
  background: var(--panel-alt);
  border: 1px solid var(--cyan);
  color: var(--text);
  font-size: 13.5px;
  max-width: 320px;
  clip-path: polygon(8px 0%, 100% 0%, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0% 100%, 0% 8px);
}
.toast.error { border-color: var(--danger); }
.toast[hidden] { display: none; }

/* ---------- misc ---------- */

.section-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
}

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: stretch; }
  .post.reply { margin-left: 10px; }
  .post { flex-direction: column; }
  .post .thumb img { width: 100%; max-height: 220px; }
  .hero h1 { font-size: 30px; }
}
