/* ============================================
   SparK — Design System v7
   Dark + Light Theme
   ============================================ */

/* --- DARK THEME (default) --- */

:root,
/* --- DARK THEME (default) --- */

[data-theme="dark"] {
  --sky: #1e2a3a;
  --navy: #e2eaf4;
  --blue: #5ba3d9;
  --teal: #3ABCB1;
  --amber: #F5A623;
  --rose: #F26B6B;
  --green: #4CAF82;
  --soft: #1a1f26;
  --card: #222831;
  --border: #2e3744;
  --text: #dce6f0;
  --muted: #7a92aa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --font: 'Nunito', sans-serif;
  --font-serif: 'Lora', serif;
}

/* --- LIGHT THEME --- */
[data-theme="light"] {
  --sky: #e8f0f9;
  --navy: #1a2a3a;
  --blue: #2d7fc1;
  --teal: #1fa89e;
  --amber: #d4880d;
  --rose: #d94f4f;
  --green: #2e8a5e;
  --soft: #f0f4f8;
  --card: #ffffff;
  --border: #d0dce8;
  --text: #1a2535;
  --muted: #5a7590;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
}

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

body {
  background: var(--soft);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================
   NAV
   ============================================ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

.nav-logo:hover {
  text-decoration: none;
}

.nav-hex {
  width: 32px;
  height: 32px;
  background: var(--blue);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.nav-search {
  flex: 1;
  max-width: 320px;
  position: relative;
}

.nav-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

.nav-search-input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--soft);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.nav-search-input:focus {
  border-color: var(--blue);
  background: var(--card);
}

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

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--sky);
  color: var(--blue);
  text-decoration: none;
}

.nav-link.active {
  color: var(--blue);
  background: var(--sky);
}

.nav-bell {
  position: relative;
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.nav-bell:hover {
  background: var(--sky);
  text-decoration: none;
}

.nav-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--rose);
  color: white;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 50px;
  min-width: 17px;
  text-align: center;
  line-height: 1.3;
}

.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.nav-avatar:hover {
  opacity: 0.85;
  text-decoration: none;
}

/* --- Theme toggle button --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.78rem;
}

.theme-toggle:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}

/* --- Hamburger --- */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.hamburger:hover {
  background: var(--sky);
  color: var(--text);
}

/* --- Drawer overlay --- */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
}

.drawer-overlay.open {
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.drawer-close:hover {
  background: var(--sky);
  color: var(--text);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:hover {
  opacity: 0.88;
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
}

.btn-ghost:hover {
  border-color: var(--rose);
  color: var(--rose);
  background: rgba(242, 107, 107, 0.07);
}

.btn-danger {
  background: transparent;
  color: var(--rose);
  border: 1px solid var(--border);
}

.btn-danger:hover {
  border-color: var(--rose);
  background: rgba(242, 107, 107, 0.08);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
}

/* ============================================
   3-COLUMN APP LAYOUT
   ============================================ */

.app-layout {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 24px;
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  gap: 24px;
  align-items: start;
}

.layout {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px;
}

.main-content {
  width: 100%;
  min-width: 0;
}

/* ============================================
   LEFT SIDEBAR
   ============================================ */

.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 84px;
}

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  padding: 0 4px;
}

.sidebar-nav {
  list-style: none;
  margin-bottom: 4px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.15s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: var(--sky);
  color: var(--blue);
  text-decoration: none;
}

.sidebar-nav li a .icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.sidebar-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.topic-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--sky);
  color: var(--blue);
  text-decoration: none;
  transition: all 0.15s;
}

.topic-pill:hover,
.topic-pill.active {
  background: var(--blue);
  color: white;
  text-decoration: none;
}

/* ============================================
   RIGHT SIDEBAR / WIDGETS
   ============================================ */

.right-sidebar {
  position: sticky;
  top: 84px;
}

.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.widget-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.trending-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.trending-num {
  font-size: 1rem;
  font-weight: 700;
  color: var(--border);
  min-width: 18px;
  padding-top: 2px;
}

.trending-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 3px;
  display: block;
}

.trending-title:hover {
  color: var(--blue);
  text-decoration: none;
}

.trending-meta {
  font-size: 0.73rem;
  color: var(--muted);
  font-weight: 500;
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.flash {
  position: fixed;
  top: 5.0rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  min-width: 260px;
  text-align: center;
  box-shadow: var(--shadow);
}

.flash-error {
  background: rgba(242, 107, 107, 0.10);
  border-color: var(--rose);
  color: var(--rose);
}

.flash-success {
  background: rgba(76, 175, 130, 0.10);
  border-color: var(--green);
  color: var(--green);
}

/* ============================================
   FEED
   ============================================ */

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.feed-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.feed-desc {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.feed-tabs {
  display: flex;
  gap: 0;
  background: var(--border);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  width: fit-content;
}

.feed-tab {
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
  text-decoration: none;
  font-family: var(--font);
}

.feed-tab:hover {
  color: var(--text);
  text-decoration: none;
}

.feed-tab.active {
  background: var(--card);
  color: var(--blue);
  box-shadow: var(--shadow);
}

/* ============================================
   POST CARDS
   ============================================ */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  transition: all 0.15s;
  display: flex;
  gap: 16px;
}

.post-card:hover {
  border-color: rgba(55, 138, 221, 0.3);
  box-shadow: var(--shadow);
}

.post-card--unread {
  border-left: 3px solid var(--teal);
}

.vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 36px;
  padding-top: 2px;
}

.vote-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.1s;
  font-family: var(--font);
  font-weight: 600;
}

.vote-btn.up:hover {
  color: var(--blue);
  background: var(--sky);
}

.vote-btn.down:hover {
  color: var(--rose);
  background: rgba(242, 107, 107, 0.1);
}

.vote-btn.voted-up {
  color: var(--blue);
}

.vote-btn.voted-down {
  color: var(--rose);
}

.vote-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

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

.post-meta {
  display: flex;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.post-topic {
  background: var(--sky);
  color: var(--blue);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.72rem;
}

.post-author {
  color: var(--text);
  font-weight: 600;
}

.post-time {
  color: var(--muted);
  font-weight: 500;
}

.post-title {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
  letter-spacing: -0.1px;
}

.post-title:hover {
  color: var(--blue);
  text-decoration: none;
}

.post-preview {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
  line-height: 1.55;
  font-weight: 500;
}

.post-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
}

.reply-count {
  color: var(--muted);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.reply-count:hover {
  background: var(--sky);
  color: var(--blue);
  text-decoration: none;
}

/* ============================================
   FULL POST VIEW
   ============================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 20px;
}

.breadcrumb a {
  color: var(--blue);
  text-decoration: none;
}

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

.post-full {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  display: flex;
  gap: 20px;
}

.post-title-full {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.25;
  letter-spacing: -0.3px;
}

.post-body-full {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.75;
  white-space: pre-wrap;
  margin-bottom: 20px;
}

[data-theme="light"] .post-body-full {
  color: #3a5068;
}

.post-content {
  flex: 1;
  min-width: 0;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ============================================
   REPLIES
   ============================================ */

.replies-section {
  margin-top: 8px;
}

.replies-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.compose-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.reply-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply-form textarea,
.post-form textarea,
.post-form input,
.post-form select {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 14px;
  width: 100%;
  resize: vertical;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.reply-form textarea:focus,
.post-form textarea:focus,
.post-form input:focus,
.post-form select:focus {
  border-color: var(--blue);
  background: var(--card);
}

.reply-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
  display: flex;
  gap: 16px;
}

.reply-card:hover {
  border-color: rgba(55, 138, 221, 0.2);
}

.reply-body {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
  flex: 1;
  min-width: 0;
}

[data-theme="light"] .reply-body {
  color: #3a5068;
}

/* ============================================
   BBCODE PREVIEW TABS
   ============================================ */

.editor-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.editor-tab {
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font);
  transition: color 0.15s;
}

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

.editor-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.editor-pane {
  display: none;
}

.editor-pane.active {
  display: block;
}

.preview-pane {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-height: 120px;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

[data-theme="light"] .preview-pane {
  color: #3a5068;
}

.preview-pane:empty::before {
  content: 'Preview will appear here...';
  color: var(--border);
  font-style: italic;
}

/* ============================================
   CHARACTER COUNTER
   ============================================ */

.field-wrap {
  position: relative;
}

.char-counter {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
  transition: color 0.15s;
}

.char-counter.warn {
  color: var(--amber);
}

.char-counter.danger {
  color: var(--rose);
}

/* ============================================
   FORMS
   ============================================ */

.form-page {
  max-width: 640px;
}

.form-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.form-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 24px;
}

.post-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-form label {
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-top: 6px;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: -6px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.btn-submit {
  background: var(--blue);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-submit:hover {
  opacity: 0.88;
}

.btn-cancel {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  text-decoration: none;
  font-family: var(--font);
}

.btn-cancel:hover {
  color: var(--text);
  border-color: var(--muted);
  text-decoration: none;
}

/* ============================================
   AUTH
   ============================================ */

.auth-form {
  max-width: 400px;
  margin: 60px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.auth-form h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.auth-form .form-subtitle {
  margin-bottom: 24px;
}

.auth-form input {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.auth-form input:focus {
  border-color: var(--blue);
  background: var(--soft);
}

.auth-form select {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a92aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.auth-form select:focus {
  border-color: var(--blue);
  background-color: var(--soft);
}

.auth-form select option {
  background: var(--card);
  color: var(--text);
}

.auth-form .btn-submit {
  width: 100%;
  text-align: center;
  margin-top: 4px;
  justify-content: center;
}

.auth-form a {
  display: inline;
  text-align: center;
  margin-top: 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.auth-form a:hover {
  color: var(--blue);
}

/* ============================================
   PROFILE
   ============================================ */

.profile-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.profile-banner {
  height: 110px;
  background: var(--sky);
  border-bottom: 1px solid var(--border);
}

.profile-info {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  padding: 0 28px 24px;
  margin-top: -36px;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--blue);
  border: 4px solid var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.profile-details {
  flex: 1;
  padding-top: 40px;
}

.profile-username {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  margin-bottom: 2px;
}

.profile-bio {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.profile-meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 10px;
}

.profile-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.profile-stat {
  text-align: center;
}

.profile-stat-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.profile-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.profile-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 40px;
}

.profile-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.section-heading {
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ============================================
   FOLLOW BUTTONS
   ============================================ */

.btn-follow {
  padding: 7px 18px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  color: var(--blue);
  background: transparent;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-follow:hover {
  background: var(--blue);
  color: white;
}

.btn-unfollow {
  border-color: var(--border);
  color: var(--muted);
}

.btn-unfollow:hover {
  border-color: var(--rose);
  color: var(--rose);
  background: transparent;
}

.btn-bookmark {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
}

.btn-bookmark:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}

.btn-bookmark.bookmarked {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}

.btn-edit {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-family: var(--font);
  text-decoration: none;
}

.btn-edit:hover {
  color: var(--blue);
  border-color: var(--blue);
  text-decoration: none;
}

.btn-delete {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete:hover {
  border-color: var(--rose);
  color: var(--rose);
}

.btn-profile {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  text-decoration: none;
  font-family: var(--font);
}

.btn-profile:hover {
  color: var(--blue);
  border-color: var(--blue);
  text-decoration: none;
}

/* ============================================
   TOPICS
   ============================================ */

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.topic-card {
  display: block;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  text-decoration: none;
}

.topic-card:hover {
  border-color: rgba(55, 138, 221, 0.3);
  box-shadow: var(--shadow);
  text-decoration: none;
}

.topic-card-name {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.topic-card-desc {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 12px;
  line-height: 1.45;
}

.topic-card-count {
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ============================================
   PAGINATION
   ============================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px 0;
}

.page-btn {
  color: var(--blue);
  border: 1px solid var(--blue);
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
  font-family: var(--font);
}

.page-btn:hover {
  background: var(--blue);
  color: white;
  text-decoration: none;
}

.page-num {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ============================================
   SEARCH
   ============================================ */

.search-header {
  margin-bottom: 24px;
}

.search-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 14px;
  min-width: 200px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--blue);
}

.search-tabs {
  display: flex;
  gap: 4px;
}

.search-tab {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
  font-family: var(--font);
  text-decoration: none;
}

.search-tab:hover {
  color: var(--text);
  text-decoration: none;
}

.search-tab.active {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.notification-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  color: var(--muted);
  text-decoration: none;
}

.notification-item:hover {
  border-color: rgba(55, 138, 221, 0.2);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}

.notification-item.unread {
  border-left: 3px solid var(--blue);
  color: var(--text);
}

.notification-type {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 52px;
  padding-top: 2px;
}

.notification-body {
  flex: 1;
}

.notification-message {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.notification-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.follow-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.follow-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state-icon {
  margin: 0 auto 20px;
  opacity: 0.35;
}

.empty-state-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.55;
}

.empty-state a {
  display: inline-block;
  margin-top: 4px;
}

/* ============================================
   TOAST
   ============================================ */

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 999;
  max-width: 320px;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  width: 32px;
  height: 32px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.toast-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 2px;
  color: var(--text);
}

.toast-message {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

/* ============================================
   ERROR PAGES
   ============================================ */

.error-page {
  text-align: center;
  padding: 80px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.error-code {
  font-size: 5rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin-bottom: 16px;
  letter-spacing: -4px;
}

.error-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.error-message {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 200px 1fr;
  }

  .right-sidebar {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
    gap: 10px;
  }

  .nav-search {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  .theme-toggle .toggle-label {
    display: none;
  }

  .app-layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .sidebar {
    display: none;
  }

  .layout {
    padding: 20px 14px;
  }

  .post-card {
    padding: 14px;
  }

  .post-full {
    flex-direction: column;
    padding: 20px;
  }

  .auth-form {
    margin: 28px auto;
    padding: 24px 18px;
  }

  .profile-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-actions {
    padding-top: 0;
  }
}

/* ============================================
   TOPNAV
   ============================================ */

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.2s, color 0.2s;
  font-family: var(--font);
  gap: 16px;
}

.topnav .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}

.topnav .logo:hover {
  text-decoration: none;
}

.topnav .logo-hex {
  width: 34px;
  height: 34px;
  background: var(--blue);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.topnav .nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topnav .nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.15s;
  text-decoration: none;
}

.topnav .nav-link:hover {
  background: var(--sky);
  color: var(--blue);
  text-decoration: none;
}

.topnav .nav-link.active {
  color: var(--blue);
  background: var(--sky);
}

.topnav .nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topnav .search-bar {
  flex: 1;
  max-width: 320px;
  position: relative;
}

.topnav .search-bar input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--soft);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.topnav .search-bar input:focus {
  border-color: var(--blue);
  background: var(--card);
}

.topnav .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

.topnav .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.topnav .avatar:hover {
  opacity: 0.85;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 450px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal .field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal select,
.modal textarea,
.modal input[type="text"] {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--soft);
  color: var(--text);
  font-size: 0.95rem;
  width: 100%;
  appearance: none;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  cursor: pointer;
  font-size: 1.25rem;
}

/* ============================================
   BBCODE TOOLBAR
   ============================================ */

.bbcode-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  flex-wrap: wrap;
}

.bb-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 3px 7px;
  line-height: 1.4;
  transition: background 0.1s, border-color 0.1s;
}

.bb-btn:hover {
  background: var(--soft);
  border-color: var(--border);
}

.bb-btn:active {
  background: var(--border);
}

.bb-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.bbcode-toolbar+textarea,
.bbcode-toolbar+.field-wrap textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ============================================
   POST REACTIONS
   ============================================ */

.post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.post-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.post-reaction-total {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.reaction-strip {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}

.reaction-trigger {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
  opacity: 0.5;
}

.reaction-trigger:hover {
  transform: scale(1.2);
  opacity: 1;
}

.reaction-trigger-pill {
  font-size: 1rem;
  opacity: 0.5;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  transition: opacity 0.15s;
  user-select: none;
}

.reaction-strip.has-reaction .reaction-trigger {
  opacity: 1;
}

.reaction-trigger.open {
  font-size: 0;
  opacity: 1;
}

.reaction-trigger.open::before {
  content: '›';
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue);
}

.reaction-options {
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  padding-right: 0;
  transition: max-width 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
}

.reaction-options.open {
  max-width: 200px;
  opacity: 1;
  padding-right: 6px;
}

.reaction-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  line-height: 1;
  opacity: 0.5;
}

.reaction-btn:hover {
  transform: scale(1.25);
  opacity: 1;
}

.reaction-btn.active {
  opacity: 1;
  background: rgba(55, 138, 221, 0.12);
}

.reaction-strip.has-reaction .reaction-btn {
  opacity: 1;
}

.reaction-counts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 8px;
}

.reaction-count-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  user-select: none;
  transition: all 0.15s;
  cursor: pointer;
  font-family: var(--font);
  line-height: 1;
}

.reaction-count-pill:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}

.reaction-count-pill.active {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(55, 138, 221, 0.12);
}

.reaction-popover-wrap {
  position: relative;
}

.reaction-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

.reaction-popover.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.reaction-summary {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-wrap: wrap;
}

.reaction-summary:hover .reaction-trigger-pill {
  opacity: 1;
}

.reaction-flame-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
  line-height: 1;
}

.reaction-flame-btn:hover {
  opacity: 1;
  border-color: var(--blue);
}

.reaction-sole-btn {
  background: rgba(55, 138, 221, 0.12);
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 1;
  transition: all 0.15s;
  line-height: 1;
}

.reaction-sole-btn:hover {
  background: rgba(55, 138, 221, 0.2);
}

.reaction-add-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
  flex-shrink: 0;
}

.reaction-add-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--sky);
}

/* ============================================
   TOOLTIPS
   ============================================ */

.has-tooltip {
  position: relative;
}

.has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: var(--shadow);
}

.has-tooltip:hover::after {
  opacity: 1;
}

/* ============================================
   FEEDBACK WIDGET
   ============================================ */

.feedback-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1099;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.15s;
}

.feedback-trigger:hover {
  opacity: 0.88;
}

.feedback-trigger-icon {
  font-size: 1rem;
}

.feedback-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.feedback-overlay.open {
  display: block;
  opacity: 1;
}

.feedback-panel {
  position: fixed;
  bottom: 72px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 48px);
  max-height: 80vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  font-family: var(--font);
}

.feedback-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.fp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fp-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.fp-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.fp-close:hover {
  background: var(--sky);
  color: var(--text);
}

.fp-body {
  overflow-y: auto;
  max-height: calc(80vh - 56px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.fp-sub {
  font-size: 0.83rem;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
}

.fp-ratings {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.fp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.fp-row:last-child {
  border-bottom: none;
}

.fp-row:hover {
  background: var(--sky);
}

.fp-row-labels {
  flex: 1;
  min-width: 0;
}

.fp-row-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-row-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 1px;
  font-weight: 500;
}

.fp-stars {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.fp-star {
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: transform 0.1s;
}

.fp-star:hover {
  transform: scale(1.2);
}

.fp-star svg {
  width: 18px;
  height: 18px;
  display: block;
}

.fp-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.fp-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.fp-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 88px;
  resize: vertical;
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 10px 12px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s;
}

.fp-textarea:focus {
  outline: none;
  border-color: var(--teal);
}

.fp-textarea::placeholder {
  color: var(--muted);
}

.fp-error {
  font-size: 0.8rem;
  color: var(--rose);
  margin: -8px 0 0;
  display: none;
  font-weight: 600;
}

.fp-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 4px;
}

.fp-btn-cancel {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fp-btn-cancel:hover {
  background: var(--sky);
  border-color: var(--muted);
  color: var(--text);
}

.fp-btn-submit {
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}

.fp-btn-submit:hover {
  opacity: 0.88;
}

.fp-btn-submit:active {
  opacity: 0.75;
}

.fp-btn-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fp-success {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.fp-success-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(29, 158, 117, 0.15);
  color: var(--teal);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.fp-success-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.fp-success-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
}

@media (max-width: 480px) {
  .feedback-panel {
    width: 100%;
    border-left: none;
    border-right: none;
    border-radius: var(--radius) var(--radius) 0 0;
    bottom: 0;
    right: 0;
  }
}

.mention {
  color: var(--teal);
  font-weight: 700;
}

.mention:hover {
  text-decoration: underline;
}

.mention-preview {
  color: transparent;
  font-weight: 700;
  background: rgba(58, 188, 177, 0.12);
  border-radius: 4px;
  padding: 0 3px;
}

.mention-highlight-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

mark.mention-preview {
  background: transparent;
  color: transparent;
  font-weight: 700;

}

textarea.mention-active {
  background: transparent !important;
}

.classroom-wide .main-content {
  grid-column: span 2;
}

.block-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.block-badge-text {
  background: var(--soft);
  color: var(--muted);
  border: 1px solid var(--border);
}

.block-badge-multiple_choice {
  background: #dbeafe;
  color: #1e40af;
}

.block-badge-true_false {
  background: #dcfce7;
  color: #166534;
}

.block-badge-short_answer {
  background: #fef9c3;
  color: #854d0e;
}

.block-badge-file_upload {
  background: #f3e8ff;
  color: #6b21a8;
}

#blocks-list textarea,
#blocks-list input[type="text"],
#blocks-list input[type="number"] {
  color: var(--text);
  background: var(--soft);
  border: 1px solid var(--border);
}

.block-item {
  margin-bottom: 1.25rem;
}

.block-item-divider {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.msg-bubble-mine {
  max-width: 75%;
  background: var(--teal);
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 4px 16px 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble-theirs {
  max-width: 75%;
  background: var(--soft);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 4px 16px 16px 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}
.msg-mine {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-theirs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* ============================================
   SparK Messenger — Floating Chat Widget
   Append to style.css
   ============================================ */

/* --- Launcher bubble --- */
.msg-launcher {
  position: fixed;
  bottom: 28spx;
  right: 28px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}

/* push launcher up if feedback button present */
body:has(.feedback-trigger) .msg-launcher {
  bottom: 88px;
}

.msg-launcher-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), background 0.15s;
  pointer-events: all;
  position: relative;
  flex-shrink: 0;
}

.msg-launcher-btn:hover {
  transform: scale(1.08);
  background: var(--teal);
}

.msg-launcher-btn.open {
  background: var(--teal);
  transform: rotate(0deg);
}

.msg-launcher-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--rose);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--soft);
  line-height: 1;
}

/* --- Container for stacked panels --- */
.msg-stack {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 1199;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

body:has(.feedback-trigger) .msg-stack {
  bottom: 156px;
}

/* --- Base panel --- */
.msg-panel {
  width: 320px;
  max-height: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}

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

/* --- Inbox panel --- */
.msg-inbox-panel {
  width: 300px;
}

.msg-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--card);
}

.msg-panel-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.2px;
}

.msg-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.msg-icon-btn:hover {
  background: var(--sky);
  color: var(--blue);
}

/* --- Conversation list (inbox) --- */
.msg-conv-list {
  overflow-y: auto;
  flex: 1;
}

.msg-conv-list::-webkit-scrollbar { width: 4px; }
.msg-conv-list::-webkit-scrollbar-track { background: transparent; }
.msg-conv-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

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

.msg-conv-item:hover {
  background: var(--sky);
}

.msg-conv-item.unread {
  background: rgba(91, 163, 217, 0.07);
}
.msg-conv-item.active {
  background: var(--sky);
}
.msg-conv-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
  font-family: var(--font);
}

.msg-conv-info {
  flex: 1;
  min-width: 0;
}

.msg-conv-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.msg-conv-preview {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.msg-conv-time {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}

.msg-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}

/* --- Chat conversation panel --- */
.msg-chat-panel {
  width: 300px;
}

.msg-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
}

.msg-chat-header:hover .msg-chat-name {
  color: var(--blue);
}

.msg-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
  font-family: var(--font);
}

.msg-chat-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}

.msg-chat-classroom {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

/* --- Message body --- */
.msg-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.msg-chat-body::-webkit-scrollbar { width: 4px; }
.msg-chat-body::-webkit-scrollbar-track { background: transparent; }
.msg-chat-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-bubble-wrap.mine { align-items: flex-end; }
.msg-bubble-wrap.theirs { align-items: flex-start; }

.msg-sender-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 4px;
}

.msg-bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
  font-family: var(--font);
}

.msg-bubble.mine {
  background: var(--blue);
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}

.msg-bubble.theirs {
  background: var(--sky);
  color: var(--text);
  border-radius: 4px 16px 16px 16px;
  border: 1px solid var(--border);
}

.msg-bubble-time {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 500;
  padding: 0 4px;
}

/* date separators */
.msg-date-sep {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
  letter-spacing: 0.5px;
}

/* loading / empty */
.msg-chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.msg-typing-dot {
  display: inline-flex;
  gap: 3px;
  padding: 8px 12px;
}

.msg-typing-dot span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: msgBounce 1.2s ease-in-out infinite;
}

.msg-typing-dot span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing-dot span:nth-child(3) { animation-delay: 0.3s; }

@keyframes msgBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* --- Compose area --- */
.msg-compose {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--card);
}

.msg-compose-input {
  flex: 1;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 7px 13px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 96px;
  overflow-y: auto;
  transition: border-color 0.15s, background 0.15s;
  scrollbar-width: none;
}

.msg-compose-input::-webkit-scrollbar { display: none; }

.msg-compose-input:focus {
  border-color: var(--blue);
  background: var(--card);
}

.msg-compose-input::placeholder { color: var(--muted); }

.msg-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

.msg-send-btn:hover { background: var(--teal); transform: scale(1.07); }
.msg-send-btn:disabled { background: var(--border); cursor: default; transform: none; }

/* --- Empty inbox --- */
.msg-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
  gap: 8px;
}

.msg-empty-icon { font-size: 2rem; opacity: 0.5; }
.msg-empty-text { font-size: 0.82rem; font-weight: 600; }

/* --- Mobile --- */
@media (max-width: 640px) {
  .msg-stack {
    right: 12px;
    bottom: 80px;
  }

  body:has(.feedback-trigger) .msg-stack {
    bottom: 140px;
  }

  .msg-launcher {
    right: 12px;
    bottom: 16px;
  }

  body:has(.feedback-trigger) .msg-launcher {
    bottom: 76px;
  }

  .msg-panel,
  .msg-inbox-panel,
  .msg-chat-panel {
    width: calc(100vw - 24px);
    max-height: 60vh;
  }

  .msg-stack {
    flex-direction: column;
    align-items: flex-end;
    right: 12px;
  }
}
.create-menu-item {
  display: block;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}
.create-menu-item:hover {
  background: var(--sky);
  color: var(--blue);
}