/* ═══════════════════════════════════════
   TOKENS (Warm Minimalism / Japandi Style)
   แก้ไขสีแบรนด์และขนาดฟอนต์เริ่มต้นที่นี่ได้ทันที
   ═══════════════════════════════════════ */
:root {
  --parchment: #FBF9F6;  
  --surface:   #FFFFFF;  
  --ink:       #2B2927;  
  --sage:      #8E8982;  
  --border:    #EFEAE4;  
  --saffron:   #CE7A53;  
  --gold:      #C2A169;  
  --plum:      #5F4E4C;
  --hl-bg:     rgba(206,122,83,0.12);
  --hl-text:   #A0522D;
  --fs:        22px; 
}
body.night {
  --parchment: #1A1208;
  --surface:   #231A0E;
  --ink:       #D4B483;
  --sage:      #7A6A50;
  --border:    rgba(212,180,131,0.12);
  --hl-bg:     rgba(206,122,83,0.18);
  --hl-text:   #E8A855;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

/* SCREENS LAYOUT */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* NAVIGATION */
.nav {
  background: var(--surface); padding: 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
}
.nav-logo { font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: 0.02em; }
.nav-sub  { font-size: 12px; color: var(--sage); margin-top: 2px; }
.nav-back { background: none; border: none; color: var(--ink); font-size: 22px; cursor: pointer; padding: 6px 10px; min-width: 44px; }
.icon-btn { background: var(--parchment); border: none; color: var(--ink); font-size: 18px; cursor: pointer; padding: 8px 12px; border-radius: 8px; min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }

/* TABS */
.tab-bar { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab-btn { flex: 1; padding: 14px 8px; text-align: center; font-size: 14px; font-weight: 600; color: var(--sage); cursor: pointer; font-family: 'Sarabun', sans-serif; border: none; background: transparent; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.18s; user-select: none; }
.tab-btn.active { color: var(--saffron); border-bottom-color: var(--saffron); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* BROWSE MODULE */
.search-hero { padding: 28px 18px 20px; text-align: center; }
.search-hero h2 { font-size: 22px; font-weight: 700; color: var(--ink); margin-top: 6px; }
.search-hero p  { font-size: 14px; color: var(--sage); margin-top: 6px; }
.search-wrap { margin: 0 16px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 14px; display: flex; align-items: center; gap: 10px; }
.search-input { flex: 1; border: none; outline: none; background: transparent; font-family: 'Sarabun', sans-serif; font-size: 16px; color: var(--ink); padding: 12px 0; }
.search-clear { font-size: 16px; color: var(--sage); cursor: pointer; display: none; padding: 4px; }
.quick-picks { padding: 12px 16px 4px; }
.section-label { font-size: 12px; font-weight: 700; color: var(--sage); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 8px 16px; border-radius: 20px; font-size: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--sage); cursor: pointer; font-family: 'Sarabun', sans-serif; font-weight: 500; min-height: 40px; display: flex; align-items: center; transition: all .15s; }
.chip.active { background: var(--saffron); color: #fff; border-color: var(--saffron); font-weight: 600; }

/* MANTRA CARDS */
.mantra-list { flex: 1; padding: 12px 16px 200px; display: flex; flex-direction: column; gap: 12px; }
.mantra-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; cursor: pointer; transition: all .18s; box-shadow: 0 1px 3px rgba(0,0,0,.02); user-select: none; }
.mantra-card.selected { border-color: var(--saffron); background: rgba(206,122,83,0.03); }
.card-row { display: flex; align-items: flex-start; gap: 14px; }
.checkbox { width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0; border: 1px solid var(--sage); margin-top: 2px; display: flex; align-items: center; justify-content: center; transition: all .15s; background: var(--surface); }
.mantra-card.selected .checkbox { background: var(--saffron); border-color: var(--saffron); }
.checkmark { font-size: 13px; color: #fff; display: none; font-weight: 700; }
.mantra-card.selected .checkmark { display: block; }
.card-right { flex: 1; min-width: 0; }
.card-top   { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-name  { font-size: 17px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.card-deity { font-size: 13px; color: var(--sage); margin-top: 2px; }
.card-tags  { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); color: var(--sage); background: var(--parchment); font-weight: 500; }
.fav-star { font-size: 22px; color: var(--sage); cursor: pointer; padding: 2px; min-width: 32px; display: flex; justify-content: center; transition: all .15s; }
.fav-star.on { color: var(--gold); transform: scale(1.1); }

/* SELECTED TRAY */
.selected-tray { position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.04); transition: transform .3s ease; }
.selected-tray.hidden { transform: translateY(100%); }
.tray-pills { display: flex; gap: 8px; padding: 12px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.tray-pills::-webkit-scrollbar { display: none; }
.tray-pill { flex-shrink: 0; background: var(--parchment); border: 1px solid var(--border); border-radius: 16px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.tray-pill-x { font-size: 14px; cursor: pointer; color: var(--sage); }
.tray-btn { margin: 8px 16px 16px; width: calc(100% - 32px); padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 700; border: none; cursor: pointer; font-family: 'Sarabun', sans-serif; background: var(--saffron); color: #fff; box-shadow: 0 4px 12px rgba(206,122,83,0.2); }

/* SETUP MODULE */
.setup-body { flex: 1; overflow-y: auto; padding: 16px 16px 140px; }
.setup-section { margin-bottom: 24px; }
.setup-sec-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--sage); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.msc { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.msc-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.msc-order { width: 28px; height: 28px; border-radius: 50%; background: var(--parchment); border: 1px solid var(--border); color: var(--ink); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msc-info { flex: 1; min-width: 0; }
.msc-name  { font-size: 16px; font-weight: 700; color: var(--ink); }
.msc-deity { font-size: 13px; color: var(--sage); margin-top: 2px; }
.order-btns { display: flex; flex-direction: column; gap: 4px; }
.order-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--parchment); color: var(--ink); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.order-btn:disabled { opacity: .3; cursor: default; }
.mini-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 8px; }
.mr-btn { height: 46px; border-radius: 8px; text-align: center; border: 1px solid var(--border); background: var(--parchment); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mr-btn.active { border-color: var(--saffron); color: var(--saffron); background: rgba(206,122,83,0.05); font-weight: 700; }
.mr-custom { display: none; margin-top: 8px; width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--gold); background: var(--surface); color: var(--ink); font-size: 16px; text-align: center; outline: none; }

.setup-font-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 10px; }
.setup-font-btn { background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 14px 6px 12px; cursor: pointer; user-select: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; min-height: 80px; transition: all .18s; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.setup-font-btn.active { border-color: var(--saffron); background: #FFF8F0; box-shadow: 0 2px 12px rgba(226,136,69,0.18); }
.setup-speed-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.setup-speed-range { flex: 1; -webkit-appearance: none; appearance: none; height: 8px; border-radius: 4px; background: var(--border); outline: none; cursor: pointer; }
.setup-speed-range::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; border-radius: 50%; background: var(--saffron); cursor: pointer; box-shadow: 0 2px 8px rgba(226,136,69,0.4); }
.setup-speed-range::-moz-range-thumb { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--saffron); cursor: pointer; }
.setup-speed-val { font-size: 17px; font-weight: 700; color: var(--saffron); width: 52px; text-align: right; flex-shrink: 0; }
.font-preview-box { background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-top: 12px; line-height: 1.9; color: var(--ink); min-height: 60px; display: flex; align-items: center; transition: font-size 0.2s; }
.speed-preview-box { margin-top: 10px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 18px 12px; display: flex; flex-direction: column; gap: 10px; }
.speed-preview-text { font-size: 19px; font-family: 'Sarabun', sans-serif; color: var(--ink); line-height: 2; }
.spw { display: inline; border-radius: 4px; padding: 1px 3px; margin: 1px; transition: background 0.15s, color 0.15s; }
.spw.active { background: var(--hl-bg); color: var(--hl-text); font-weight: 600; }
.speed-preview-hint { font-size: 13px; color: var(--sage); }

.print-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 10px; font-size: 14px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; margin-top: 16px; }
.setup-bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; background: var(--surface); border-top: 1px solid var(--border); padding: 16px; display: flex; gap: 12px; }

/* PRAY MODULE */
.pray-nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.round-badge { background: rgba(206,122,83,0.08); border: 1px solid var(--saffron); border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--saffron); }
.pray-act-btn { padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--ink); }
.pray-body { flex: 1; overflow-y: auto; padding: 24px 20px 200px; background: var(--parchment); }
.round-divider { text-align: center; margin: 32px 0 20px; position: relative; }
.round-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.round-divider span { position: relative; background: var(--parchment); padding: 0 16px; font-size: 13px; font-weight: 700; color: var(--sage); }
.mantra-text-block { line-height: 2.2; color: var(--ink); margin-bottom: 24px; text-align: center; }
.word { display: inline; border-radius: 4px; padding: 2px 4px; margin: 1px; transition: all .2s; }
.word.active { background: var(--hl-bg); color: var(--hl-text); font-weight: 600; }

.pray-footer-fixed { position: fixed; bottom: 0; left: 0; right: 0; z-index: 200; background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 12px 16px 24px; }
.tp-side { flex: 1.2; min-height: 54px; border-radius: 10px; border: 1px solid var(--border); background: var(--parchment); color: var(--ink); font-size: 16px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tp-label { font-size: 10px; color: var(--sage); }
.tp-skip { flex: 0.9; min-height: 54px; border-radius: 10px; border: 1px solid var(--border); background: var(--parchment); color: var(--sage); font-size: 14px; font-weight: 600; cursor: pointer; }
.tp-center { flex: 1.5; min-height: 54px; border-radius: 10px; border: 2px solid var(--saffron); background: rgba(206,122,83,0.05); color: var(--saffron); font-size: 24px; cursor: pointer; }

/* COMPLETE & COLLECTIONS */
.complete-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; }
.complete-lotus { font-size: 64px; margin-bottom: 16px; }
.complete-title { font-size: 28px; font-weight: 700; color: var(--saffron); }
.complete-sub { font-size: 16px; color: var(--sage); margin-top: 12px; line-height: 1.8; }
.collections-list { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.coll-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: pointer; }
.coll-header { display: flex; align-items: center; gap: 14px; padding: 16px; }
.coll-icon { width: 48px; height: 48px; border-radius: 10px; background: var(--parchment); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.coll-info { flex: 1; min-width: 0; }
.coll-name { font-size: 17px; font-weight: 700; color: var(--ink); }
.coll-desc { font-size: 13px; color: var(--sage); margin-top: 4px; line-height: 1.4; }
.coll-start-btn { display: block; width: 100%; padding: 14px; background: var(--saffron); color: #fff; font-size: 15px; font-weight: 700; border: none; cursor: pointer; }

/* RESPONSIVE TABLET */
@media (min-width: 600px) {
  .screen { max-width: 640px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  body { background: #F4F0EA; }
  .selected-tray, .setup-bottom, .pray-footer-fixed { max-width: 640px; left: 50%; transform: translateX(-50%); }
}

/* PRINT PREVIEW */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff !important; color: #1A0F00 !important; font-family: 'Sarabun', sans-serif; }
  .screen, .selected-tray, .setup-bottom, .pray-footer-fixed, .nav, .pray-nav { display: none !important; }
  #print-area { display: block !important; padding: 18mm 20mm; max-width: 100%; }
  .print-header { text-align: center; border-bottom: 2px solid #C2A169; padding-bottom: 10px; margin-bottom: 16px; }
  .print-header h1 { font-size: 20pt; color: #5F4E4C; font-weight: 700; }
  .print-header p  { font-size: 10pt; color: #8E8982; margin-top: 4px; }
  .print-mantra-block { margin-bottom: 20px; page-break-inside: avoid; }
  .print-mantra-title { font-size: 13pt; font-weight: 700; color: #5F4E4C; border-left: 4px solid #CE7A53; padding-left: 10px; margin-bottom: 8px; }
  .print-mantra-meta { font-size: 9pt; color: #8E8982; margin-bottom: 8px; padding-left: 14px; }
  .print-mantra-text { font-size: 13pt; line-height: 2.2; color: #1A0F00; padding-left: 14px; white-space: pre-wrap; }
  .print-divider { border: none; border-top: 1px solid #ddd; margin: 14px 0; }
  .print-footer { text-align: center; font-size: 8pt; color: #aaa; margin-top: 20px; }
}
/* ── FAVORITES ── */
#fav-section { padding: 12px 16px 4px; }
.fav-chip { border-color: var(--gold); color: var(--gold); }
.fav-chip:hover { background: rgba(194,161,105,0.08); }

/* Tray pill with remove X */
.tray-pill { display: flex; align-items: center; gap: 6px; background: rgba(206,122,83,0.1); border: 1px solid rgba(206,122,83,0.3); border-radius: 20px; padding: 5px 10px 5px 12px; font-size: 13px; white-space: nowrap; color: var(--ink); }
.tray-pill-x { cursor: pointer; color: var(--sage); font-size: 12px; padding: 0 2px; line-height: 1; }
.tray-pill-x:hover { color: var(--saffron); }

/* Collection fav button */
.coll-fav-btn { transition: all .15s; }
.coll-fav-btn.on { color: var(--gold) !important; }
.coll-fav-btn:active { background: rgba(194,161,105,0.12) !important; }

/* Pause state on tp-center */
.tp-center.paused { color: var(--saffron) !important; border-color: var(--saffron) !important; background: rgba(206,122,83,0.08) !important; }

/* Complete screen actions */
.complete-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 24px; }
.btn-primary { width: 100%; padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 700; border: none; cursor: pointer; font-family: 'Sarabun', sans-serif; background: var(--saffron); color: #fff; }
.btn-secondary { width: 100%; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 600; border: 1px solid var(--border); cursor: pointer; font-family: 'Sarabun', sans-serif; background: transparent; color: var(--ink); }
