@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Merriweather:ital,wght@0,300;0,400;0,700;1,300;1,400&display=swap');

:root {
  --bg: #0d0c0a;
  --bg-warm: #100e0b;
  --surface: #16130f;
  --border: #2a2622;
  --hairline: #221e1a;
  --text: #d8d2c4;
  --text-dim: #a89e8b;
  --muted: #6b6357;
  --faint: #3a342d;
  --accent: #e8b04a;
  --accent-dim: #b58836;
  --danger: #d97a6a;
  --dots: #1a1612;
  --serif: 'Merriweather', Georgia, serif;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--mono);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 55% 50% at 50% 45%, var(--bg) 0%, var(--bg) 30%, transparent 75%),
    radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: auto, 22px 22px;
  background-position: 0 0, 0 0;
  background-attachment: fixed, fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
a:hover { border-bottom-color: var(--accent-dim); }

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

#toastHost {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-warn { border-color: var(--accent-dim); color: var(--accent); }

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

button, .btn-primary, .btn-secondary, .link-btn {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
button:hover, .link-btn:hover, .btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #1a1410;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #1a1410;
}

.btn-secondary {
  display: inline-block;
  text-align: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-secondary:hover { border-bottom-color: var(--accent); }

input, textarea {
  font-family: var(--mono);
  background: var(--bg-warm);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}
textarea {
  font-size: 0.92rem;
  resize: vertical;
  min-height: 70px;
  line-height: 1.55;
}

/* ---------- login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 340px;
  padding: 36px 32px 28px;
  text-align: center;
}
.login-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: -0.04em;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(232, 176, 74, 0.25);
}
.login-sub {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form .btn-primary { padding: 10px; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--hairline);
}
.btn-secondary {
  width: 100%;
  padding: 10px;
}
.login-err {
  color: var(--danger);
  font-family: var(--mono);
  font-size: 0.8rem;
  margin-top: 14px;
  min-height: 1em;
}

/* ---------- menu (hamburger) ---------- */

.menu-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4.5px;
  z-index: 20;
  cursor: pointer;
}
.menu-btn span {
  display: block;
  width: 16px;
  height: 1px;
  background: var(--text-dim);
  transition: transform 0.2s, opacity 0.2s, background 0.15s;
}
.menu-btn:hover span { background: var(--accent); }
.menu-btn.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.menu-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 19;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.menu-search {
  margin-bottom: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
}
.menu-divider {
  height: 1px;
  background: var(--hairline);
  margin: 6px 0;
}
.menu-link, .menu-link.as-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 7px 10px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0;
}
.menu-link:hover, .menu-link.as-btn:hover {
  background: var(--bg-warm);
  color: var(--accent);
  border-bottom: none;
}
.menu-form { margin: 0; padding: 0; }

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 32px;
  max-width: 880px;
  margin: 64px auto 80px;
  padding: 0 24px;
}

body.anon .layout,
body.sidebar-hidden .layout {
  grid-template-columns: minmax(0, 1fr);
  max-width: 620px;
}
body.anon .side-col,
body.sidebar-hidden .side-col { display: none; }

.main-col { min-width: 0; }

.side-col {
  font-family: var(--mono);
  font-size: 0.8rem;
  position: sticky;
  top: 64px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.side-col h2 {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.tag-list { list-style: none; }
.tag-list li { padding: 1px 0; }
.tag-list a {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 3px;
  color: var(--text-dim);
  border-bottom: none;
}
.tag-list a:hover {
  background: var(--bg-warm);
  color: var(--accent);
}
.tag-list a.active { color: var(--accent); background: var(--bg-warm); }
.tag-list .count { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 18px; }
  .side-col { position: static; max-height: none; margin-top: 20px; }
  .tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
  .tag-list li { padding: 0; }
  .menu-btn { top: 12px; right: 12px; }
  .menu-panel { top: 56px; right: 12px; left: 12px; min-width: 0; }
}

/* ---------- composer ---------- */

.composer {
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(22, 19, 15, 0.5);
}
.composer.drag-over {
  border-color: var(--accent);
  background: rgba(232, 176, 74, 0.04);
}
.composer textarea { border: none; background: transparent; padding: 4px 0; min-height: 56px; }
.composer textarea:focus { outline: none; }

.composer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
}
.composer-foot .hint {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  flex: 1;
}
.file-btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}
.file-btn:hover { border-color: var(--accent); color: var(--accent); }

.media-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}
.media-preview:empty { display: none; }
.media-preview .item {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--hairline);
}
.media-preview .item img,
.media-preview .item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-preview .item .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.media-preview .item .status {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 0.7rem;
  background: rgba(0,0,0,0.75);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  color: #fff;
}

/* ---------- timeline ---------- */

.filter-banner {
  border-bottom: 1px solid var(--hairline);
  padding: 8px 4px 12px;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.timeline { display: flex; flex-direction: column; }

.post {
  padding: 18px 4px;
  position: relative;
}
.post.clickable { cursor: pointer; }
.post.clickable:hover { background: rgba(232, 176, 74, 0.02); }

.post-text {
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 12px;
  color: var(--text);
}
.post-text:empty { display: none; }

.thread { margin-bottom: 28px; }
.thread-replies {
  padding-left: 22px;
  position: relative;
}
.thread-replies::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 4px;
  bottom: 14px;
  width: 1px;
  background: var(--border);
}
.thread-replies .post {
  padding-top: 12px;
  padding-bottom: 12px;
}
.thread-replies .post-text { font-size: 0.88rem; }
.post-text .hashtag {
  color: var(--accent);
  font-family: var(--mono);
  border-bottom: none;
}
.post-text .hashtag:hover { border-bottom: 1px dotted var(--accent); }

.post-media {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  border-radius: 6px;
  overflow: hidden;
}
.post-media.count-1 { grid-template-columns: 1fr; }
.post-media.count-2 { grid-template-columns: 1fr 1fr; }
.post-media.count-3, .post-media.count-4 { grid-template-columns: 1fr 1fr; }
.post-media .item {
  position: relative;
  background: var(--bg);
  max-height: 480px;
  overflow: hidden;
}
.post-media .item img,
.post-media .item video {
  width: 100%;
  height: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
}

.post-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.post-foot a {
  color: var(--muted);
  border-bottom: none;
}
.post-foot a:hover { color: var(--accent); }
.post-foot .grow { flex: 1; }
.post-foot .delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}
.post-foot .delete-btn:hover { color: var(--danger); }

.load-more {
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  font-family: var(--mono);
  color: var(--text-dim);
}

/* ---------- single post / replies ---------- */

.single-post {
  max-width: 640px;
  margin: 64px auto 80px;
  padding: 0 24px;
}
.single-post .post {
  padding: 24px 4px 28px;
  border-bottom: 2px solid var(--hairline);
}
.single-post .post-text { font-size: 1.08rem; }
.replies-header {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  margin: 24px 0 4px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.reply-composer { margin: 18px 0 0; }

.not-found {
  font-family: var(--mono);
  color: var(--muted);
  text-align: center;
  padding: 60px 0;
}
