:root {
  --forest: #0f4c35;
  --forest-dark: #0a3625;
  --forest-soft: #e6f4ea;
  --leaf: #1e7e4f;
  --amber: #d97706;
  --bg: #f4f7f2;
  --card: #ffffff;
  --ink: #1a2420;
  --muted: #5a6b63;
  --border: #dde6df;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 76, 53, 0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.hidden { display: none !important; }

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 10px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-logo {
  font-size: 28px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--forest-soft);
  border-radius: 12px;
}
.brand-text strong {
  display: block;
  font-size: 18px;
  line-height: 1.15;
  color: var(--forest);
}
.brand-text .accent { color: var(--amber); }
.brand-text small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.nav-search {
  flex: 1;
  min-width: 220px;
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.nav-search input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.nav-search button {
  border: 0;
  background: transparent;
  padding: 0 14px;
  cursor: pointer;
  font-size: 16px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary {
  background: var(--forest);
  color: #fff;
}
.btn-primary:hover { background: var(--forest-dark); }
.btn-outline {
  background: #fff;
  color: var(--forest);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--forest-soft); border-color: var(--forest); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-block { width: 100%; }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}
.lang-switch button {
  border: 0;
  background: transparent;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}
.lang-switch button.active {
  background: var(--forest);
  color: #fff;
}

.auth-area { display: flex; align-items: center; gap: 6px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--forest-soft);
  color: var(--forest-dark);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #0d4731 0%, #166534 60%, #1d7a46 100%);
  color: #fff;
  padding: 28px 0;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 24px;
  align-items: center;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.16);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  margin-bottom: 10px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 27px;
  line-height: 1.3;
  font-weight: 800;
}
.hero p {
  margin: 0 0 14px;
  color: rgba(255,255,255,0.9);
  font-size: 15px;
}
.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}
.quick-label {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}
.pill {
  background: rgba(255,255,255,0.16);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.28);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.pill:hover { background: rgba(255,255,255,0.3); }

.stats-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-box {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.stat-box.highlight {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.4);
}
.stat-box strong {
  display: block;
  font-size: 23px;
  font-weight: 800;
  line-height: 1.15;
}
.stat-box span {
  font-size: 12.5px;
  color: rgba(255,255,255,0.88);
}

/* Section Switcher Bar (Forum vs Market) */
.section-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(15, 76, 53, 0.04);
}
.section-bar-inner {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.section-tab:hover { border-color: var(--forest); background: var(--forest-soft); }
.section-tab.active {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}
.tab-new-badge {
  background: var(--amber);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}
.badge-price {
  background: #fef3c7;
  color: #92400e;
  font-weight: 800;
}
.badge-sell { background: #dcfce7; color: #166534; }
.badge-buy { background: #e0e7ff; color: #3730a3; }
.badge-exchange { background: #fce7f3; color: #9d174d; }
.badge-free { background: #ccfbf1; color: #115e59; }
.market-info-box {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 14px;
}
.btn-line {
  background: #06c755;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13.5px;
}
.btn-line:hover { background: #05a847; }
.badge-verified {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.market-promo-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ecfdf5 0%, #fefce8 100%);
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.market-promo-banner strong { color: var(--forest-dark); font-size: 15px; display: block; margin-bottom: 3px; }
.market-promo-banner p { margin: 0; font-size: 13px; color: var(--muted); }
.market-disclaimer {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.legal-check {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--muted) !important;
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
}
.legal-check input[type="checkbox"] {
  width: auto;
  margin-top: 3px;
  flex-shrink: 0;
}

/* Main Forum Layout */
.forum-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 20px;
  padding-top: 22px;
  padding-bottom: 48px;
}

.sidebar { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--forest);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cat-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 9px 11px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s;
}
.cat-btn:hover { background: var(--bg); }
.cat-btn.active {
  background: var(--forest-soft);
  color: var(--forest-dark);
  font-weight: 700;
}

.select-input, input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(15, 76, 53, 0.25);
  border-color: var(--forest);
}

.community-guide ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
}
.community-guide li { margin-bottom: 6px; }

/* Feed Column */
.feed-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.feed-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}
.feed-heading h2 { margin: 0; font-size: 19px; color: var(--forest-dark); }
.badge-count {
  background: var(--forest-soft);
  color: var(--forest);
  font-weight: 700;
  font-size: 12.5px;
  padding: 2px 9px;
  border-radius: 999px;
}

.sort-tabs {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.sort-tabs button {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.sort-tabs button.active {
  background: var(--forest);
  color: #fff;
}

.active-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 8px 12px;
  border-radius: 10px;
}

/* Thread Cards (Pantip Style) */
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.thread-card {
  display: grid;
  grid-template-columns: 1fr 165px;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}
.thread-card.no-img { grid-template-columns: 1fr; }
.thread-card:hover {
  transform: translateY(-1px);
  border-color: var(--leaf);
}
.thread-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-cat { background: var(--forest-soft); color: var(--forest-dark); }
.badge-dist { background: #eff6ff; color: #1d4ed8; }
.badge-pin { background: #fef3c7; color: #b45309; }
.badge-op { background: #dcfce7; color: #166534; }
.badge-guest { background: #f3f4f6; color: #4b5563; }

.thread-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}
.thread-excerpt {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.thread-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.thread-author { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.thread-stats { display: flex; align-items: center; gap: 12px; font-weight: 600; }

.thread-thumb {
  width: 165px;
  height: 122px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
}
.thumb-wrap {
  position: relative;
  width: 165px;
  height: 122px;
}
.thumb-wrap .thread-thumb { width: 100%; height: 100%; }
.video-pill {
  position: absolute;
  bottom: 7px;
  right: 7px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.video-embed-short {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 9 / 16;
  margin: 14px auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: var(--shadow);
}
.video-embed-wide {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 14px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.video-embed-short iframe,
.video-embed-wide iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 30, 20, 0.58);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
.modal-lg { max-width: 820px; }
.modal-sm { max-width: 440px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafcf9;
}
.modal-header h3 { margin: 0; font-size: 17px; color: var(--forest-dark); }
.modal-kicker { font-size: 13px; font-weight: 700; color: var(--forest); }
.icon-close {
  border: 0;
  background: var(--bg);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* Thread Detail Content */
.detail-title { margin: 0 0 10px; font-size: 22px; line-height: 1.35; color: var(--forest-dark); }
.detail-photo {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: 12px;
  margin: 14px 0;
  border: 1px solid var(--border);
}
.detail-body {
  white-space: pre-line;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--ink);
  margin-bottom: 16px;
}
.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.replies-header { font-size: 16px; margin: 0 0 12px; color: var(--forest-dark); }
.reply-card {
  background: #f9fbf8;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.reply-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.reply-num { font-weight: 700; color: var(--forest); }
.reply-body { white-space: pre-line; font-size: 14.5px; margin: 0 0 10px; }
.reply-photo { max-width: 100%; max-height: 300px; border-radius: 10px; margin-bottom: 10px; }
.reply-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}

.reply-form-box {
  margin-top: 18px;
  padding: 16px;
  background: var(--forest-soft);
  border-radius: 12px;
}
.reply-form-box h4 { margin: 0 0 10px; color: var(--forest-dark); }

/* Forms */
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--ink); }
.info-banner {
  background: var(--forest-soft);
  color: var(--forest-dark);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}
.photo-preview { max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 8px; object-fit: cover; }
.form-msg { font-size: 13.5px; font-weight: 600; min-height: 18px; }
.form-msg.err { color: #dc2626; }
.form-msg.ok { color: #15803d; }
.honeypot { position: absolute; left: -9999px; opacity: 0; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.auth-tabs button {
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}
.auth-tabs button.active { background: #fff; color: var(--forest); box-shadow: var(--shadow); }

/* Footer */
.footer {
  background: var(--forest-dark);
  color: rgba(255,255,255,0.88);
  padding: 24px 0;
  font-size: 13.5px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer p { margin: 4px 0 0; opacity: 0.85; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: #fff; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* Mobile */
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .forum-layout { grid-template-columns: 1fr; }
  .category-list { flex-direction: row; flex-wrap: wrap; }
  .cat-btn { width: auto; padding: 7px 11px; border: 1px solid var(--border); background: #fff; }
  .thread-card { grid-template-columns: 1fr; }
  .thread-thumb, .thumb-wrap { width: 100%; height: 200px; order: -1; }
  .form-row { grid-template-columns: 1fr; }
}
