/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1f14;
  --bg2: #122019;
  --bg3: #1a2e20;
  --bg4: #1f3526;
  --gold: #c8952a;
  --gold2: #e8b84b;
  --gold-light: rgba(200,149,42,0.15);
  --cream: #f0e8d5;
  --cream2: #d4c9b0;
  --cream3: rgba(240,232,213,0.6);
  --green: #4a9e5c;
  --green2: #2d7a40;
  --green-light: rgba(74,158,92,0.15);
  --red: #c0392b;
  --red-light: rgba(192,57,43,0.15);
  --border: rgba(200,149,42,0.2);
  --border2: rgba(200,149,42,0.4);
  --shadow: 0 8px 40px rgba(0,0,0,0.5);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Heebo', Arial, sans-serif;
  --font-serif: 'Playfair Display', serif;
  --sidebar-w: 240px;
  --transition: 0.25s cubic-bezier(.4,0,.2,1);
}

html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--cream);
  min-height: 100vh;
  direction: rtl;
  display: flex;
  overflow-x: hidden;
}

/* ===== BG PARTICLES ===== */
.bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}
.bg-canvas::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(74,158,92,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 10% 80%, rgba(200,149,42,0.06) 0%, transparent 60%);
}
.leaf {
  position: absolute;
  width: 6px; height: 6px;
  background: rgba(74,158,92,0.3);
  border-radius: 50% 0 50% 0;
  animation: floatLeaf linear infinite;
  opacity: 0;
}
@keyframes floatLeaf {
  0%   { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  right: 0; top: 0; bottom: 0;
  z-index: 10;
  gap: 2rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.5rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-logo-img {
  width: 100%;
  max-width: 200px;
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
  background: #fff;
  padding: 8px;
}
body.light .brand-logo-img { background: transparent; padding: 0; }
.logo-leaf {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(74,158,92,0.5));
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(74,158,92,0.4)); }
  50%       { filter: drop-shadow(0 0 14px rgba(74,158,92,0.8)); }
}
.logo-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--gold2);
  line-height: 1.2;
}
.logo-sub {
  font-size: 11px;
  color: var(--cream3);
  font-weight: 300;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--cream3);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  text-align: right;
  transition: var(--transition);
  width: 100%;
  position: relative;
  overflow: hidden;
}
.nav-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gold-light);
  opacity: 0;
  transition: var(--transition);
  border-radius: var(--radius-sm);
}
.nav-btn:hover { color: var(--cream); border-color: var(--border); }
.nav-btn:hover::before { opacity: 1; }
.nav-btn.active {
  background: var(--gold-light);
  border-color: var(--border2);
  color: var(--gold2);
  font-weight: 600;
}
.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer { margin-top: auto; }

.lang-toggle {
  width: 100%;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  border-radius: 10px;
  border: 1.5px solid rgba(45,122,64,0.25);
  background: #f0f8f3;
  color: #15803d;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.lang-toggle:hover { background: #16a34a; color: #fff; border-color: #16a34a; }
.lang-globe { font-size: 15px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--gold2); line-height: 1; }
.stat-lbl { font-size: 11px; color: var(--cream3); margin-top: 4px; }

/* ===== MAIN ===== */
.main {
  margin-right: var(--sidebar-w);
  flex: 1;
  padding: 2.5rem 2rem;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.tab-section { display: none; }
.tab-section.active {
  display: block;
  animation: fadeUp 0.4s cubic-bezier(.4,0,.2,1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header { margin-bottom: 2rem; }
.section-title {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 700;
  color: var(--cream);
  line-height: 1.2;
  margin-bottom: 6px;
}
.section-title em {
  font-style: italic;
  color: var(--gold2);
}
.section-desc { font-size: 14px; color: var(--cream3); font-weight: 300; }

/* ===== BOTANICAL GALLERY ===== */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gallery-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1), box-shadow 0.28s, border-color 0.2s;
  animation: cardIn 0.4s cubic-bezier(.4,0,.2,1) both;
  position: relative;
}
.gallery-card:hover {
  transform: translateY(-5px);
  border-color: var(--border2);
  box-shadow: 0 16px 50px rgba(0,0,0,0.35);
}
.gallery-card.expanded { border-color: var(--gold); }
body.light .gallery-card.expanded { border-color: #2d7a40; }

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* illustration zone */
.gallery-illus {
  width: 100%; height: 165px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.gallery-illus.fi {
  background: radial-gradient(ellipse at 60% 40%, rgba(200,149,42,0.12) 0%, rgba(74,158,92,0.06) 60%, transparent 100%);
  color: var(--gold2);
}
.gallery-illus.ci {
  background: radial-gradient(ellipse at 40% 60%, rgba(74,158,92,0.14) 0%, rgba(200,149,42,0.04) 60%, transparent 100%);
  color: var(--green);
}
body.light .gallery-illus.fi {
  background: radial-gradient(ellipse at 60% 40%, rgba(168,114,10,0.10) 0%, rgba(45,122,64,0.07) 60%, transparent 100%);
  color: #7a5200;
}
body.light .gallery-illus.ci {
  background: radial-gradient(ellipse at 40% 60%, rgba(45,122,64,0.14) 0%, rgba(168,114,10,0.04) 60%, transparent 100%);
  color: #1d5a2c;
}
.gallery-illus svg { width: 100%; height: 100%; }

/* product photo */
.product-img {
  max-width: 100%; max-height: 100%;
  width: auto; height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.35));
  transition: transform .3s var(--ease);
}
body.light .product-img { filter: drop-shadow(0 6px 16px rgba(15,45,24,0.18)); }
.gallery-card:hover .product-img { transform: scale(1.06) translateY(-2px); }
.lc-illus .product-img { height: 92%; }

/* decorative corner dots */
.gallery-illus::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(to top, var(--bg2), transparent);
  pointer-events: none;
}

/* card body */
.gallery-body { padding: 0.9rem 1.1rem 1.1rem; }
.gallery-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.gallery-badge-name { display: flex; align-items: center; gap: 8px; }

.card-num {
  font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  white-space: nowrap; flex-shrink: 0;
}
.card-num.formula-badge { background: var(--gold-light); color: var(--gold2); border: 1px solid rgba(200,149,42,0.3); }
.card-num.cream-badge   { background: var(--green-light); color: var(--green);  border: 1px solid rgba(74,158,92,0.3); }
body.light .card-num.formula-badge { background: rgba(168,114,10,0.1); color: #7a5200; border-color: rgba(168,114,10,0.25); }
body.light .card-num.cream-badge   { background: rgba(45,122,64,0.1); color: #1d5a2c; border-color: rgba(45,122,64,0.25); }

.card-name { font-size: 16px; font-weight: 700; color: var(--cream); }
body.light .card-name { font-weight: 800 !important; color: #12301a !important; }

.expand-arrow { font-size: 14px; color: var(--cream3); transition: transform 0.3s; flex-shrink: 0; }
.gallery-card.expanded .expand-arrow { transform: rotate(180deg); color: var(--gold2); }
body.light .gallery-card.expanded .expand-arrow { color: #2d7a40; }

.card-chinese {
  font-size: 11.5px; color: var(--cream3); line-height: 1.5;
  padding-right: 8px; border-right: 2px solid var(--gold);
  margin-bottom: 9px;
}
body.light .card-chinese { border-right-color: #2d7a40; }

.syms-preview { display: flex; flex-wrap: wrap; gap: 4px; }
.sym { font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--bg4); color: var(--cream3); }
.sym.hl { background: rgba(200,149,42,0.18); color: var(--gold2); }
body.light .sym     { background: rgba(45,122,64,0.08); color: #2a5535; }
body.light .sym.hl  { background: rgba(45,122,64,0.2);  color: #1d5a2c; }

.card-expanded { max-height: 0; overflow: hidden; transition: max-height 0.4s cubic-bezier(.4,0,.2,1); }
.gallery-card.expanded .card-expanded { max-height: 1000px; }
.expanded-inner { padding-top: 10px; border-top: 1px solid var(--border); margin-top: 10px; }
.expanded-syms { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }

.video-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 30px;
  border: 1px solid var(--gold);
  background: var(--gold-light); color: var(--gold2);
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--font); transition: var(--transition);
}
.video-btn:hover { background: var(--gold); color: var(--bg); transform: scale(1.04); }
.video-btn .play-icon { font-size: 13px; }
.video-btn.soon { border-color: var(--border); background: transparent; color: var(--cream3); cursor: default; font-weight: 400; }
.video-btn.soon:hover { background: transparent; color: var(--cream3); transform: none; }
body.light .video-btn       { border-color: #2d7a40; background: rgba(45,122,64,0.1); color: #1d5a2c; }
body.light .video-btn:hover { background: #2d7a40; color: #fff; }

/* card actions row + buy button */
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.buy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border-radius: 30px;
  border: none; text-decoration: none;
  background: linear-gradient(135deg, #d4971e, #b8821f);
  color: #fff; font-size: 13px; font-weight: 800;
  cursor: pointer; font-family: var(--font); transition: var(--transition);
  box-shadow: 0 2px 12px rgba(184,130,31,.35);
}
.buy-btn:hover { transform: scale(1.05); box-shadow: 0 4px 18px rgba(184,130,31,.5); }

/* community shared notes */
.note-dot { font-size: 12px; margin-right: 4px; opacity: .8; }
.notes-block {
  margin-top: 14px; padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1.5px solid rgba(184,130,31,.3);
}
.notes-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.notes-label { font-size: 13px; font-weight: 800; color: #92400e; display: flex; align-items: center; gap: 6px; }
.notes-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #d4971e; color: #fff; font-size: 11px; font-weight: 700;
}
.notes-summarize-btn {
  font-size: 11px; font-weight: 700; padding: 5px 12px; border-radius: 20px;
  border: 1px solid rgba(184,130,31,.4); background: #fff; color: #92400e;
  cursor: pointer; font-family: var(--font); transition: .2s; white-space: nowrap;
}
.notes-summarize-btn:hover { background: #d4971e; color: #fff; }
.notes-summary { margin-bottom: 12px; }
.notes-summary-box {
  background: #fff; border: 1px solid rgba(184,130,31,.25); border-radius: 10px;
  padding: 12px 14px; font-size: 12.5px; line-height: 1.7; color: #3d2f10;
}
.notes-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 260px; overflow-y: auto; }
.notes-msg { font-size: 12px; color: #a8804a; text-align: center; padding: 12px; }
.note-item {
  background: #fff; border-radius: 10px; padding: 10px 12px;
  border: 1px solid rgba(184,130,31,.15);
}
.note-item-text { font-size: 13px; color: #1f1a0d; line-height: 1.6; margin-bottom: 5px; }
.note-item-meta { font-size: 10.5px; color: #a8804a; }
.note-item-meta strong { color: #92400e; }
.notes-compose { display: flex; flex-direction: column; gap: 8px; }
.notes-name {
  padding: 8px 12px; border-radius: 8px; border: 1.5px solid rgba(184,130,31,.25);
  background: #fff; color: #1f1a0d; font-family: var(--font); font-size: 12.5px; outline: none;
}
.notes-name:focus { border-color: #d4971e; }
.notes-area {
  width: 100%; min-height: 56px; max-height: 180px;
  padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid rgba(184,130,31,.25); background: #fff;
  color: #1f1a0d; font-family: var(--font); font-size: 13px;
  line-height: 1.6; resize: vertical; outline: none; box-sizing: border-box;
}
.notes-area:focus { border-color: #d4971e; box-shadow: 0 0 0 3px rgba(212,151,30,.12); }
.notes-area::placeholder, .notes-name::placeholder { color: #b8956b; }
.notes-post-btn {
  align-self: flex-start;
  padding: 8px 22px; border-radius: 20px; border: none;
  background: linear-gradient(135deg,#d4971e,#b8821f); color: #fff;
  font-size: 13px; font-weight: 800; cursor: pointer; font-family: var(--font); transition: .2s;
}
.notes-post-btn:hover:not(:disabled) { transform: scale(1.04); }
.notes-post-btn:disabled { opacity: .5; cursor: default; }
.notes-hint { font-size: 10px; color: #a8804a; opacity: .8; margin-top: 8px; text-align: center; }


/* ===== FULL COURSE FEED ===== */
.course-feed { display: flex; flex-direction: column; gap: 1.25rem; max-width: 820px; }

.cf-lesson { display: flex; gap: 16px; align-items: flex-start; animation: cfIn .4s cubic-bezier(.4,0,.2,1) both; }
@keyframes cfIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.cf-index {
  width: 38px; height: 38px; flex-shrink: 0; margin-top: 6px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif, 'Playfair Display', serif);
  font-size: 16px; font-weight: 700;
  background: #16a34a; color: #fff;
  box-shadow: 0 2px 10px rgba(22,163,74,.3);
}

.cf-card {
  flex: 1; display: flex; gap: 1.25rem;
  background: #fff; border: 1px solid rgba(22,163,74,.15);
  border-radius: 20px; padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 16px rgba(15,45,24,.06);
  transition: box-shadow .25s, transform .25s, border-color .2s;
}
.cf-card:hover { box-shadow: 0 10px 40px rgba(15,45,24,.12); transform: translateY(-2px); border-color: rgba(22,163,74,.35); }

.cf-illus {
  width: 130px; flex-shrink: 0;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  align-self: stretch;
}
.cf-illus.fi { background: linear-gradient(150deg,#fef3c7,#fde68a); }
.cf-illus.ci { background: linear-gradient(150deg,#dcfce7,#bbf7d0); }
.cf-illus .product-img { height: 88%; max-height: 200px; }
.cf-illus svg { width: 100px; height: 100px; }

.cf-body { flex: 1; min-width: 0; }
.cf-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 4px 12px; border-radius: 20px; margin-bottom: 8px;
}
.cf-badge.formula-badge { background: rgba(168,114,10,.1); color: #78350f; }
.cf-badge.cream-badge { background: rgba(22,163,74,.1); color: #14532d; }

.cf-name {
  font-family: var(--font-serif, 'Playfair Display', serif);
  font-size: 1.6rem; font-weight: 900; color: #0d1f12;
  line-height: 1.15; margin-bottom: 10px; letter-spacing: -.01em;
}

.cf-chinese-wrap { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 14px; }
.cf-chinese-label {
  font-size: 9px; font-weight: 700; letter-spacing: 1px; color: #6b8a72;
  white-space: nowrap; margin-top: 3px; text-transform: uppercase;
}
.cf-chinese {
  font-size: 13px; color: #3d5a45; line-height: 1.6;
  padding-right: 8px; border-right: 2px solid #16a34a;
}

.cf-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: #6b8a72; margin-bottom: 8px;
}
.cf-syms { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.cf-sym {
  font-size: 11.5px; padding: 4px 11px; border-radius: 20px;
  background: #f0fdf4; color: #2a5535; border: 1px solid rgba(22,163,74,.15);
}

.cf-video-row { margin-top: 4px; }
.cf-video-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: 30px; border: none;
  background: #16a34a; color: #fff; font-size: 12.5px; font-weight: 700;
  cursor: pointer; transition: .2s; font-family: var(--font);
  box-shadow: 0 2px 10px rgba(22,163,74,.3);
}
.cf-video-btn:hover { background: #15803d; transform: scale(1.04); }
.cf-no-video { font-size: 12px; color: #6b8a72; opacity: .7; }

@media (max-width: 640px) {
  .cf-card { flex-direction: column; }
  .cf-illus { width: 100%; height: 160px; }
  .cf-index { display: none; }
}

/* ===== SMART MATCHER ===== */
.matcher-wrap { max-width: 720px; display: flex; flex-direction: column; gap: 16px; }

.matcher-input-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 1.25rem;
  transition: border-color 0.2s;
}
.matcher-input-card:focus-within { border-color: var(--gold); }
body.light .matcher-input-card:focus-within { border-color: #2d7a40; }

.matcher-input-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--cream3); margin-bottom: 10px;
}
.matcher-label-icon { font-size: 16px; }

.matcher-textarea {
  width: 100%; min-height: 120px; max-height: 220px;
  background: transparent; border: none; outline: none;
  font-family: var(--font); font-size: 14px; color: var(--cream);
  line-height: 1.75; resize: vertical;
}
body.light .matcher-textarea { color: #12301a; }
.matcher-textarea::placeholder { color: var(--cream3); opacity: 0.7; }

.matcher-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.matcher-clear-btn {
  font-size: 12px; color: var(--cream3); background: none; border: none;
  cursor: pointer; font-family: var(--font); padding: 4px 10px;
  border-radius: 20px; transition: var(--transition);
}
.matcher-clear-btn:hover { color: var(--cream); background: var(--bg3); }
.matcher-char-count { font-size: 11px; color: var(--cream3); opacity: 0.6; }

/* Empty state */
.matcher-empty { text-align: center; padding: 3rem 1rem; color: var(--cream3); }
.matcher-empty-icon { font-size: 42px; margin-bottom: 12px; opacity: 0.5; }
.matcher-empty p { font-size: 14px; }

/* Results */
.matcher-results { display: flex; flex-direction: column; gap: 10px; }

.match-result-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden;
  animation: cardIn 0.3s cubic-bezier(.4,0,.2,1) both;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.match-result-card:hover { border-color: var(--border2); box-shadow: 0 4px 20px rgba(0,0,0,0.25); }
.match-result-card.rank-1 { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(200,149,42,0.15); }
body.light .match-result-card.rank-1 { border-color: #2d7a40; box-shadow: 0 0 0 1px rgba(45,122,64,0.15); }

.match-card-inner { display: flex; align-items: stretch; }

.match-illus {
  width: 110px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0.5rem;
}
.match-illus.fi { background: radial-gradient(ellipse at 50% 50%, rgba(200,149,42,0.12) 0%, transparent 80%); color: var(--gold2); }
.match-illus.ci { background: radial-gradient(ellipse at 50% 50%, rgba(74,158,92,0.14) 0%, transparent 80%); color: var(--green); }
body.light .match-illus.fi { background: radial-gradient(ellipse, rgba(168,114,10,0.1) 0%, transparent 80%); color: #7a5200; }
body.light .match-illus.ci { background: radial-gradient(ellipse, rgba(45,122,64,0.12) 0%, transparent 80%); color: #1d5a2c; }
.match-illus svg { width: 90px; height: 90px; }

.match-body { flex: 1; padding: 1rem 1.1rem; }

.match-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; justify-content: space-between; }
.match-name-row { display: flex; align-items: center; gap: 8px; }
.match-name { font-size: 16px; font-weight: 700; color: var(--cream); }
body.light .match-name { color: #12301a !important; font-weight: 800 !important; }

/* Score bar */
.match-score-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.match-score-num {
  font-size: 13px; font-weight: 700;
  min-width: 36px; text-align: center;
}
.rank-1 .match-score-num { color: var(--gold2); }
.rank-2 .match-score-num { color: var(--cream3); }
.rank-3 .match-score-num, .rank-other .match-score-num { color: var(--cream3); opacity: 0.7; }
body.light .rank-1 .match-score-num { color: #1d5a2c; }

.match-score-bar { width: 80px; height: 5px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.match-score-fill { height: 100%; border-radius: 3px; transition: width 0.6s cubic-bezier(.4,0,.2,1); }
.rank-1 .match-score-fill { background: linear-gradient(to left, var(--gold2), var(--green)); }
.rank-2 .match-score-fill { background: var(--cream3); opacity: 0.6; }
.rank-3 .match-score-fill, .rank-other .match-score-fill { background: var(--cream3); opacity: 0.35; }
body.light .rank-1 .match-score-fill { background: linear-gradient(to left, #2d7a40, #6ec97e); }

.match-chinese {
  font-size: 12px; color: var(--cream3); line-height: 1.5;
  padding-right: 8px; border-right: 2px solid var(--gold);
  margin-bottom: 10px;
}
body.light .match-chinese { border-right-color: #2d7a40; }

.match-syms { display: flex; flex-wrap: wrap; gap: 4px; }
.match-sym { font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--bg4); color: var(--cream3); }
.match-sym.matched { background: rgba(200,149,42,0.18); color: var(--gold2); font-weight: 600; }
body.light .match-sym { background: rgba(45,122,64,0.07); color: #2a5535; }
body.light .match-sym.matched { background: rgba(45,122,64,0.2); color: #1d5a2c; font-weight: 700; }

/* Top rank badge */
.rank-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.rank-1 .rank-badge { background: var(--gold-light); color: var(--gold2); border: 1px solid rgba(200,149,42,0.35); }
body.light .rank-1 .rank-badge { background: rgba(45,122,64,0.15); color: #1d5a2c; border-color: rgba(45,122,64,0.3); }


/* ===== SEARCH ===== */
.search-wrap { max-width: 680px; }
.search-field-wrap {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 12px 22px;
  margin-bottom: 1.5rem;
  transition: var(--transition);
}
.search-field-wrap:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,149,42,0.1);
}
.search-icon { font-size: 18px; color: var(--cream3); flex-shrink: 0; }
.search-field {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font); font-size: 15px; color: var(--cream);
}
.search-field::placeholder { color: var(--cream3); }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--cream3); }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

.search-result-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 10px;
  animation: fadeUp 0.3s ease both;
  transition: var(--transition);
}
.search-result-card:hover { border-color: var(--border2); background: var(--bg3); }
.sr-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sr-name { font-size: 16px; font-weight: 600; color: var(--cream); }
.sr-chinese { font-size: 12px; color: var(--cream3); margin-bottom: 10px; padding-right: 10px; border-right: 2px solid var(--gold); }
.sr-syms { display: flex; flex-wrap: wrap; gap: 5px; }

/* ===== VIDEO MODAL ===== */
.video-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center; justify-content: center;
}
.video-backdrop.active { display: flex; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.video-modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 90%; max-width: 760px;
  animation: slideUp 0.3s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 20px 80px rgba(0,0,0,0.7);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.video-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.video-modal-title { font-size: 15px; font-weight: 600; color: var(--gold2); }
.video-close-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3); color: var(--cream3);
  font-size: 14px; cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.video-close-btn:hover { background: var(--red-light); border-color: var(--red); color: #e06c6c; }

.video-frame { width: 100%; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.video-frame iframe { width: 100%; height: 100%; border: none; }

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--cream3);
  font-family: var(--font); font-size: 13px;
  cursor: pointer; transition: var(--transition);
  text-align: right;
}
.theme-toggle:hover { border-color: var(--border2); color: var(--cream); background: var(--bg4); }
.theme-icon { font-size: 16px; }
.theme-label { font-size: 13px; }

/* ===== LIGHT MODE ===== */
body.light {
  --bg:          #c3ecd2;
  --bg2:         #ffffff;
  --bg3:         #d6eddc;
  --bg4:         #b4e0c2;
  --gold:        #2d7a40;
  --gold2:       #1d5a2c;
  --gold-light:  rgba(45,122,64,0.15);
  --cream:       #12301a;
  --cream2:      #2a5535;
  --cream3:      rgba(18,48,26,0.55);
  --green:       #1d5a2c;
  --green2:      #145020;
  --green-light: rgba(29,90,44,0.12);
  --red:         #b83025;
  --red-light:   rgba(184,48,37,0.12);
  --border:      rgba(45,122,64,0.25);
  --border2:     rgba(45,122,64,0.5);
  --shadow:      0 8px 40px rgba(18,48,26,0.1);
  background:
    radial-gradient(ellipse 80% 60% at 82% -5%,  rgba(180,144,84,0.22) 0%, transparent 55%),
    radial-gradient(ellipse 70% 60% at 0% 105%,   rgba(176,141,87,0.16) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 50% 50%,   rgba(216,204,180,0.30) 0%, transparent 70%),
    linear-gradient(160deg, #f6f0e3 0%, #efe3cd 52%, #e7d9bd 100%);
  background-attachment: fixed;
}

body.light .bg-canvas::before {
  background:
    radial-gradient(ellipse 70% 60% at 75% 15%, rgba(45,122,64,0.14) 0%, transparent 60%),
    radial-gradient(ellipse 50% 70% at 5% 85%,  rgba(29,90,44,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(100,200,120,0.05) 0%, transparent 70%);
}
body.light .leaf { background: rgba(45,122,64,0.4); }
body.light .logo-leaf {
  filter: drop-shadow(0 0 10px rgba(45,122,64,0.6));
}

/* Bold headings in light mode */
body.light .section-title {
  font-weight: 900 !important;
  color: #12301a !important;
  letter-spacing: -0.5px;
}
body.light .section-title em {
  color: #2d7a40 !important;
  font-style: italic;
}
body.light .card-name { font-weight: 800 !important; color: #12301a !important; }
body.light .sr-name   { font-weight: 800 !important; color: #12301a !important; }
body.light .logo-title { color: #1d5a2c !important; font-weight: 700 !important; }
body.light .stat-num  { color: #1d5a2c !important; font-weight: 900 !important; }
body.light .nav-btn.active { color: #1d5a2c !important; }
body.light .fc-answer-name { font-weight: 900 !important; color: #12301a !important; }
body.light .fc-answer-num  { font-weight: 900 !important; color: #1d5a2c !important; }
body.light .quiz-result-num { font-weight: 900 !important; color: #1d5a2c !important; }

/* Cards – crisp white on green bg */
body.light .formula-card {
  background: #ffffff;
  border-color: rgba(45,122,64,0.2);
  box-shadow: 0 2px 12px rgba(18,48,26,0.06);
}
body.light .formula-card:hover {
  border-color: rgba(45,122,64,0.5);
  box-shadow: 0 6px 24px rgba(18,48,26,0.12);
}
body.light .formula-card::before {
  background: linear-gradient(to bottom, #2d7a40, #6ec97e);
}
body.light .card-chinese { border-right-color: #2d7a40; }
body.light .sym { background: #e8f5ec; color: #2d5a35; border-color: rgba(45,122,64,0.15); }
body.light .sym.hl { background: rgba(45,122,64,0.18); color: #1d5a2c; border-color: rgba(45,122,64,0.4); }
body.light .card-num.formula-badge { background: rgba(45,122,64,0.12); color: #1d5a2c; border-color: rgba(45,122,64,0.3); }
body.light .card-num.cream-badge   { background: rgba(100,160,80,0.12); color: #2a5535; border-color: rgba(100,160,80,0.3); }
body.light .expand-arrow { color: #2d7a40; }

/* Sidebar */
body.light .sidebar {
  background: #d0e8d6;
  border-left-color: rgba(45,122,64,0.3);
  box-shadow: 2px 0 20px rgba(18,48,26,0.08);
}
body.light .sidebar-logo { border-bottom-color: rgba(45,122,64,0.25); }
body.light .stat-box { background: #e8f5ec; border-color: rgba(45,122,64,0.2); }
body.light .nav-btn { color: #2a5535; }
body.light .nav-btn:hover { color: #12301a; background: rgba(45,122,64,0.12); }
body.light .nav-btn.active { background: rgba(45,122,64,0.18); border-color: rgba(45,122,64,0.4); }
body.light .theme-toggle { background: #e8f5ec; border-color: rgba(45,122,64,0.3); color: #2a5535; }
body.light .theme-toggle:hover { background: #d0e8d6; color: #12301a; }

/* Flashcard */
body.light .fc-front {
  background: #ffffff;
  box-shadow: 0 4px 30px rgba(18,48,26,0.08), inset 0 1px 0 rgba(255,255,255,0.9);
  border-color: rgba(45,122,64,0.2);
}
body.light .fc-back {
  background: linear-gradient(135deg, #d6eddc 0%, #b8dfc2 100%);
  border-color: #2d7a40;
}
body.light .fc-badge { background: #e8f5ec; color: #2a5535; border-color: rgba(45,122,64,0.25); }
body.light .fc-answer-num { color: #1d5a2c; text-shadow: 0 0 30px rgba(45,122,64,0.3); }
body.light .fc-answer-name { color: #12301a; }
body.light .fc-prog-fill { background: linear-gradient(to left, #2d7a40, #6ec97e); }

/* Quiz */
body.light .quiz-q-card {
  background: #ffffff;
  border-color: rgba(45,122,64,0.2);
  box-shadow: 0 2px 12px rgba(18,48,26,0.06);
}
body.light .quiz-q-card::before { color: rgba(45,122,64,0.07); }
body.light .quiz-opt { background: #ffffff; border-color: rgba(45,122,64,0.2); color: #2a5535; }
body.light .quiz-opt:hover:not(:disabled) { background: #e8f5ec; border-color: rgba(45,122,64,0.5); color: #12301a; }
body.light .quiz-next-btn { background: rgba(45,122,64,0.15); border-color: #2d7a40; color: #1d5a2c; }
body.light .quiz-next-btn:hover { background: #2d7a40; color: #fff; }
body.light .restart-btn { background: rgba(45,122,64,0.15); border-color: #2d7a40; color: #1d5a2c; }
body.light .restart-btn:hover { background: #2d7a40; color: #fff; }
body.light .quiz-result-num { color: #1d5a2c; text-shadow: 0 0 40px rgba(45,122,64,0.25); }

/* Search */
body.light .search-field-wrap { background: #ffffff; border-color: rgba(45,122,64,0.25); }
body.light .search-field-wrap:focus-within { border-color: #2d7a40; box-shadow: 0 0 0 3px rgba(45,122,64,0.12); }
body.light .search-result-card { background: #ffffff; border-color: rgba(45,122,64,0.2); box-shadow: 0 2px 8px rgba(18,48,26,0.05); }
body.light .search-result-card:hover { border-color: rgba(45,122,64,0.45); background: #f4fbf6; }
body.light .sr-chinese { border-right-color: #2d7a40; }
body.light .sr-name { color: #12301a; font-weight: 800; }

/* Video btn */
body.light .video-btn { background: rgba(45,122,64,0.12); border-color: #2d7a40; color: #1d5a2c; }
body.light .video-btn:hover { background: #2d7a40; color: #fff; }

/* Scrollbar */
body.light ::-webkit-scrollbar-track { background: #d6eddc; }
body.light ::-webkit-scrollbar-thumb { background: rgba(45,122,64,0.3); }
body.light ::-webkit-scrollbar-thumb:hover { background: rgba(45,122,64,0.55); }
body.light .video-frame { background: #111; }
body.light .video-modal { background: #f4fbf6; border-color: rgba(45,122,64,0.35); }
body.light .video-modal-title { color: #1d5a2c; }
body.light .video-close-btn { background: #e8f5ec; border-color: rgba(45,122,64,0.3); color: #2a5535; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; }
  .main { margin-right: 0; padding: 1.2rem 1rem 88px; }
  .section-title { font-size: 26px; }
  .quiz-opts { grid-template-columns: 1fr; }
  .browse-grid { grid-template-columns: 1fr; }

  /* sidebar becomes a fixed BOTTOM tab bar */
  .sidebar {
    position: fixed; right: 0; left: 0; bottom: 0; top: auto;
    width: 100%; min-height: 0; height: auto;
    flex-direction: row; padding: 0; gap: 0;
    border-left: none; border-top: 1px solid var(--border);
    background: var(--bg2); z-index: 100; display: flex;
    box-shadow: 0 -4px 20px rgba(13,51,32,.08);
  }
  .sidebar-logo, .sidebar-footer { display: none; }
  .sidebar-nav { display: flex; flex-direction: row; width: 100%; gap: 0; }
  .nav-btn {
    flex: 1 1 0; min-width: 0; flex-direction: column; gap: 4px;
    padding: 10px 4px; border-radius: 0; justify-content: center;
    border: none; border-top: 3px solid transparent;
  }
  .nav-btn.active { border-top: 3px solid #2d7a40; background: rgba(45,122,64,0.06); }
  .nav-btn .nav-icon { font-size: 22px; }
  .nav-btn span:last-child { font-size: 12px; font-weight: 800; line-height: 1.15; text-align: center; }

  /* floating language toggle (since footer is hidden) */
  .mobile-lang {
    display: flex; position: fixed; top: 12px;
    align-items: center; gap: 5px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 700;
    color: #2a5535; z-index: 101; cursor: pointer; font-family: var(--font);
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
  }
  html[dir="rtl"] .mobile-lang { left: 12px; }
  html[dir="ltr"] .mobile-lang { right: 12px; }
  #admin-bar { bottom: 80px; }
}
/* desktop: hide the mobile lang button */
.mobile-lang { display: none; }

/* ===== LTR (English) FULL LAYOUT FLIP ===== */
html[dir="ltr"] body { direction: ltr; }

/* sidebar moves to the LEFT */
html[dir="ltr"] .sidebar {
  right: auto; left: 0;
  border-left: none;
  border-right: 1px solid var(--border);
}
html[dir="ltr"] .main {
  margin-right: 0;
  margin-left: var(--sidebar-w);
}

/* text alignment + accent borders flip */
html[dir="ltr"] .card-chinese {
  border-right: none; border-left: 2px solid #16a34a;
  padding-right: 0; padding-left: 10px;
}
html[dir="ltr"] .match-chinese {
  border-right: none; border-left: 2px solid var(--green);
  padding-right: 0; padding-left: 8px;
}
html[dir="ltr"] .matcher-input-label { text-align: left; }
html[dir="ltr"] .section-title,
html[dir="ltr"] .section-desc { text-align: left; }

/* mobile: sidebar flip stays consistent */
@media (max-width: 820px) {
  html[dir="ltr"] .main { margin-left: 0; }
}

/* note edit/delete controls */
.note-actions { display: flex; gap: 6px; margin-top: 8px; }
.note-edit-btn, .note-del-btn, .note-save-btn, .note-cancel-btn {
  font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 16px;
  border: 1px solid rgba(184,130,31,.3); background: #fff; cursor: pointer;
  font-family: var(--font); transition: .15s;
}
.note-edit-btn { color: #92400e; }
.note-edit-btn:hover { background: #d4971e; color: #fff; }
.note-del-btn { color: #8a5a1a; border-color: rgba(138,90,26,.3); }
.note-del-btn:hover { background: #8a5a1a; color: #fff; }
.note-save-btn { background: #16a34a; color: #fff; border-color: #16a34a; }
.note-save-btn:hover { background: #15803d; }
.note-save-btn:disabled { opacity: .6; cursor: default; }
.note-cancel-btn { color: #6b8a72; }
.note-cancel-btn:hover { background: #f0f0f0; }
.note-edit-area {
  width: 100%; min-height: 56px; padding: 8px 10px; border-radius: 8px;
  border: 1.5px solid #d4971e; background: #fff; color: #1f1a0d;
  font-family: var(--font); font-size: 13px; line-height: 1.6; resize: vertical;
  outline: none; box-sizing: border-box;
}



/* admin floating bar (only visible when admin active) */
#admin-bar {
  position: fixed; bottom: 16px; left: 16px; z-index: 9999;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(135deg, #2f3d26, #4a6149);
  color: #f6f0e3;
  padding: 10px 16px; border-radius: 30px;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  box-shadow: 0 6px 24px rgba(47,61,38,.35);
}
#admin-bar button {
  background: #b8821f; color: #fff; border: none;
  padding: 6px 15px; border-radius: 20px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: .15s;
}
#admin-bar button:hover { background: #9a6c19; }
html[dir="ltr"] #admin-bar { left: auto; right: 16px; }
.note-item.admin-flag { border-color: rgba(184,130,31,.35); }

/* ===== LEAD CAPTURE ===== */
.lead-box {
  margin-top: 16px; padding: 18px; border-radius: 16px;
  background: linear-gradient(135deg,#0d3320,#16623a); color: #fff;
  box-shadow: 0 6px 24px rgba(13,51,32,.2);
}
.lead-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.lead-desc { font-size: 12.5px; opacity: .8; margin-bottom: 12px; line-height: 1.5; }
.lead-form { display: flex; flex-direction: column; gap: 8px; }
.lead-input {
  padding: 10px 14px; border-radius: 10px; border: none;
  font-family: var(--font); font-size: 13px; outline: none;
}
.lead-btn {
  padding: 11px; border-radius: 10px; border: none;
  background: linear-gradient(135deg,#d4971e,#b8821f); color: #fff;
  font-family: var(--font); font-size: 14px; font-weight: 800; cursor: pointer;
  transition: .2s; box-shadow: 0 3px 14px rgba(184,130,31,.4);
}
.lead-btn:hover:not(:disabled) { transform: scale(1.02); }
.lead-btn:disabled { opacity: .6; cursor: default; }
.lead-thanks { text-align: center; font-size: 15px; font-weight: 700; padding: 14px; }

/* ===== CUSTOMER REVIEWS ===== */
.reviews-block {
  margin-top: 14px; padding: 14px; border-radius: 14px;
  background: #f7fbf8; border: 1.5px solid rgba(22,163,74,.18);
}
.reviews-head { margin-bottom: 10px; }
.reviews-label { font-size: 13px; font-weight: 800; color: #15803d; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rev-avg-stars { color: #d4971e; letter-spacing: 1px; }
.rev-avg-num { font-size: 11px; color: #6b8a72; font-weight: 600; }
.reviews-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 240px; overflow-y: auto; }
.review-item { background: #fff; border-radius: 10px; padding: 10px 12px; border: 1px solid rgba(22,163,74,.12); }
.review-stars { color: #d4971e; font-size: 13px; letter-spacing: 1px; margin-bottom: 4px; }
.review-text { font-size: 13px; color: #1f2d20; line-height: 1.6; margin-bottom: 5px; }
.review-meta { font-size: 10.5px; color: #6b8a72; }
.reviews-compose { display: flex; flex-direction: column; gap: 8px; }
.reviews-star-pick { display: flex; gap: 4px; font-size: 24px; cursor: pointer; }
.star-pick { color: #d4971e; transition: transform .1s; cursor: pointer; }
.star-pick:hover { transform: scale(1.2); }
.reviews-post-btn {
  align-self: flex-start; padding: 8px 22px; border-radius: 20px; border: none;
  background: #16a34a; color: #fff; font-size: 13px; font-weight: 800;
  cursor: pointer; font-family: var(--font); transition: .2s;
}
.reviews-post-btn:hover:not(:disabled) { background: #15803d; transform: scale(1.03); }
.reviews-post-btn:disabled { opacity: .6; }

/* ===== QUIZ ===== */
.quiz-wrap { max-width: 600px; margin: 0 auto; }
.quiz-card {
  background: #fff; border: 1px solid rgba(22,163,74,.15); border-radius: 24px;
  padding: 2rem; box-shadow: 0 8px 40px rgba(15,45,24,.08);
}
.quiz-progress { height: 6px; background: #e4f2ea; border-radius: 3px; overflow: hidden; margin-bottom: 18px; }
.quiz-progress-fill { height: 100%; background: linear-gradient(to left,#d4971e,#16a34a); transition: width .4s; }
.quiz-step-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: #6b8a72; margin-bottom: 8px; }
.quiz-question { font-family: var(--font-serif,'Playfair Display',serif); font-size: 1.5rem; font-weight: 800; color: #0d1f12; margin-bottom: 20px; line-height: 1.3; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  padding: 14px 18px; border-radius: 14px; border: 1.5px solid rgba(22,163,74,.2);
  background: #f7fbf8; color: #1f2d20; font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .18s; text-align: right;
}
.quiz-option:hover { border-color: #16a34a; background: #16a34a; color: #fff; transform: translateX(-4px); }
html[dir="ltr"] .quiz-option { text-align: left; }
html[dir="ltr"] .quiz-option:hover { transform: translateX(4px); }
.quiz-back { margin-top: 16px; background: none; border: none; color: #6b8a72; font-family: var(--font); font-size: 13px; cursor: pointer; }
.quiz-back:hover { color: #16a34a; }
.quiz-result-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: #6b8a72; margin-bottom: 12px; }
.quiz-result-formula { display: flex; gap: 16px; align-items: center; }
.quiz-result-num { font-family: var(--font-serif,'Playfair Display',serif); font-size: 1.4rem; font-weight: 900; color: #15803d; }
.quiz-result-chinese { font-size: 13px; color: #3d5a45; line-height: 1.5; margin: 6px 0; }
.quiz-alts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.quiz-alt { font-size: 12px; padding: 5px 12px; border-radius: 20px; background: #e4f2ea; color: #15803d; font-weight: 600; }

/* ===== ADMIN DASHBOARD ===== */
#admin-bar { flex-wrap: wrap; }
.dash-backdrop { position: fixed; inset: 0; background: rgba(13,51,32,.5); z-index: 10000; }
.dash-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(720px,92vw); max-height: 82vh; background: #fff; border-radius: 18px;
  z-index: 10001; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,.08);
  font-size: 16px; font-weight: 800; color: #0d1f12;
}
.dash-head button { background: none; border: none; font-size: 18px; cursor: pointer; color: #6b8a72; }
.dash-body { overflow-y: auto; padding: 12px 20px 20px; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dash-table th { text-align: right; padding: 8px; border-bottom: 2px solid #e4f2ea; color: #6b8a72; font-weight: 700; position: sticky; top: 0; background: #fff; }
.dash-table td { padding: 8px; border-bottom: 1px solid #f0f0f0; color: #1f2d20; word-break: break-word; }
html[dir="ltr"] .dash-table th { text-align: left; }

/* quiz dosing note */
.quiz-dose-note {
  margin-top: 14px; padding: 12px 16px; border-radius: 12px;
  background: #fef3c7; border: 1.5px solid rgba(184,130,31,.3);
  color: #92400e; font-size: 13.5px; font-weight: 700; line-height: 1.5;
}

/* cosmetics result */
.cos-head { background: var(--sage-deep, #2a5535); color: #fff; margin: -2rem -2rem 0; padding: 22px 2rem; border-radius: 24px 24px 0 0; }
.cos-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.cos-pattern { font-size: 13px; opacity: .9; }
.cos-block { padding: 16px 0; border-bottom: 1px dashed var(--border); }
.cos-block:last-of-type { border-bottom: none; }
.cos-block h4 { font-size: 16px; font-weight: 800; color: #15803d; margin-bottom: 10px; }
.cos-block p { font-size: 14.5px; color: #2a3d2f; line-height: 1.6; }
.cos-prod { display: flex; align-items: center; gap: 12px; background: #f7fbf8; border: 1px solid rgba(22,163,74,.15); border-radius: 12px; padding: 12px 14px; margin: 8px 0; flex-wrap: wrap; }
.cos-pnum { width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; background: #16a34a; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.cos-prod.cream .cos-pnum { background: #d4971e; }
.cos-pinfo { flex: 1; min-width: 110px; }
.cos-pname { font-weight: 800; color: #14321f; font-size: 15px; }
.cos-pdesc { font-size: 12px; color: #5c7a64; }
.cos-nutri { display: grid; grid-template-columns: 76px 1fr; gap: 10px; margin: 6px 0; font-size: 14px; }
.cos-nutri .av { color: #9a4a2e; font-weight: 800; }
.cos-nutri .ad { color: #15803d; font-weight: 800; }
@media (max-width: 600px){ .cos-nutri { grid-template-columns: 1fr; gap: 2px; } .cos-head { margin: -1.5rem -1.5rem 0; } }

/* cream cosmetic detail lines in quiz result */
.cos-puse { font-size: 12px; color: #5c7a64; margin-top: 4px; }
.cos-pwarn { font-size: 12px; color: #9a4a2e; margin-top: 4px; }
.cos-prod { align-items: flex-start; }
.cos-pnum { margin-top: 2px; }

/* ===== SMART DIAGNOSIS ===== */
.diag-wrap { max-width: 640px; margin: 0 auto; }
.diag-card { background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 2rem; box-shadow: 0 8px 40px rgba(31,26,20,.08); }
.diag-block { margin-bottom: 22px; }
.diag-label { display: block; font-family: var(--font); font-size: 15px; font-weight: 800; color: #2a5535; margin-bottom: 10px; }
.diag-opt { font-weight: 400; font-size: 12px; color: #8a7a5a; }
.diag-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.diag-input, .diag-textarea {
  padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--border);
  background: #faf8f2; font-family: var(--font); font-size: 14px; color: #1f1a14; outline: none; width: 100%; box-sizing: border-box;
}
.diag-input { width: 120px; }
.diag-input:focus, .diag-textarea:focus { border-color: #b8821f; }
.diag-gender { display: flex; gap: 8px; }
.diag-g { padding: 11px 22px; border-radius: 12px; border: 1.5px solid var(--border); background: #faf8f2; font-family: var(--font); font-size: 14px; font-weight: 700; cursor: pointer; color: #5c5147; transition: .15s; }
.diag-g.on { background: #2d7a40; color: #fff; border-color: #2d7a40; }
.diag-upload {
  border: 2px dashed var(--border2); border-radius: 14px; padding: 22px; text-align: center;
  cursor: pointer; color: #5c5147; font-size: 14px; background: #faf8f2; transition: .15s; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.diag-upload:hover { border-color: #b8821f; background: #f5efe0; }
.diag-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; }
.diag-hint { font-size: 11px; color: #8a7a5a; margin-top: 6px; }
.diag-go {
  width: 100%; padding: 15px; border-radius: 14px; border: none; margin-top: 8px;
  background: linear-gradient(135deg, #2d7a40, #1d5a2c); color: #fff;
  font-family: var(--font); font-size: 16px; font-weight: 800; cursor: pointer; transition: .2s;
  box-shadow: 0 4px 18px rgba(45,122,64,.35);
}
.diag-go:hover:not(:disabled) { transform: scale(1.02); }
.diag-go:disabled { opacity: .6; cursor: default; }
.diag-disclaimer { font-size: 12px; color: #8a5a1a; text-align: center; margin-top: 14px; line-height: 1.5; }
.diag-loading { text-align: center; padding: 30px; font-size: 16px; color: #2a5535; }
.diag-err, .diag-redflag { background: #fdf3e7; border: 1px solid rgba(154,74,46,.3); border-radius: 12px; padding: 12px 16px; color: #9a4a2e; font-size: 13.5px; margin: 12px 0; }
.diag-result-card { background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 2rem; margin-top: 24px; box-shadow: 0 8px 40px rgba(31,26,20,.08); animation: fade .4s ease; }
.diag-rhead { background: linear-gradient(135deg,#2f3d26,#4a6149); color: #f6f0e3; margin: -2rem -2rem 12px; padding: 22px 2rem; border-radius: 24px 24px 0 0; }
.diag-rtitle { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.diag-conf { font-size: 13px; opacity: .9; }
@media (max-width:600px){ .diag-card, .diag-result-card { padding: 1.5rem; } .diag-rhead { margin: -1.5rem -1.5rem 12px; } }

/* diagnosis extra fields */
.diag-input.full { width: 100%; }
.diag-sub { display: block; font-size: 11px; color: #8a7a5a; margin-bottom: 4px; }
.diag-row .diag-input.full { flex: 1; min-width: 130px; }
