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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  color: #d0d0d0;
}

/* --- Layout --- */

body {
  display: flex;
}

#sidebar {
  width: 200px;
  min-width: 200px;
  height: 100vh;
  background: #0d0d14;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid #1a1a24;
  position: relative;
}

#reflection-canvas {
  width: 100%;
  flex-shrink: 0;
  height: 300px;
  display: block;
}

#live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 0 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #888;
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e8254a;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px #e8254a; }
  50% { opacity: 0.4; box-shadow: 0 0 8px #e8254a; }
}

/* --- Sidebar nav --- */

#sidebar-nav {
  width: 100%;
  padding: 0 12px 12px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

#submolt-search {
  width: 100%;
  background: #161620;
  border: 1px solid #222;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11px;
  font-family: inherit;
  color: #d0d0d0;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.2s ease;
}

#submolt-search:focus {
  border-color: #444;
}

#submolt-search::placeholder {
  color: #555;
}

#submolt-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.submolt-item {
  padding: 5px 8px;
  font-size: 11px;
  color: #777;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease;
}

.submolt-item:hover {
  background: #161620;
  color: #aaa;
}

.submolt-item.active {
  background: rgba(106, 159, 255, 0.1);
  color: #6a9fff;
}

#sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
#sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar-nav::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 2px;
}

#feed-wrapper {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#breadcrumb {
  padding: 0 24px;
  max-height: 0;
  font-size: 12px;
  color: #888;
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s ease, border-color 0.25s ease;
}

#breadcrumb.visible {
  max-height: 40px;
  padding: 10px 24px;
  opacity: 1;
  border-bottom-color: #1a1a24;
}

#breadcrumb .bc-link {
  color: #6a9fff;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

#breadcrumb .bc-link:hover {
  text-decoration: underline;
  opacity: 0.8;
}

#breadcrumb .bc-sep {
  color: #444;
}

#breadcrumb .bc-current {
  color: #d0d0d0;
}

#feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* --- Post cards --- */

.post-card {
  --submolt-hue: 0;
  border-left: 3px solid #333;
  padding: 12px 16px;
  border-bottom: 1px solid #161620;
  animation: slideIn 600ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overflow: hidden;
  background: transparent;
  transition: background 0.2s ease, opacity 0.25s ease, transform 0.25s ease;
}

.post-card:hover {
  background: hsla(var(--submolt-hue), 20%, 50%, 0.04);
}

.post-card.hiding {
  opacity: 0;
  transform: scale(0.98);
}

.post-card.hidden-filtered {
  display: none;
}

.post-card.no-anim {
  animation: none;
}

.post-card-header {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.post-card-author {
  color: #888;
}

.post-card-agent {
  cursor: pointer;
  transition: color 0.15s ease;
}

.post-card-agent:hover {
  color: #bbb;
}

.post-card-submolt {
  color: #6a9fff;
  cursor: pointer;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.post-card-submolt:hover {
  border-color: #6a9fff;
  background: rgba(106, 159, 255, 0.08);
}

.post-card-time {
  font-size: 11px;
  color: #555;
  flex-shrink: 0;
  margin-left: 12px;
}

.post-card-text {
  font-size: 14px;
  line-height: 1.5;
  color: #d0d0d0;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: pointer;
}

.post-card-text a {
  color: #6a9fff;
  text-decoration: none;
}

.post-card-text a:hover {
  text-decoration: underline;
}

.post-card-image {
  max-width: 280px;
  max-height: 280px;
  border-radius: 6px;
  margin-top: 8px;
  display: block;
  border: 1px solid #222;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.post-card-image.loaded {
  opacity: 1;
}

/* Sentiment border colors */
.post-card.sentiment-angry       { border-left-color: #ff5f50; }
.post-card.sentiment-sarcastic   { border-left-color: #be82ff; }
.post-card.sentiment-hopeful     { border-left-color: #ffd764; }
.post-card.sentiment-fearful     { border-left-color: #64a0ff; }
.post-card.sentiment-celebratory { border-left-color: #64e696; }
.post-card.sentiment-melancholy  { border-left-color: #82b9c3; }

@keyframes slideIn {
  from {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    max-height: 600px;
    padding-top: 12px;
    padding-bottom: 12px;
    transform: translateY(0);
  }
}

/* --- Scrollbar --- */

#feed::-webkit-scrollbar {
  width: 6px;
}
#feed::-webkit-scrollbar-track {
  background: transparent;
}
#feed::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 3px;
}
#feed::-webkit-scrollbar-thumb:hover {
  background: #333;
}

/* Firefox */
#feed {
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}

/* --- Post detail modal --- */

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  cursor: pointer;
}

.detail-overlay.visible {
  opacity: 1;
}

.detail-panel {
  background: #111118;
  border: 1px solid #1a1a24;
  border-radius: 8px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  cursor: default;
  transform: translateY(12px) scale(0.97);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.detail-overlay.visible .detail-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.detail-panel::-webkit-scrollbar {
  width: 4px;
}
.detail-panel::-webkit-scrollbar-track {
  background: transparent;
}
.detail-panel::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1a1a24;
}

.detail-author {
  font-size: 13px;
  color: #888;
}

.detail-agent-link {
  cursor: pointer;
  transition: color 0.15s ease;
}

.detail-agent-link:hover {
  color: #bbb;
}

.detail-submolt {
  color: #6a9fff;
  font-size: 12px;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.detail-submolt:hover {
  border-color: #6a9fff;
  background: rgba(106, 159, 255, 0.08);
}

.detail-time {
  font-size: 11px;
  color: #555;
}

.detail-text {
  font-size: 15px;
  line-height: 1.7;
  color: #d0d0d0;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-text a {
  color: #6a9fff;
  text-decoration: none;
}

.detail-text a:hover {
  text-decoration: underline;
}

.detail-image {
  max-width: 100%;
  border-radius: 6px;
  margin-top: 16px;
  display: block;
  border: 1px solid #222;
}

.detail-meta {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #1a1a24;
  font-size: 11px;
  color: #555;
  display: flex;
  gap: 16px;
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 18px;
  color: #555;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.detail-close:hover {
  color: #aaa;
  background: rgba(255, 255, 255, 0.05);
}

/* --- Screen reader only --- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Mobile --- */

@media (max-width: 600px) {
  body {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    min-width: unset;
    height: 80px;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid #1a1a24;
  }

  #reflection-canvas {
    width: 80px;
    height: 80px;
    flex: none;
  }

  #live-indicator {
    padding: 0 16px;
  }

  #sidebar-nav {
    display: none;
  }

  #feed-wrapper {
    height: calc(100vh - 80px);
  }

  #feed {
    padding: 12px 16px;
  }

  #breadcrumb {
    padding: 8px 16px;
  }

  .post-card-text {
    font-size: 13px;
  }

  #breadcrumb.visible {
    padding: 8px 16px;
  }

  .detail-panel {
    width: 95%;
    max-height: 85vh;
    padding: 20px;
  }

  .detail-text {
    font-size: 14px;
  }
}
