:root {
  --bg: #f6efe2;
  --paper: rgba(255, 252, 244, 0.86);
  --paper-strong: #fffaf0;
  --brown: #563426;
  --brown-dark: #3f251d;
  --muted: #877260;
  --gold: #bd8b2c;
  --gold-dark: #9a641f;
  --gold-soft: #e2c98e;
  --line: rgba(185, 139, 46, 0.26);
  --shadow: 0 22px 60px rgba(86, 52, 38, 0.12);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--brown);
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 249, 232, 0.95), transparent 32%),
    radial-gradient(circle at 82% 12%, rgba(224, 198, 137, 0.24), transparent 34%),
    linear-gradient(180deg, #fbf6ea 0%, #f3eadb 52%, #f9f1e2 100%);
  overflow-x: hidden;
}

a {
  color: inherit;
}

/* ================================
   Topbar
   ================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 82px;
  padding: 14px min(56px, 5vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: rgba(255, 250, 240, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  min-width: max-content;
}

.brand-mark {
  font-size: 32px;
  color: var(--gold);
  line-height: 1;
  filter: drop-shadow(0 8px 18px rgba(185, 139, 46, 0.18));
}

.brand strong {
  display: block;
  font-size: 23px;
  line-height: 1.12;
  color: var(--brown-dark);
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
}

.nav a {
  text-decoration: none;
}

.nav-pill {
  padding: 12px 18px;
  border-radius: 999px;
  color: #5d4537;
  font-weight: 700;
  white-space: nowrap;
}

.nav-pill span {
  color: var(--gold);
  margin-right: 6px;
}

.nav-pill.active {
  background: #fff7e8;
  box-shadow: 0 10px 26px rgba(86, 52, 38, 0.08);
}

.nav-cta {
  margin-left: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid rgba(185, 139, 46, 0.55);
  color: var(--brown);
  font-weight: 800;
  background: rgba(255, 248, 235, 0.72);
  white-space: nowrap;
}

/* ================================
   Main / decorative background
   ================================ */

main {
  width: min(1240px, calc(100vw - 48px));
  margin: 0 auto;
  position: relative;
}

.decor {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.decor-temple {
  display: block;
  left: 50%;
  top: 250px;
  width: 100vw;
  max-width: none;
  height: 360px;
  transform: translateX(-50%);
  opacity: 0.38;
  z-index: -2;
}

.decor-lotus-left,
.decor-lotus-right,
.decor-glow,
.decor-cloud,
.decor-corner,
.decor-sparkles {
  display: none !important;
}

/* ================================
   Hero
   ================================ */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 68px;
  align-items: center;
  padding: 74px 0 82px;
  min-height: calc(100vh - 82px);
  overflow: visible;
}

.hero::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 140px;
  width: 100vw;
  height: 620px;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse at center, rgba(255, 250, 238, 0.92) 0%, rgba(255, 250, 238, 0.64) 36%, transparent 72%),
    linear-gradient(180deg, rgba(255,255,255,0.22), rgba(246,239,226,0.88));
  z-index: -3;
  pointer-events: none;
}

.hero-left {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 5;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 17px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.72);
  color: var(--gold);
  font-weight: 800;
  margin-bottom: 18px;
}

h1,
.hero h1 {
  margin: 0 auto;
  max-width: 760px;
  color: var(--brown-dark);
  font-size: clamp(46px, 5vw, 76px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-align: center;
  text-shadow: 0 10px 34px rgba(86, 52, 38, 0.08);
}

.hero-subtitle {
  max-width: 700px;
  margin: 22px auto 18px;
  color: #806958;
  font-size: 19px;
  line-height: 1.75;
  text-align: center;
}

.divider,
.mini-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--gold);
}

.divider {
  margin: 20px auto 0;
}

.divider span,
.mini-divider span {
  height: 1px;
  width: 150px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.hero-actions {
  margin: 28px 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  position: relative;
  z-index: 8;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 13px 24px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 900;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, #7c472f, #b8872b);
  box-shadow: 0 16px 34px rgba(109, 70, 38, 0.22);
}

.secondary-btn {
  color: var(--brown);
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.78);
}

.spin-hint {
  margin: 28px 0 12px;
  color: #7c6958;
  font-weight: 800;
  text-align: center;
}

.wheel-note {
  margin: 18px auto 0;
  color: #84705e;
  text-align: center;
  font-size: 14px;
}

/* ================================
   Dhamma wheel
   ================================ */

.wheel-wrap {
  position: relative;
  width: min(420px, 72vw);
  height: min(420px, 72vw);
  margin: 16px auto 0;
  z-index: 5;
}

.wheel-shell {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  background:
    radial-gradient(circle, rgba(255, 252, 244, 0.98) 0 43%, rgba(255, 248, 232, 0.72) 44% 100%);
  border: 8px solid #604034;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.36),
    0 30px 60px rgba(86, 52, 38, 0.22);
}

.wheel-ring {
  position: absolute;
  inset: 34px;
  border-radius: inherit;
  border: 2px dashed var(--gold);
  opacity: 0.92;
}

.wheel-inner {
  position: absolute;
  inset: 78px;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255,255,255,0.34), transparent 68%);
}

#wheelRestoreSvg {
  animation: nookWheelSpin 28s linear infinite !important;
  transform-origin: center center !important;
  pointer-events: none !important;
  opacity: 0.95;
}

.wheel-wrap:hover #wheelRestoreSvg {
  animation-duration: 12s !important;
}

@keyframes nookWheelSpin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.spin-btn,
.wheel-center,
.ask-btn {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 94px !important;
  height: 94px !important;
  border-radius: 999px !important;
  border: 3px solid rgba(255, 235, 186, 0.95) !important;
  background: radial-gradient(circle at 35% 28%, #8a5236, #5b3327 72%) !important;
  color: white !important;
  font-weight: 900 !important;
  font-size: 18px !important;
  line-height: 1.22 !important;
  cursor: pointer !important;
  z-index: 30 !important;
  box-shadow: 0 12px 30px rgba(71, 40, 28, 0.28);
}

/* ================================
   Right guide card
   ================================ */

.hero-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 32px 28px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 252, 244, 0.92), rgba(255, 247, 230, 0.82));
  border: 1px solid rgba(185, 139, 46, 0.30);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  align-self: center;
  z-index: 6;
}

.quote-mark {
  color: var(--gold);
  font-size: 58px;
  line-height: 0.8;
  font-weight: 900;
}

blockquote {
  margin: 10px 0 12px;
  color: var(--brown);
  font-size: 18px;
  line-height: 1.7;
  text-align: center;
  font-weight: 700;
}

.quote-source {
  color: #806b59;
  text-align: center;
  margin: 0 0 26px;
}

.guide {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.guide h3 {
  text-align: center;
  margin: 0 0 16px;
  color: var(--brown-dark);
}

.guide-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid rgba(185, 139, 46, 0.16);
}

.guide-item span {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--gold);
  background: rgba(185, 139, 46, 0.10);
  font-size: 21px;
}

.guide-item p {
  margin: 0;
  line-height: 1.55;
  color: #6f594a;
}

/* ================================
   Recent questions
   ================================ */

.recent-section {
  width: min(1120px, 100%);
  margin: 24px auto 54px;
  padding: 28px;
  border-radius: var(--radius);
  background: rgba(255, 252, 244, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  position: relative;
  z-index: 5;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-head h2,
.section-title h2 {
  margin: 0;
  color: var(--brown-dark);
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.section-head a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 900;
  white-space: nowrap;
}

.recent-grid,
#recentLogList {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  padding: 0 10px 0 0;
  margin: 0;
  max-height: 390px;
  overflow-y: auto;
  overflow-x: hidden;
}

.recent-grid li,
#recentLogList li {
  list-style: none;
}

.force-question-btn,
.recent-question-btn {
  width: 100%;
  min-height: 66px;
  border: 1px solid rgba(185, 139, 46, 0.18);
  border-radius: 16px;
  padding: 17px 52px 17px 20px;
  text-align: left;
  font: inherit;
  color: var(--brown);
  background: rgba(255, 248, 235, 0.92);
  cursor: pointer;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.force-question-btn::after,
.recent-question-btn::after {
  content: "›";
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 26px;
}

.force-question-btn:hover,
.recent-question-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(86, 52, 38, 0.08);
  border-color: rgba(185, 139, 46, 0.45);
}

.force-question-btn.is-active {
  border-color: rgba(185, 139, 46, 0.85);
  background: #fff7e8;
  font-weight: 800;
}

.recent-loading,
.recent-log-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 22px;
  border-radius: 18px;
  background: rgba(255, 248, 235, 0.75);
}

/* ================================
   Answer reader
   ================================ */

#recentQuestionReaderForce,
.force-recent-reader {
  display: none;
}

#recentQuestionReaderForce.is-open,
.force-recent-reader.is-open {
  display: block;
  width: min(1120px, 100%);
  margin: -24px auto 54px;
  padding: 32px;
  border-radius: var(--radius);
  background: rgba(255, 252, 244, 0.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.force-recent-reader h3 {
  margin: 0 0 12px;
  color: var(--gold);
}

.force-reader-question {
  font-size: 24px;
  font-weight: 900;
  color: var(--brown-dark);
  margin-bottom: 26px;
}

.force-reader-answer {
  line-height: 1.85;
  color: #4c3328;
  font-size: 17px;
}

.force-reader-answer h1 {
  font-size: 34px;
  line-height: 1.25;
}

.force-reader-answer h2 {
  font-size: 26px;
}

.force-reader-answer h3 {
  font-size: 21px;
  color: var(--brown);
}

.force-reader-answer a {
  color: #9a6a1f;
  font-weight: 800;
  word-break: break-word;
}

.force-reader-chat-btn {
  display: inline-flex;
  margin-top: 24px;
  padding: 13px 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7d4830, #b98b2e);
  color: white;
  text-decoration: none;
  font-weight: 800;
}

/* ================================
   Features
   ================================ */

.features {
  width: min(1120px, 100%);
  margin: 50px auto 24px;
}

.section-title {
  text-align: center;
  margin-bottom: 26px;
}

.mini-divider {
  margin-top: 12px;
}

.mini-divider span {
  width: 92px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.feature-card {
  padding: 30px 22px;
  border-radius: 22px;
  background: rgba(255, 252, 244, 0.76);
  border: 1px solid var(--line);
  text-align: center;
  box-shadow: 0 16px 40px rgba(86, 52, 38, 0.08);
  backdrop-filter: blur(12px);
}

.feature-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 18px;
  color: var(--gold);
  background: rgba(185, 139, 46, 0.10);
  font-size: 34px;
}

.feature-card h3 {
  margin: 0 0 10px;
  color: var(--brown-dark);
}

.feature-card p {
  margin: 0;
  color: #745d4e;
  line-height: 1.65;
}

/* ================================
   Wisdom banner
   ================================ */

.wisdom-banner {
  width: min(1120px, 100%);
  margin: 26px auto 44px;
  padding: 30px;
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(184, 139, 46, 0.22), rgba(255, 250, 240, 0.82), rgba(184, 139, 46, 0.22));
  border: 1px solid rgba(185, 139, 46, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.lotus-glow {
  font-size: 48px;
  color: var(--gold);
  filter: drop-shadow(0 10px 22px rgba(185, 139, 46, 0.25));
}

.wisdom-banner p {
  max-width: 760px;
  margin: 0;
  color: var(--brown);
  font-size: 22px;
  line-height: 1.65;
}

/* ================================
   Footer
   ================================ */

.footer {
  background: linear-gradient(135deg, #3f251d, #6b402d);
  color: #fff2d4;
  padding: 42px min(64px, 5vw);
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 30px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
}

.footer-brand span {
  color: var(--gold-soft);
  font-size: 34px;
}

.footer h4 {
  margin: 0 0 12px;
  color: #ffe2a6;
}

.footer a,
.footer p {
  display: block;
  color: rgba(255, 242, 212, 0.78);
  text-decoration: none;
  margin: 8px 0;
}

/* ================================
   Responsive
   ================================ */

@media (max-width: 1100px) {
  main {
    width: min(100% - 32px, 980px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-cta {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 38px;
    padding: 54px 0 66px;
    min-height: auto;
  }

  .hero-left {
    max-width: 820px;
  }

  .hero-card {
    max-width: 520px;
  }

  .wheel-wrap {
    width: min(390px, 78vw);
    height: min(390px, 78vw);
  }

  .decor-temple {
    top: 310px;
    opacity: 0.26;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 24px, 980px);
  }

  .topbar {
    padding: 16px;
  }

  .brand strong {
    font-size: 20px;
  }

  .hero {
    padding: 36px 0 48px;
  }

  h1,
  .hero h1 {
    font-size: 40px;
    line-height: 1.14;
  }

  .hero-subtitle {
    font-size: 16px;
  }

  .divider span {
    width: 88px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn {
    width: min(280px, 100%);
    text-align: center;
  }

  .wheel-wrap {
    width: min(330px, 86vw);
    height: min(330px, 86vw);
  }

  .spin-btn,
  .wheel-center,
  .ask-btn {
    width: 82px !important;
    height: 82px !important;
    font-size: 16px !important;
  }

  .hero-card {
    padding: 26px 22px;
  }

  .decor-temple {
    display: none;
  }

  .recent-section {
    padding: 18px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .recent-grid,
  #recentLogList {
    grid-template-columns: 1fr;
  }

  #recentQuestionReaderForce.is-open,
  .force-recent-reader.is-open {
    padding: 22px;
  }

  .force-reader-answer h1 {
    font-size: 28px;
  }

  .feature-grid,
  .footer {
    grid-template-columns: 1fr;
  }

  .wisdom-banner {
    flex-direction: column;
  }

  .wisdom-banner p {
    font-size: 18px;
  }
}

/* =========================================================
   TRUE CENTER HERO FIX
   Center title + wheel on viewport, card floats right
   ========================================================= */

main {
  width: min(1240px, calc(100vw - 48px)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* ไม่ใช้ grid เพราะ grid ทำให้กงล้ออยู่กลางคอลัมน์ซ้าย ไม่ใช่กลางจอ */
.hero {
  display: block !important;
  position: relative !important;
  min-height: 880px !important;
  padding: 72px 0 90px !important;
  overflow: visible !important;
}

/* เนื้อหาหลักอยู่กลางจอจริง */
.hero-left {
  width: min(820px, 100%) !important;
  max-width: 820px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center !important;
  transform: none !important;
  position: relative !important;
  z-index: 5 !important;
}

/* หัวข้ออยู่กลาง */
.hero h1,
h1 {
  max-width: 760px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center !important;
  font-size: clamp(46px, 5vw, 76px) !important;
  line-height: 1.08 !important;
}

/* subtitle กลาง */
.hero-subtitle {
  max-width: 700px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center !important;
}

/* ปุ่มกลาง */
.hero-actions {
  justify-content: center !important;
}

/* กงล้อกลางจอจริง */
.wheel-wrap {
  position: relative !important;
  width: min(420px, 72vw) !important;
  height: min(420px, 72vw) !important;
  margin: 18px auto 0 !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
}

/* กล่องขวาลอย ไม่ดันกงล้อ */
.hero-card {
  position: absolute !important;
  top: 130px !important;
  right: 0 !important;
  left: auto !important;
  width: 360px !important;
  max-width: 360px !important;
  margin: 0 !important;
  z-index: 7 !important;
}

/* ถ้าจอไม่กว้างพอ ลดขนาดกล่องนิดนึง */
@media (max-width: 1280px) {
  .hero-card {
    width: 330px !important;
    max-width: 330px !important;
    right: 0 !important;
  }

  .hero-left {
    width: min(760px, 100%) !important;
  }

  .hero h1,
  h1 {
    max-width: 700px !important;
    font-size: clamp(44px, 5vw, 68px) !important;
  }
}

/* Tablet / mobile: card ลงล่าง */
@media (max-width: 1080px) {
  .hero {
    min-height: auto !important;
    padding: 54px 0 66px !important;
  }

  .hero-card {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: min(520px, 100%) !important;
    max-width: 520px !important;
    margin: 40px auto 0 !important;
  }

  .hero-left {
    width: min(820px, 100%) !important;
  }

  .wheel-wrap {
    width: min(390px, 78vw) !important;
    height: min(390px, 78vw) !important;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 36px 0 48px !important;
  }

  .hero h1,
  h1 {
    font-size: 40px !important;
  }

  .wheel-wrap {
    width: min(330px, 86vw) !important;
    height: min(330px, 86vw) !important;
  }

  .hero-card {
    padding: 26px 22px !important;
  }
}

/* =========================================================
   FINAL RIGHT CARD POSITION
   ดันกล่องขวาออกจากหัวข้อ / ไม่ทับกลางหน้า
   ========================================================= */

/* desktop กว้าง: หัวข้อ+กงล้อกลางจอ, card ลอยออกไปขวา */
@media (min-width: 1381px) {
  .hero {
    display: block !important;
    position: relative !important;
    min-height: 900px !important;
    padding-top: 78px !important;
  }

  .hero-left {
    width: min(820px, 100%) !important;
    max-width: 820px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
    transform: none !important;
  }

  .hero-card {
    position: absolute !important;
    top: 118px !important;
    right: -170px !important;
    left: auto !important;
    width: 340px !important;
    max-width: 340px !important;
    margin: 0 !important;
    z-index: 8 !important;
  }
}

/* จอกว้างกลาง: พื้นที่ไม่พอ ให้ card ลงล่าง ไม่ทับ */
@media (max-width: 1380px) {
  .hero {
    display: block !important;
    min-height: auto !important;
    padding-top: 58px !important;
    padding-bottom: 70px !important;
  }

  .hero-left {
    width: min(820px, 100%) !important;
    max-width: 820px !important;
    margin: 0 auto !important;
    transform: none !important;
    text-align: center !important;
  }

  .hero-card {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: min(520px, 100%) !important;
    max-width: 520px !important;
    margin: 42px auto 0 !important;
  }
}

/* ลดหัวข้อไม่ให้เลยไปชน card */
@media (min-width: 1381px) {
  .hero h1,
  h1 {
    max-width: 760px !important;
  }

  .hero-subtitle {
    max-width: 700px !important;
  }
}
