/* styles/base.css — design tokens, reset, shared primitives */

:root {
  --bg: #eef2f7;                   /* barely-off-white blue */
  --bg-elevated: #e3e9f1;
  --bg-input: #f6f9fc;
  --text: #1a1d22;
  --text-muted: #5d6470;
  --text-faint: #8a919d;
  --border: #d2d8e2;
  --border-strong: #a8b0bd;
  --accent-cool: #4a8d99;          /* washed teal — water, screens */
  --accent-cool-soft: #c4dde2;
  --accent-warm: #c2580c;          /* sodium amber — warm counterpoint */
  --accent-warm-soft: #f0d9bc;
  --accent-glow: 194,88,12;
  --name-anon: #4f8a6e;            /* sage — nature */
  --name-user: #2c6e78;            /* deeper teal */
  --tripcode: #c2580c;
  --quotelink: #b04a0c;
  --greentext: #5e8b3b;
  --shadow-card: 0 1px 0 rgba(31,29,26,.04), 0 8px 24px -16px rgba(31,29,26,.18);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

[data-theme="dark"] {
  --bg: #15171a;
  --bg-elevated: #1c1f23;
  --bg-input: #0f1114;
  --text: #e6e0d2;
  --text-muted: #8a857a;
  --text-faint: #5b574f;
  --border: #2a2d33;
  --border-strong: #3a3e45;
  --accent-cool: #6db3b8;
  --accent-cool-soft: #2a4448;
  --accent-warm: #ff9b4a;          /* sodium streetlight — the star in dark mode */
  --accent-warm-soft: #4a2e1c;
  --accent-glow: 255,155,74;
  --name-anon: #7fa890;
  --name-user: #6db3b8;
  --tripcode: #ff9b4a;
  --quotelink: #ffb074;
  --greentext: #9bbf7a;
  --shadow-card: 0 1px 0 rgba(0,0,0,.4), 0 12px 32px -20px rgba(0,0,0,.6);
}

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

body {
  font-family: "Instrument Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color .35s ease, color .35s ease;
  position: relative;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain);
  opacity: .9;
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::before {
  mix-blend-mode: screen; opacity: .35;
}

main {
  max-width: 980px; margin: 0 auto;
  padding: 24px 22px 120px;
  position: relative; z-index: 1;
}
@media (max-width: 640px) {
  main { padding: 14px 12px 96px; }
}

/* ============ shared button primitives ============ */

button.btn, a.btn {
  font-family: "Instrument Sans", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 2px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex; align-items: center; gap: 7px;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
button.btn:hover, a.btn:hover {
  border-color: var(--accent-warm);
  color: var(--accent-warm);
  background: var(--accent-warm-soft);
}
button.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
button.btn.primary:hover {
  background: var(--accent-warm);
  border-color: var(--accent-warm);
  color: var(--bg);
}

.icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: 2px; cursor: pointer; color: var(--text);
  transition: all .18s ease;
}
.icon-btn:hover { border-color: var(--accent-warm); color: var(--accent-warm); }
.icon-btn svg { width: 15px; height: 15px; }

/* ============ initial-load animation ============ */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* styles/topbar.css — sticky top bar */

header.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 980px; margin: 0 auto;
  padding: 14px 22px;
  display: flex; align-items: baseline; gap: 18px;
}

.brand {
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  text-decoration: none;
  transition: color .18s ease;
}
.brand:hover { color: var(--accent-warm); }
.brand .brand-sep {
  color: var(--accent-cool);
  font-weight: 500;
  margin: 0 2px;
}
.brand .brand-num {
  color: var(--accent-warm);
  font-weight: 500;
  font-size: 14px;
}

.tagline {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.tagline .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-warm); margin: 0 8px;
  box-shadow: 0 0 10px rgba(var(--accent-glow), .6);
  vertical-align: 1px;
}

.topbar-actions {
  margin-left: auto;
  display: flex; gap: 6px; align-items: center;
}

.identity-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .18s ease;
}
.identity-pill .ident-name { color: var(--name-anon); }
.identity-pill.has-name .ident-name { color: var(--name-user); }
.identity-pill .ident-trip { color: var(--tripcode); margin-left: 2px; }
.identity-pill:hover { border-color: var(--accent-warm); }

@media (max-width: 640px) {
  .topbar-inner { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .tagline { display: none; }
}
/* styles/board-meta.css — counts strip above the thread list */

.board-meta {
  display: flex; align-items: center; gap: 18px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 0 18px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 22px;
}
.board-meta span strong { color: var(--text-muted); font-weight: 500; }
.new-thread-btn {
  margin-bottom: 22px;
}
.new-thread-btn svg {
  width: 14px; height: 14px;
  color: var(--accent-cool); flex-shrink: 0;
}

@media (max-width: 640px) {
  .board-meta {
    gap: 10px 14px; flex-wrap: wrap;
    padding: 2px 0 12px;
    margin-bottom: 14px;
  }
  .board-meta span[style] { margin-left: 0 !important; }
  .new-thread-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 12px;
    margin-bottom: 14px;
  }
}
/* styles/thread.css — thread card + post-meta + post-content + stats */

.thread {
  margin: 0 0 18px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: var(--shadow-card);
  transition: border-color .2s ease, transform .2s ease;
  position: relative;
  animation: fadeUp .5s ease-out backwards;
}
.thread:hover { border-color: var(--border-strong); }
.thread.expanded { border-color: var(--accent-cool); }

.thread:nth-child(2) { animation-delay: .04s; }
.thread:nth-child(3) { animation-delay: .08s; }
.thread:nth-child(4) { animation-delay: .12s; }
.thread:nth-child(5) { animation-delay: .16s; }
.thread:nth-child(6) { animation-delay: .20s; }
.thread:nth-child(7) { animation-delay: .24s; }

.thread-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
}

.thread-thumb {
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  cursor: zoom-in;
  background: var(--bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
  max-width: 220px;
  max-height: 220px;
  line-height: 0;
}
.thread-thumb svg, .thread-thumb img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
}
.thread-thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.15));
  pointer-events: none;
}

.thread-body { min-width: 0; }

/* ============ post-meta (shared with replies) ============ */

.post-meta {
  display: flex; align-items: baseline; gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.post-meta .subject {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--text);
  flex-basis: 100%;
  padding-right: 108px;
  margin-right: 0;
}
.post-meta .name { color: var(--name-anon); font-weight: 500; }
.post-meta .name.has-name { color: var(--name-user); }
.post-meta .trip { color: var(--tripcode); }
.post-meta .flag { font-size: 14px; line-height: 1; }
.post-meta .timestamp { color: var(--text-faint); }
.post-meta .postno {
  color: var(--text-muted); cursor: pointer;
  transition: color .15s;
}
.post-meta .postno:hover { color: var(--accent-warm); }

/* ============ post content (shared with replies) ============ */

.post-content {
  font-size: 14.5px;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.post-content .greentext { color: var(--greentext); }
.post-content .quotelink {
  color: var(--quotelink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--quotelink) 40%, transparent);
  text-underline-offset: 2px;
  cursor: pointer;
}
.post-content .quotelink:hover {
  text-decoration-color: var(--quotelink);
  background: var(--accent-warm-soft);
}

/* ============ thread stats row ============ */

.thread-stats {
  margin-top: 10px;
  display: flex; gap: 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.thread-actions {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  z-index: 2;
}
.thread-actions .open-link {
  color: var(--accent-cool);
  cursor: pointer;
  text-decoration: none;
  padding: 2px 4px;
  margin: -2px -4px;
}
.thread-actions .open-link:hover { color: var(--accent-warm); }

@media (max-width: 640px) {
  .thread { padding: 12px; }
  .thread-head { gap: 10px; }
  .thread-thumb,
  .thread-thumb img,
  .thread-thumb svg {
    max-width: 140px;
    max-height: 140px;
  }
  .thread-actions { top: 10px; right: 10px; font-size: 11.5px; }
  .post-meta { gap: 6px; font-size: 11.5px; }
  .post-meta .subject { font-size: 13px; }
  .post-content { font-size: 14px; }
  .thread-stats { font-size: 10.5px; gap: 12px; }
}
/* styles/reply.css — reply rows + omitted-link indicator */

.replies {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.omitted-link {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0;
  color: var(--text-muted);
  padding: 6px 14px;
  margin: 0 0 10px;
  cursor: pointer;
  border-left: 2px dashed var(--border);
  transition: color .15s, border-color .15s;
}
.omitted-link:hover {
  color: var(--accent-warm);
  border-left-color: var(--accent-warm);
}
.omitted-link .open-action {
  color: var(--accent-cool);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-cool) 40%, transparent);
  text-underline-offset: 2px;
  margin-left: 6px;
}
.omitted-link:hover .open-action {
  color: var(--accent-warm);
  text-decoration-color: var(--accent-warm);
}

.reply {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: 2px;
  border-left: 2px solid var(--border);
  transition: border-color .15s;
  align-items: start;
}
.reply:target,
.reply.flash {
  border-left-color: var(--accent-warm);
  animation: flash 1.4s ease-out;
}
@keyframes flash {
  0%   { background: var(--accent-warm-soft); }
  100% { background: var(--bg); }
}
.reply.no-image { grid-template-columns: 1fr; }
.reply.no-image .post-meta { padding-left: 0; }

.reply-thumb {
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  max-width: 160px;
  max-height: 160px;
  line-height: 0;
  cursor: zoom-in;
}
.reply-thumb svg, .reply-thumb img {
  display: block;
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
}

.reply .post-meta { font-size: 11px; }
.reply .post-content { font-size: 14px; }

@media (max-width: 640px) {
  .replies { margin-top: 10px; padding-top: 10px; }
  .reply { gap: 8px; padding: 8px 10px; }
  .reply-thumb,
  .reply-thumb img,
  .reply-thumb svg {
    max-width: 110px;
    max-height: 110px;
  }
  .reply .post-meta { gap: 5px; font-size: 10.5px; }
  .reply .post-meta .subject { padding-right: 0; flex-basis: auto; }
  .reply .post-content { font-size: 13.5px; line-height: 1.5; }
  .omitted-link { font-size: 11px; padding: 5px 12px; }
}
/* styles/settings-modal.css — identity & preferences dialog */

.modal-backdrop {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--bg) 70%, #000 30%);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  width: 100%; max-width: 460px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.4);
  overflow: hidden;
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}

.modal-body { padding: 18px 20px; }
.modal-body label,
.modal-body .field-label {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 14px 0 6px;
}
.modal-body label:first-child,
.modal-body .field-label:first-child { margin-top: 0; }

.modal-body input[type="text"],
.modal-body textarea,
.modal-body select {
  -webkit-appearance: none;
  appearance: none;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 8px 10px;
  width: 100%;
  display: block;
  transition: border-color .15s, box-shadow .15s;
}
.modal-body input::placeholder,
.modal-body textarea::placeholder {
  color: var(--text-faint);
}
.modal-body textarea {
  min-height: 140px;
  resize: vertical;
}
.modal-body .file-label {
  display: flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: 2px;
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.modal-body .file-label:hover {
  border-color: var(--accent-cool);
  color: var(--accent-cool);
}
.modal-body .file-label .file-name {
  font-family: "Instrument Sans", sans-serif;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-faint);
}
.modal-body .file-label .file-name.has-file {
  color: var(--text);
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--accent-cool);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-cool) 20%, transparent);
}

.modal-body .help {
  font-size: 12px; color: var(--text-faint);
  margin-top: 4px; line-height: 1.45;
}
.upload-status { font-size: 0.75rem; margin-top: 4px; display: block; }
.upload-status.uploading { color: var(--accent-cool); }
.upload-status.error { color: var(--accent-warm); }
.upload-status.success { color: var(--accent-cool); }
.modal-body .help code {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  background: var(--bg);
  padding: 1px 4px; border-radius: 2px;
  border: 1px solid var(--border);
  color: var(--tripcode);
}

.modal-body .toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.modal-body .toggle-row .label { font-size: 14px; }
.modal-body .toggle-row .sub { font-size: 12px; color: var(--text-faint); }

/* ============ toggle switch ============ */

.switch { position: relative; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong);
  border-radius: 999px; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute;
  height: 14px; width: 14px;
  left: 3px; top: 3px;
  background: var(--bg);
  border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .slider { background: var(--accent-cool); }
.switch input:checked + .slider::before { transform: translateX(16px); }

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

.compose-drawer {
  position: fixed;
  top: 50%;
  right: 24px;
  transform: translate(12px, -50%);
  z-index: 9999;
  width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  box-shadow: 0 8px 32px -8px rgba(0,0,0,.3);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: transform .15s ease-out, opacity .15s ease-out;
}
.compose-drawer.open {
  transform: translate(0, -50%);
  opacity: 1;
  pointer-events: auto;
}
.compose-drawer .modal-body textarea { min-height: 100px; }

@media (max-width: 640px) {
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal { max-width: 100%; max-height: calc(100vh - 24px); display: flex; flex-direction: column; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; overflow-y: auto; }
  .modal-foot { padding: 12px 16px; }
  .modal-body textarea { min-height: 100px; }

  .compose-drawer {
    top: auto; bottom: 0; left: 0; right: 0;
    transform: translateY(12px);
    width: 100%;
    max-height: 85vh;
    border-radius: 2px 2px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    box-shadow: 0 -8px 32px -8px rgba(0,0,0,.3);
  }
  .compose-drawer.open {
    transform: translateY(0);
  }
}
.thread-thumb.expanded,
.reply-thumb.expanded {
  max-width: none;
  max-height: none;
  overflow: visible;
  grid-column: 1 / -1;
  cursor: zoom-out;
}
.thread-thumb.expanded::after {
  display: none;
}
.thread-thumb.expanded img,
.thread-thumb.expanded svg,
.reply-thumb.expanded img,
.reply-thumb.expanded svg {
  max-width: 100vw;
  max-height: none;
  cursor: zoom-out;
}

/* styles/login.css — login page */

.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%; max-width: 340px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: var(--shadow-card);
  padding: 32px 28px 28px;
  animation: fadeUp .5s ease-out backwards;
}

.login-brand {
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.03em;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
}
.login-brand .brand-sep {
  color: var(--accent-cool);
  font-weight: 500;
}

.login-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-faint);
  text-align: center;
  margin-bottom: 28px;
}

.login-error:empty { display: none; }
.login-error {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--accent-warm);
  text-align: center;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--accent-warm-soft);
  background: var(--accent-warm-soft);
  border-radius: 2px;
}

.login-field { margin-bottom: 16px; }

.login-label {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.login-input {
  -webkit-appearance: none;
  appearance: none;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 12px;
  width: 100%;
  display: block;
  transition: border-color .15s, box-shadow .15s;
}
.login-input::placeholder { color: var(--text-faint); }
.login-input:focus {
  outline: none;
  border-color: var(--accent-cool);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-cool) 20%, transparent);
}

.login-btn {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font-size: 13px;
  justify-content: center;
}

@media (max-width: 640px) {
  .login-card { padding: 28px 22px 24px; }
  .login-brand { font-size: 22px; }
}

/* styles/footer.css — bottom mark */

.footer {
  margin-top: 30px; padding-top: 20px;
  border-top: 1px dashed var(--border);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.04em;
}
.footer .sep {
  color: var(--accent-cool);
  margin: 0 6px;
}
