/* ─── Base & Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f8f8f6;
  --surface:   #ffffff;
  --border:    #e8e8e4;
  --border-2:  #d4d4ce;
  --text:      #1a1a18;
  --text-2:    #6b6b66;
  --text-3:    #9b9b96;
  --accent:    #1a1a18;
  --accent-fg: #ffffff;
  --danger:    #dc4a3d;
  --warn:      #e8a030;
  --green:     #2d7a4f;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 2px;
}

.logo-mark { color: var(--text); }
.logo-sep  { color: var(--text-3); margin: 0 1px; }
.logo-word { color: var(--text); }

.admin-badge {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--text);
  color: var(--accent-fg);
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 8px;
}

.header-tagline {
  font-size: 0.8rem;
  color: var(--text-3);
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Main Layout ──────────────────────────────────────────────────────────── */
.main-layout {
  padding-top: 32px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ─── Compose Card ─────────────────────────────────────────────────────────── */
.compose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

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

.char-counter {
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}

.char-counter.near-limit { color: var(--warn); }
.char-counter.at-limit   { color: var(--danger); }

.compose-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.6;
}

.compose-textarea:focus {
  border-color: var(--border-2);
  box-shadow: 0 0 0 3px rgba(26,26,24,.06);
}

.compose-textarea::placeholder { color: var(--text-3); }

.compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 12px;
}

.compose-note {
  font-size: 0.75rem;
  color: var(--text-3);
  flex: 1;
}

.btn-send {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-send:hover   { opacity: 0.85; }
.btn-send:active  { transform: scale(.97); }
.btn-send:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.submit-feedback {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
}

.submit-feedback.success { background: #e6f4ed; color: var(--green); }
.submit-feedback.error   { background: #fdecea; color: var(--danger); }
.hidden { display: none; }

/* ─── Feed ─────────────────────────────────────────────────────────────────── */
.feed-section {}

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

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

.feed-count {
  font-size: 0.78rem;
  color: var(--text-3);
}

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

.message-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
  animation: fadeInUp 0.3s ease both;
}

.message-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-md);
}

.message-text {
  font-size: 0.93rem;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.message-time {
  display: block;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ─── Date Separator ────────────────────────────────────────────────────────── */
.date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
}

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

.date-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  padding: 0 4px;
}

/* Slide-in for newly added card */
.message-card.new-card {
  border-color: var(--border-2);
  animation: slideInNew 0.4s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInNew {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Live Indicator Bar ───────────────────────────────────────────────────── */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0faf4;
  border: 1px solid #b8e6cc;
  border-radius: var(--radius);
  padding: 9px 14px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: #1e6e3e;
  font-weight: 500;
  animation: fadeInDown 0.25s ease;
}

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

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.live-load-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e6e3e;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  font-family: inherit;
}

.live-load-btn:hover { opacity: 0.75; }

/* ─── Empty State ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ─── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.page-btn:hover {
  background: var(--bg);
  border-color: var(--border-2);
  color: var(--text);
}

.page-btn--disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.page-num:hover {
  background: var(--bg);
  border-color: var(--border-2);
  color: var(--text);
}

.page-num--active {
  background: var(--text);
  color: var(--accent-fg);
  border-color: var(--text);
  cursor: default;
}

.page-ellipsis {
  font-size: 0.82rem;
  color: var(--text-3);
  padding: 0 4px;
  user-select: none;
}

.user-delete-container {
  display: inline-block;
  margin-right: 8px;
}

.btn-user-delete {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  font-family: inherit;
}

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

.btn-user-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Message Meta Row ─────────────────────────────────────────────────────── */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.reply-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  padding: 2px 4px;
  border-radius: 5px;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}

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

.reply-toggle-btn.is-open {
  color: var(--text-2);
}

/* ─── Reply Thread ─────────────────────────────────────────────────────────── */
.reply-thread {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  animation: fadeInUp 0.2s ease;
}

.reply-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.reply-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.reply-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-3);
}

.reply-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
  min-width: 0;
}

.reply-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.reply-time {
  display: block;
  font-size: 0.68rem;
  color: var(--text-3);
  margin-top: 4px;
}

.reply-loading {
  font-size: 0.8rem;
  color: var(--text-3);
  text-align: center;
  padding: 8px 0;
}

.reply-empty {
  font-size: 0.8rem;
  color: var(--text-3);
  text-align: center;
  padding: 4px 0;
}

/* ─── Reply Form ───────────────────────────────────────────────────────────── */
.reply-form {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.reply-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.5;
}

.reply-textarea:focus {
  border-color: var(--border-2);
  box-shadow: 0 0 0 3px rgba(26,26,24,.05);
}

.reply-textarea::placeholder { color: var(--text-3); }

.reply-form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
}

.reply-char-counter {
  font-size: 0.7rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.btn-reply-send {
  background: var(--text);
  color: var(--accent-fg);
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-reply-send:hover    { opacity: 0.82; }
.btn-reply-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* New reply card animation */
.reply-card.new-reply {
  animation: fadeInUp 0.25s ease both;
}

/* ─── Footer ───────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
}

.site-footer p {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ─── Admin Dashboard ──────────────────────────────────────────────────────── */
.admin-layout {
  padding-top: 28px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 860px;
}

.stats-bar {
  display: flex;
  gap: 12px;
}

.stat-item {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.tab-btn {
  flex: 1;
  text-align: center;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.tab-btn.active {
  background: var(--text);
  color: var(--accent-fg);
}

.tab-btn:not(.active):hover {
  background: var(--bg);
  color: var(--text);
}

.admin-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  transition: opacity 0.3s, transform 0.3s;
}

.admin-card.is-hidden {
  opacity: 0.5;
  border-style: dashed;
}

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

.admin-msg-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.admin-msg-time {
  display: block;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-3);
}

.admin-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.action-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.btn-toggle:hover {
  background: #fffbe6;
  border-color: #e8c030;
  color: #8a6000;
}

.btn-delete:hover {
  background: #fdecea;
  border-color: #dc4a3d;
  color: var(--danger);
}

/* ─── Buttons (Outline) ────────────────────────────────────────────────────── */
.btn-outline-sm {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-2);
  transition: background 0.15s, border-color 0.15s;
}

.btn-outline-sm:hover { background: var(--bg); border-color: var(--border-2); }

.btn-danger-outline { color: var(--danger); border-color: rgba(220,74,61,.3); }
.btn-danger-outline:hover { background: #fdecea; border-color: var(--danger); }

/* ─── Login Page ───────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 0.82rem;
  color: var(--text-3);
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--border-2);
  box-shadow: 0 0 0 3px rgba(26,26,24,.06);
}

.btn-login {
  width: 100%;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}

.btn-login:hover { opacity: 0.85; }

/* ─── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-danger  { background: #fdecea; color: var(--danger); }
.alert-success { background: #e6f4ed; color: var(--green); }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .admin-layout { max-width: 100%; }

  .stats-bar {
    gap: 8px;
  }

  .stat-item {
    padding: 10px 12px;
  }

  .stat-num { font-size: 1.2rem; }

  .admin-card {
    flex-direction: column;
    gap: 10px;
  }

  .admin-card-actions {
    align-self: flex-end;
  }

  .compose-footer {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }

  .compose-note { display: none; }

  .action-btn span { display: none; }
  .action-btn { padding: 7px 9px; }
}
