/* ============================================================
   TAOR — TheAgeOfRenaissance
   Design System · styles.css
   Fonts: Cormorant (brand) + IBM Plex Sans (UI)
   ============================================================ */

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

/* ============================================================
   1. CSS CUSTOM PROPERTIES — LIGHT MODE (DEFAULT)
   ============================================================ */

:root {
  /* --- Brand --- */
  --brand-serif: 'Cormorant', Georgia, serif;
  --brand-sans: 'IBM Plex Sans', 'Helvetica Neue', sans-serif;

  /* --- Accent --- */
  --accent:        #B8965A;   /* muted Renaissance gold */
  --accent-hover:  #A07A3E;
  --accent-dim:    rgba(184, 150, 90, 0.12);
  --accent-border: rgba(184, 150, 90, 0.30);

  /* --- Surfaces --- */
  --bg-page:       #F7F6F3;   /* warm off-white, like aged paper */
  --bg-surface:    #FFFFFF;
  --bg-elevated:   #FFFFFF;
  --bg-overlay:    rgba(247, 246, 243, 0.92);
  --bg-input:      #F2F1EE;
  --bg-hover:      #EFEDE9;
  --bg-active:     #E8E6E1;
  --bg-sidebar:    #EFEDE8;
  --bg-code:       #F0EEE9;

  /* --- Borders --- */
  --border-subtle:  #E5E3DE;
  --border-default: #D8D5CF;
  --border-strong:  #B8B5AE;
  --border-focus:   var(--accent);

  /* --- Text --- */
  --text-primary:   #18171A;
  --text-secondary: #5C5954;
  --text-tertiary:  #8C8880;
  --text-disabled:  #B8B5AE;
  --text-inverse:   #FFFFFF;
  --text-accent:    var(--accent);
  --text-link:      #2563EB;

  /* --- Status --- */
  --success:        #166534;
  --success-bg:     #F0FDF4;
  --warning:        #92400E;
  --warning-bg:     #FFFBEB;
  --danger:         #991B1B;
  --danger-bg:      #FEF2F2;
  --info:           #1E40AF;
  --info-bg:        #EFF6FF;

  /* --- Shadows --- */
  --shadow-xs:  0 1px 2px rgba(24, 23, 26, 0.05);
  --shadow-sm:  0 1px 4px rgba(24, 23, 26, 0.07), 0 1px 2px rgba(24, 23, 26, 0.04);
  --shadow-md:  0 4px 12px rgba(24, 23, 26, 0.08), 0 2px 4px rgba(24, 23, 26, 0.05);
  --shadow-lg:  0 12px 32px rgba(24, 23, 26, 0.10), 0 4px 8px rgba(24, 23, 26, 0.06);
  --shadow-xl:  0 24px 56px rgba(24, 23, 26, 0.12), 0 8px 16px rgba(24, 23, 26, 0.08);

  /* --- Radii --- */
  --radius-xs:  3px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* --- Spacing Scale --- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* --- Layout --- */
  --nav-height:     60px;
  --sidebar-width:  240px;
  --content-max:    720px;
  --panel-width:    280px;

  /* --- Transitions --- */
  --ease-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-default: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-slow:   350ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   2. DARK MODE TOKENS
   ============================================================ */

[data-theme="dark"] {
  --accent:        #C9A86C;
  --accent-hover:  #DFC080;
  --accent-dim:    rgba(201, 168, 108, 0.12);
  --accent-border: rgba(201, 168, 108, 0.25);

  --bg-page:       #111010;
  --bg-surface:    #1A1917;
  --bg-elevated:   #222120;
  --bg-overlay:    rgba(17, 16, 16, 0.92);
  --bg-input:      #1E1D1B;
  --bg-hover:      #242220;
  --bg-active:     #2C2A27;
  --bg-sidebar:    #161514;
  --bg-code:       #1E1D1B;

  --border-subtle:  #2A2826;
  --border-default: #343230;
  --border-strong:  #48453F;
  --border-focus:   var(--accent);

  --text-primary:   #F0EDE8;
  --text-secondary: #9B9690;
  --text-tertiary:  #6B6760;
  --text-disabled:  #48453F;
  --text-inverse:   #111010;
  --text-accent:    var(--accent);
  --text-link:      #93C5FD;

  --success:        #86EFAC;
  --success-bg:     rgba(134, 239, 172, 0.08);
  --warning:        #FCD34D;
  --warning-bg:     rgba(252, 211, 77, 0.08);
  --danger:         #FCA5A5;
  --danger-bg:      rgba(252, 165, 165, 0.08);
  --info:           #93C5FD;
  --info-bg:        rgba(147, 197, 253, 0.08);

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm:  0 1px 4px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg:  0 12px 32px rgba(0, 0, 0, 0.40), 0 4px 8px rgba(0, 0, 0, 0.30);
  --shadow-xl:  0 24px 56px rgba(0, 0, 0, 0.50), 0 8px 16px rgba(0, 0, 0, 0.35);
}

/* ============================================================
   3. RESET & BASE
   ============================================================ */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--brand-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-page);
  transition: background-color var(--ease-default), color var(--ease-default);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--ease-fast), opacity var(--ease-fast);
}

a:hover { opacity: 0.8; }

img { max-width: 100%; display: block; }

button {
  font-family: var(--brand-sans);
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

input, textarea, select {
  font-family: var(--brand-sans);
  font-size: inherit;
  color: inherit;
}

ul, ol { list-style: none; }

/* ============================================================
   4. SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   5. TYPOGRAPHY
   ============================================================ */

.font-brand { font-family: var(--brand-serif); }
.font-ui    { font-family: var(--brand-sans); }

/* Display — used for TAOR logo and hero headings */
.text-display {
  font-family: var(--brand-serif);
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.text-h1 {
  font-family: var(--brand-serif);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.text-h2 {
  font-family: var(--brand-serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.text-h3 {
  font-family: var(--brand-sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.4;
}

.text-body    { font-size: 0.95rem; line-height: 1.65; }
.text-sm      { font-size: 0.85rem; line-height: 1.5; }
.text-xs      { font-size: 0.78rem; line-height: 1.45; }
.text-label   { font-size: 0.78rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-accent    { color: var(--text-accent); }
.text-danger    { color: var(--danger); }
.text-success   { color: var(--success); }

.fw-300 { font-weight: 300; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ============================================================
   6. LAYOUT
   ============================================================ */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  z-index: 100;
  transition: background var(--ease-default), border-color var(--ease-default);
}

.navbar-brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-logo {
  font-family: var(--brand-serif);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.navbar-logo span {
  color: var(--accent);
}

.navbar-tagline {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: none;
}

@media (min-width: 900px) { .navbar-tagline { display: block; } }

.navbar-search {
  flex: 1;
  max-width: 380px;
  margin: 0 auto;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-left: auto;
}

/* --- Main body layout --- */
.app-body {
  display: flex;
  padding-top: var(--nav-height);
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: var(--space-4) 0;
  transition: background var(--ease-default), border-color var(--ease-default), transform var(--ease-default);
  z-index: 80;
}

.sidebar-section {
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 var(--space-3) var(--space-2);
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
  text-decoration: none;
  transition: background var(--ease-fast), color var(--ease-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}

.sidebar-link .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
}

.sidebar-link.active .icon,
.sidebar-link:hover .icon { opacity: 1; }

.sidebar-link .badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-active);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-link.active .badge {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-3) var(--space-4);
}

/* --- Main content area --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

/* ============================================================
   7. SEARCH INPUT
   ============================================================ */

.search-wrap {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3) 0 var(--space-8);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--ease-fast), background var(--ease-fast), box-shadow var(--ease-fast);
}

.search-input::placeholder { color: var(--text-tertiary); }

.search-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ============================================================
   8. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  border: none;
  outline: none;
  transition: background var(--ease-fast), color var(--ease-fast), box-shadow var(--ease-fast), transform var(--ease-fast), opacity var(--ease-fast);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  font-family: var(--brand-sans);
}

.btn:active { transform: scale(0.975); }

.btn-primary {
  background: var(--text-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--text-secondary);
  opacity: 1;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-hover);
  opacity: 1;
}

.btn-secondary {
  background: var(--bg-active);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
  opacity: 1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  opacity: 1;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(153, 27, 27, 0.2);
}

.btn-danger:hover { background: var(--danger); color: #fff; opacity: 1; }

.btn-sm {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: 0.82rem;
}

.btn-lg {
  height: 44px;
  padding: 0 var(--space-6);
  font-size: 0.95rem;
}

.btn-icon {
  width: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
  width: 30px;
}

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

/* ============================================================
   9. FORM ELEMENTS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast), background var(--ease-fast);
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-textarea {
  width: 100%;
  min-height: 140px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
  resize: vertical;
  line-height: 1.65;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast), background var(--ease-fast);
}

.form-textarea::placeholder { color: var(--text-tertiary); }

.form-textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

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

.form-error {
  font-size: 0.8rem;
  color: var(--danger);
}

.form-select {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239B9690' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ============================================================
   10. CARDS
   ============================================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background var(--ease-default), border-color var(--ease-default), box-shadow var(--ease-fast);
}

.card-hover:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   11. THREAD CARDS (Feed)
   ============================================================ */

.thread-feed {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.thread-card {
  background: var(--bg-surface);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: background var(--ease-fast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-decoration: none;
  color: inherit;
}

.thread-card:hover { background: var(--bg-hover); }
.thread-card:hover { color: inherit; }

.thread-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.thread-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.thread-title {
  font-family: var(--brand-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.01em;
  transition: color var(--ease-fast);
}

.thread-card:hover .thread-title { color: var(--accent); }

.thread-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread-card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-1);
}

.thread-meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.thread-meta svg {
  width: 13px;
  height: 13px;
}

.thread-pinned-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

/* ============================================================
   12. TAGS / PILLS
   ============================================================ */

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-2);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-xs);
  background: var(--bg-active);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--ease-fast), color var(--ease-fast);
  cursor: default;
  letter-spacing: 0.01em;
}

.tag-accent {
  background: var(--accent-dim);
  color: var(--accent);
}

.tag-clickable {
  cursor: pointer;
}

.tag-clickable:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tags-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* ============================================================
   13. AVATAR
   ============================================================ */

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  font-family: var(--brand-serif);
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.85rem;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs { width: 24px; height: 24px; font-size: 0.65rem; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.78rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.9rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; }
.avatar-xl { width: 68px; height: 68px; font-size: 1.4rem; }

/* ============================================================
   14. THREAD DETAIL VIEW
   ============================================================ */

.thread-detail {}

.thread-detail-header {
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-6);
}

.thread-detail-title {
  font-family: var(--brand-serif);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: var(--space-4);
}

.thread-detail-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.author-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.author-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.author-role {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.post-body {
  font-size: 0.975rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.post-body p { margin-bottom: var(--space-4); }
.post-body p:last-child { margin-bottom: 0; }

.post-body strong { font-weight: 600; }
.post-body em { font-style: italic; }

.post-body code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
}

.post-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  overflow-x: auto;
  margin: var(--space-4) 0;
}

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-4);
  color: var(--text-secondary);
  font-style: italic;
  margin: var(--space-4) 0;
}

/* ============================================================
   15. POST COMPOSER
   ============================================================ */

.composer {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}

.composer:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-input);
}

.composer-toolbar-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--brand-sans);
}

.composer-toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.composer-toolbar-btn svg {
  width: 14px;
  height: 14px;
}

.composer-toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 var(--space-1);
}

.composer-body {
  padding: var(--space-3) var(--space-4);
}

.composer-title-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-family: var(--brand-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  line-height: 1.4;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
}

.composer-title-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 300;
  font-style: italic;
}

.composer-content-input {
  width: 100%;
  min-height: 120px;
  background: none;
  border: none;
  outline: none;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
  resize: none;
}

.composer-content-input::placeholder { color: var(--text-tertiary); }

.composer-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-input);
}

.composer-footer-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

/* ============================================================
   16. IMAGE UPLOAD
   ============================================================ */

.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease-fast), background var(--ease-fast);
  background: var(--bg-input);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-zone-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-3);
  color: var(--text-tertiary);
}

.upload-zone p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.upload-zone small {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.upload-zone .link-text {
  color: var(--accent);
  font-weight: 500;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.image-preview-item {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--ease-fast);
  font-size: 12px;
  border: none;
}

.image-preview-item:hover .image-preview-remove { opacity: 1; }

/* In-post images */
.post-images {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.post-images.count-1 { grid-template-columns: 1fr; }
.post-images.count-2 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 .post-image:first-child { grid-column: span 2; }
.post-images.count-4 { grid-template-columns: 1fr 1fr; }

.post-image {
  width: 100%;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--ease-fast);
  max-height: 480px;
  object-fit: cover;
}

.post-image:hover { opacity: 0.92; }

/* ============================================================
   17. VIDEO EMBED
   ============================================================ */

.video-embed-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--space-4) 0;
}

.video-embed-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-url-input-wrap {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* ============================================================
   18. REPLIES / COMMENTS
   ============================================================ */

.replies-section {
  margin-top: var(--space-8);
}

.replies-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.replies-count {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-active);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.reply-list {
  display: flex;
  flex-direction: column;
}

.reply-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.reply-body { flex: 1; min-width: 0; }

.reply-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.reply-content {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.reply-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.reply-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  transition: background var(--ease-fast), color var(--ease-fast);
  font-family: var(--brand-sans);
}

.reply-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.reply-action-btn svg { width: 13px; height: 13px; }

.reply-action-btn.liked {
  color: var(--accent);
}

/* Reply composer */
.reply-composer {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.reply-input-wrap { flex: 1; }

.reply-input {
  width: 100%;
  min-height: 80px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
  resize: none;
  line-height: 1.6;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}

.reply-input::placeholder { color: var(--text-tertiary); }

.reply-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.reply-input-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ============================================================
   19. FEED HEADER / SORT CONTROLS
   ============================================================ */

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.feed-title {
  font-family: var(--brand-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

.sort-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-active);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.sort-tab {
  padding: 5px var(--space-3);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast);
  background: none;
  border: none;
  font-family: var(--brand-sans);
}

.sort-tab:hover { color: var(--text-primary); }

.sort-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ============================================================
   20. MODAL / OVERLAY
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fade-in var(--ease-fast) both;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-xl);
  animation: slide-up var(--ease-default) both;
  overflow: hidden;
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-family: var(--brand-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-input);
}

/* ============================================================
   21. AUTH FORMS
   ============================================================ */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  padding: var(--space-6);
}

.auth-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-md);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-logo-text {
  font-family: var(--brand-serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.auth-logo-text span { color: var(--accent); }

.auth-logo-sub {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.auth-title {
  font-family: var(--brand-serif);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.auth-subtitle {
  font-size: 0.88rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-6);
}

.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-2) 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.auth-divider span {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.auth-switch {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-top: var(--space-4);
}

.auth-switch a {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

/* ============================================================
   22. CATEGORY HEADER STRIP
   ============================================================ */

.category-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1) 0 var(--space-4);
  scrollbar-width: none;
}

.category-strip::-webkit-scrollbar { display: none; }

.category-pill {
  flex-shrink: 0;
  padding: 5px var(--space-3);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-active);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast), border-color var(--ease-fast);
  white-space: nowrap;
  font-family: var(--brand-sans);
}

.category-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.category-pill.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}

/* ============================================================
   23. EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state h3 {
  font-family: var(--brand-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 300px;
  margin: 0 auto var(--space-5);
}

/* ============================================================
   24. TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 500;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slide-in-right var(--ease-spring) both;
  max-width: 340px;
}

.toast-success { background: #166534; }
.toast-error   { background: #991B1B; }
.toast-warning { background: #92400E; }

/* ============================================================
   25. LIGHTBOX (image viewer)
   ============================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fade-in var(--ease-fast) both;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-size: 1.2rem;
  transition: background var(--ease-fast);
}

.lightbox-close:hover { background: rgba(255,255,255,0.22); }

/* ============================================================
   26. LOADING STATES
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-active) 25%,
    var(--bg-hover) 50%,
    var(--bg-active) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius-sm);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ============================================================
   27. THEME TOGGLE
   ============================================================ */

.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast), border-color var(--ease-fast);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* ============================================================
   28. DROPDOWN MENUS
   ============================================================ */

.dropdown-wrap { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  z-index: 150;
  animation: fade-in var(--ease-fast) both, slide-down var(--ease-fast) both;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-xs);
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--brand-sans);
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); color: var(--danger); }

.dropdown-item svg { width: 14px; height: 14px; opacity: 0.7; }

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-1);
}

/* ============================================================
   29. UTILITY CLASSES
   ============================================================ */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

/* ============================================================
   30. KEYFRAME ANIMATIONS
   ============================================================ */

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ============================================================
   31. RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-content {
    margin-left: 0;
  }

  .content-wrapper {
    padding: var(--space-5) var(--space-4);
  }
}

@media (max-width: 600px) {
  .thread-detail-title { font-size: 1.5rem; }
  .auth-box { padding: var(--space-8) var(--space-5); }
  .modal-body { padding: var(--space-4); }
  .modal-header { padding: var(--space-4); }
  .modal-footer { padding: var(--space-3) var(--space-4); }
}

/* ============================================================
   32. FOCUS VISIBLE
   ============================================================ */

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

/* ============================================================
   33. SELECTION
   ============================================================ */

::selection {
  background: var(--accent-dim);
  color: var(--text-primary);
}
