/* ==========================================
   DATE SELECTION TOOL — STYLES
   Matches the main app warm gold palette
   ========================================== */

:root {
  --bg: #f6efe4;
  --paper: #fffdf8;
  --card: #ffffff;
  --ink: #1f1811;
  --muted: #786650;
  --line: #e7d7bf;
  --line-strong: #d9c19c;
  --accent: #c88a2b;
  --accent-deep: #9c6514;
  --dark: #24180f;
  --shadow: 0 10px 28px rgba(64, 37, 6, 0.08);
  --radius: 20px;
  --good-color: #16a34a;
  --good-bg: #f0fdf4;
  --good-border: #bbf7d0;
  --warn-color: #d97706;
  --warn-bg: #fffbeb;
  --bad-color: #dc2626;
  --bad-bg: #fef2f2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: 'Nokora', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── TOP BAR ── */
.ds-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(64, 37, 6, 0.06);
}
.ds-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line-strong);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.ds-back-btn:hover {
  background: white;
  box-shadow: 0 2px 8px rgba(64, 37, 6, 0.1);
}
.ds-title {
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
  flex: 1;
}
.ds-title span {
  color: var(--accent);
}

/* ── LANGUAGE TOGGLE ── */
.ds-lang-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 50px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 4px rgba(64, 37, 6, 0.05);
}
.ds-lang-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(200, 138, 43, 0.2);
}
.ds-lang-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
}
.ds-lang-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}

/* ── MAIN LAYOUT ── */
.ds-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 12px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── CARDS ── */
.ds-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(64, 37, 6, 0.04);
}
.ds-card-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent-deep);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ds-card-title::before {
  content: '';
  display: block;
  width: 5px;
  height: 18px;
  background: var(--accent);
  border-radius: 3px;
}

#dsCalendarTitle,
#dsHourSelectionTitle,
#dsMonthSelectionTitle,
#dsYearSelectionTitle,
#dsDateSearchToolsTitle,
#dsFourPillarsTitle {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent-deep);
}

/* ── DATETIME PICKER IN CARD TITLE ── */
.ds-datetime-picker-wrap {
  margin-left: auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fffdfa;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: 0 2px 6px rgba(64, 37, 6, 0.05);
  transition: all 0.2s ease;
  user-select: none;
}
.ds-datetime-picker-wrap:hover {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(200, 138, 43, 0.2);
  transform: translateY(-1px);
}
.ds-datetime-display {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-deep);
  white-space: nowrap;
}
.ds-datetime-icon {
  font-size: 14px;
  opacity: 0.85;
}
.ds-datetime-input {
  display: none;
}

/* ── BIRTH INPUT ── */
.birth-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.birth-input-row label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.birth-select {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23786650' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.birth-select:focus { border-color: var(--accent); }

.natal-hex-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(to right, #fffaf4, #fdf6ec);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.natal-hex-label {
  font-size: 12px;
  color: var(--muted);
}
.natal-hex-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
  font-family: 'Ma Shan Zheng Chinese Only', serif;
}
.natal-hex-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 28px;
}
.natal-hex-num .top { font-size: 18px; font-weight: 900; color: #000; }
.natal-hex-num .bot { font-size: 18px; font-weight: 900; color: #cc0000; }
.natal-hex-id { font-size: 12px; color: var(--muted); font-weight: 700; }

/* ── CALENDAR ── */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--ink);
}
.cal-nav-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.cal-month-title {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}
.cal-header {
  text-align: center;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  padding: 5px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  min-height: 58px;
}
.cal-day-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.cal-day-right-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.1;
  gap: 2px;
}
.cal-day-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
}
.cal-day-row.top-row .top, .cal-day-row.bot-row .bot {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}
.cal-day-row.top-row .top { color: #000; }
.cal-day-row.bot-row .bot { color: #cc0000; }
.cal-day-row .char { 
  color: var(--muted); 
  font-family: 'Ma Shan Zheng Chinese Only', sans-serif; 
  font-weight: 400; 
  font-size: 22px !important; 
  line-height: 1;
}

.cal-day:hover:not(.empty):not(.selected) {
  background: var(--good-bg);
  border-color: var(--line);
}
.cal-day.empty { cursor: default; }
.cal-day.today {
  border-color: var(--good-color);
  background: var(--good-bg);
}
.cal-day.selected {
  background: var(--good-color) !important;
  border-color: #15803d !important;
  color: #ffffff !important;
}
.cal-day.selected,
.cal-day.selected * {
  color: #ffffff !important;
}
.cal-day.selected .cal-day-dot { background: rgba(255,255,255,0.8); }
.cal-day.good-day:not(.selected) {
  background: var(--good-bg);
  border-color: var(--good-border);
}
.cal-day-num {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 2px;
  text-align: center;
}
.cal-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 3px;
  background: transparent;
}
.cal-day.good-day .cal-day-dot { background: var(--good-color); }

/* ── DATE & TIME PICKER DROPDOWN ── */
.ds-pillars-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.ds-datetime-container {
  position: relative;
  margin-left: auto;
}
.ds-datetime-picker-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fdfaf6;
  border: 1px solid var(--line-strong, #eddcc1);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}
.ds-datetime-picker-wrap:hover {
  background: #fdf3e2;
  border-color: #c88a2b;
  box-shadow: 0 2px 8px rgba(200, 138, 43, 0.15);
}
.ds-datetime-display {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink, #1f1811);
}
.ds-datetime-icon {
  font-size: 14px;
}
.ds-dt-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #ffffff;
  border: 1.5px solid #c88a2b;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(31, 24, 17, 0.2);
  z-index: 1000;
  width: 320px;
  max-width: 94vw;
  box-sizing: border-box;
  animation: dsDtFadeIn 0.15s ease-out;
}
@keyframes dsDtFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── PILLAR CELL ROW ── */
.pillar-cell-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  gap: 3px;
}
.pillar-cell-num {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  margin: 0;
}
.pillar-cell-code {
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1;
  margin: 0;
  display: inline-flex;
  align-items: center;
}
.pillar-cell-char {
  font-family: 'Ma Shan Zheng Chinese Only', sans-serif;
  font-size: 19px;
  font-weight: 400;
}

/* ── PILLAR PANEL ── */
.pillar-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.pillar-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pillar-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.pillar-arrow-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--ink);
  line-height: 1;
}
.pillar-arrow-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: scale(1.08);
}
.pillar-arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.pillar-hex-box {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: white;
  padding: 8px 4px;
  transition: all 0.25s;
  gap: 4px;
}
.pillar-hex-box.pairing {
  border-color: var(--good-color);
  background: var(--good-bg);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}
.pillar-hex-box.partial {
  border-color: var(--warn-color);
  background: var(--warn-bg);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.pillar-stem-branch {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}
.pillar-hex-char {
  font-size: 16px;
  font-weight: 900;
  color: var(--ink);
  font-family: 'Ma Shan Zheng Chinese Only', serif;
}
.pillar-num-top {
  font-size: 18px;
  font-weight: 900;
  color: #000;
  line-height: 1;
}
.pillar-num-bot {
  font-size: 18px;
  font-weight: 900;
  color: #cc0000;
  line-height: 1;
}
.pillar-pair-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--good-color);
  color: white;
  letter-spacing: 0.04em;
  display: none;
}
.pillar-hex-box.pairing .pillar-pair-badge { display: inline-block; }

/* ── HOUR, MONTH, AND YEAR GRIDS ── */
.hour-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
  width: 100%;
  box-sizing: border-box;
}
#monthGrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
#yearGrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.hour-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 70px;
}
.hour-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(64,37,6,0.08); }
.hour-chip.good-hour {
  background: var(--good-bg);
  border-color: var(--good-color);
}
.hour-chip.partial-hour {
  background: var(--warn-bg);
  border-color: var(--warn-color);
}
.hour-chip.selected-hour {
  border-color: #15803d;
  background: var(--good-color);
  box-shadow: 0 2px 8px rgba(22,163,74,0.3);
}
.hour-chip-time {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}
.hour-chip-nums {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}
.hour-chip-top { font-size: 14px; font-weight: 900; color: #000; }
.hour-chip-bot { font-size: 14px; font-weight: 900; color: #cc0000; }

.hour-chip.selected-hour {
  border-color: #15803d;
  background: var(--good-color);
  box-shadow: 0 2px 8px rgba(22,163,74,0.3);
}

.hour-chip.selected-hour,
.hour-chip.selected-hour * {
  color: white !important;
}

.hour-chip-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--good-color);
  color: white;
  margin-top: 2px;
  opacity: 0;
}
.hour-chip.good-hour .hour-chip-badge { opacity: 1; }

/* ── JUMP CHIPS (MONTH/YEAR) ── */
.jump-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  min-height: 70px;
}
.hour-chip .cal-day-num,
.jump-chip .cal-day-num {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 3px;
  text-align: center;
}
.jump-chip:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(64,37,6,0.08); }
.jump-chip.selected {
  border-color: #15803d;
  background: var(--good-color);
  color: white;
  box-shadow: 0 2px 8px rgba(22,163,74,0.3);
}
.jump-chip.selected,
.jump-chip.selected * {
  color: white !important;
}

/* ── RESULT SUMMARY ── */
.result-summary {
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(to right, var(--good-bg), #ecfdf5);
  border: 1px solid var(--good-border);
  font-size: 13px;
  color: var(--good-color);
  font-weight: 700;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-summary.none {
  background: #f9f9f9;
  border-color: var(--line);
  color: var(--muted);
  font-weight: 400;
}
.result-summary .icon { font-size: 20px; }

/* ── HEXAGRAM GRAPHIC (Enlarged ~50%) ── */
.hex-graphic {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.2px;
  width: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}
.hex-line-yang {
  width: 100%;
  height: 3px;
  background: #1f1811;
  border-radius: 0.8px;
}
.hex-line-yin {
  display: flex;
  justify-content: space-between;
  width: 100%;
}
.hex-line-yin span {
  width: 43%;
  height: 3px;
  background: #1f1811;
  border-radius: 0.8px;
}
.hex-separator { height: 3px; }



/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
/* ==========================================
   FORMULA MODAL & BADGE STYLES
   ========================================== */

.ds-formula-btn {
  padding: 6px 12px;
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.ds-formula-btn:hover {
  background: rgba(124, 58, 237, 0.2);
}

.formula-badge {
  padding: 8px 12px;
  background: linear-gradient(135deg, #fefce8, #fef9c3);
  border: 1px solid #fde047;
  border-radius: 8px;
  color: #854d0e;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(234, 179, 8, 0.15);
  animation: glow 2s infinite alternate;
}

@keyframes glow {
  from { box-shadow: 0 2px 6px rgba(234, 179, 8, 0.15); }
  to { box-shadow: 0 4px 12px rgba(234, 179, 8, 0.3); }
}

/* Modal styles */
.ds-modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.ds-modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.ds-modal-card {
  background: white;
  width: 90%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}
.ds-modal-backdrop.show .ds-modal-card {
  transform: translateY(0);
}

.ds-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: #fdf6ec;
  border-bottom: 1px solid #eddcc1;
}
.ds-modal-title {
  font-size: 15px;
  font-weight: 800;
  color: #9c6514;
  margin: 0;
}
.ds-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #9c6514;
  cursor: pointer;
}

.ds-modal-body {
  padding: 16px;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 13px;
  color: #4a4a4a;
  line-height: 1.6;
}
.ds-modal-body h4 {
  color: #1f1811;
  font-size: 14px;
  margin: 12px 0 6px 0;
}
.ds-modal-body ul {
  padding-left: 20px;
  margin-bottom: 12px;
}
.ds-modal-body li {
  margin-bottom: 6px;
}
.highlight-blue {
  color: #1d4ed8;
  font-weight: 700;
}
.highlight-green {
  color: #16a34a;
  font-weight: 700;
}

/* Search Result Styles */
.search-result-item {
  background: white;
  border: 1px solid #eddcc1;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.search-result-item:hover {
  border-color: #fde047;
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.15);
}
.search-result-date {
  font-size: 15px;
  font-weight: 800;
  color: #1f1811;
  margin-bottom: 8px;
}
.search-result-hour {
  display: inline-block;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  margin-bottom: 6px;
}

.search-result-pillars {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  background: #fffaf4;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #eddcc1;
  justify-content: space-between;
}
.sr-pillar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  font-size: 12px;
  font-weight: 800;
  gap: 4px;
}
.sr-pillar .sr-top { color: #000; }
.sr-pillar .sr-bot { color: #cc0000; }

/* Find Branches (សាហៈ) Table Styles */
.fb-result-item {
  border-left: 4px solid #7c3aed;
  background: #ffffff;
  transition: all 0.2s ease-in-out;
}
.fb-result-item:hover {
  border-color: #6d28d9;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.15);
  transform: translateY(-1px);
}
.fb-pillars-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  text-align: center;
  font-size: 12px;
  border: 1px solid #eddcc1;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 6px;
}
.fb-pillars-table th {
  background: #fdf6ec;
  color: #786650;
  font-weight: 800;
  padding: 6px 4px;
  border: 1px solid #eddcc1;
  font-size: 11px;
}
.fb-pillars-table td {
  padding: 6px 4px;
  border: 1px solid #eddcc1;
  vertical-align: middle;
}
.fb-kv-highlight {
  background: #fdf8eb !important;
}
.t-star.khong {
  color: #866d49;
  background: #f3e9d8;
  border: 1px solid #e7d7bf;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  display: inline-block;
}

/* ── COMPREHENSIVE RESPONSIVE DESIGN FOR MOBILE ── */
@media (max-width: 640px) {
  /* Layout & Cards */
  .ds-shell {
    padding: 10px 8px 80px;
    gap: 12px;
  }
  .ds-card {
    padding: 12px 10px;
    border-radius: 14px;
  }
  .ds-card-title,
  #dsCalendarTitle,
  #dsHourSelectionTitle,
  #dsMonthSelectionTitle,
  #dsYearSelectionTitle,
  #dsDateSearchToolsTitle,
  #dsFourPillarsTitle {
    font-size: 15.5px !important;
    margin-bottom: 10px;
  }

  /* Top Bar */
  .ds-topbar {
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .ds-title {
    font-size: 15px;
    min-width: 120px;
  }
  .ds-back-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .ds-lang-toggle {
    padding: 5px 8px;
    gap: 5px;
  }
  .ds-lang-checkbox {
    width: 15px;
    height: 15px;
  }
  .ds-lang-label {
    font-size: 11px;
  }
  .ds-formula-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Four Pillars Header on Mobile */
  .ds-pillars-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px;
  }
  .ds-datetime-container {
    width: 100% !important;
    margin-left: 0 !important;
  }
  .ds-datetime-picker-wrap {
    margin-left: 0;
    width: 100% !important;
    display: flex;
    justify-content: center;
    padding: 6px 8px;
    min-height: 36px;
    border-radius: 8px;
    box-sizing: border-box;
  }
  .ds-datetime-display {
    font-size: 13.5px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ds-dt-dropdown {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    box-sizing: border-box;
  }

  /* Four Pillars Columns on Mobile */
  .pillar-panel {
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }
  .pillar-col {
    min-width: 0;
    gap: 3px;
  }
  .pillar-label {
    font-size: 11px;
    font-weight: 800;
  }
  .pillar-arrow-btn {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }
  .pillar-hex-box {
    min-height: 80px;
    padding: 6px 1px;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
  }
  .pillar-cell-row {
    gap: 2px;
    max-width: 100%;
  }
  .pillar-cell-num {
    font-size: 15.5px !important;
    font-weight: 900 !important;
  }
  .pillar-cell-code {
    font-size: 12.5px !important;
    font-weight: 800 !important;
  }
  .pillar-cell-char {
    font-size: 16.5px !important;
  }

  /* Calendar on Mobile */
  .cal-grid {
    gap: 2px;
    width: 100%;
    box-sizing: border-box;
  }
  .cal-header {
    font-size: 11.5px !important;
    font-weight: 800;
    padding: 4px 0;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
    letter-spacing: -0.3px;
  }
  .cal-day {
    min-height: 54px;
    padding: 3px 1px;
    border-radius: 6px;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
  .cal-day-num {
    font-size: 14.5px !important;
    font-weight: 800 !important;
    margin-bottom: 1px !important;
  }
  .cal-day-row {
    gap: 2px;
    max-width: 100%;
  }
  .cal-day-row.top-row .top,
  .cal-day-row.bot-row .bot {
    font-size: 15px !important;
    font-weight: 900 !important;
  }
  .cal-day-row .char {
    font-size: 19px !important;
  }

  /* Hour Grid on Mobile: 4 columns (divides into 3 rows) */
  .hour-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }
  .hour-chip {
    padding: 6px 2px;
    min-height: 58px;
    border-radius: 8px;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }
  .hour-chip .cal-day-num,
  #monthGrid .jump-chip .cal-day-num,
  #yearGrid .jump-chip .cal-day-num {
    font-size: 12.5px !important;
    font-weight: 800;
    margin-bottom: 2px;
  }
  .hour-chip-time {
    font-size: 11px;
    font-weight: 800;
  }
  .hour-chip-top, .hour-chip-bot {
    font-size: 13.5px;
    font-weight: 900;
  }
  .hour-chip-badge {
    font-size: 8px;
    padding: 1px 3px;
  }

  /* Month Selection Grid: 4 columns on mobile (divides into 3 rows) */
  #monthGrid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }
  #monthGrid .jump-chip {
    padding: 6px 2px;
    font-size: 12px;
    font-weight: 800;
    min-height: 58px;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  /* Year Selection Grid: 4 columns on mobile (divides into 3 rows) */
  #yearGrid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }
  #yearGrid .jump-chip {
    padding: 6px 2px;
    font-size: 12.5px;
    font-weight: 800;
    min-height: 58px;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  /* Modals on Mobile */
  .ds-modal-card {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px auto;
    border-radius: 14px;
  }
  .ds-modal-header {
    padding: 12px 14px;
  }
  .ds-modal-body {
    padding: 12px 8px !important;
    max-height: 80vh;
  }
  .fb-pillars-table th {
    padding: 6px 2px;
    font-size: 11px;
  }
  .fb-pillars-table td {
    padding: 6px 2px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  /* Extra narrow phones */
  .cal-header {
    font-size: 9.5px !important;
    letter-spacing: -0.5px;
  }
  .cal-day {
    min-height: 48px;
    padding: 2px 0;
  }
  .cal-day-num {
    font-size: 12px !important;
  }
  .cal-day-row.top-row .top,
  .cal-day-row.bot-row .bot {
    font-size: 12px !important;
  }
  .cal-day-row .char {
    font-size: 15px !important;
  }
  .pillar-cell-row {
    gap: 1px;
  }
  .pillar-cell-num {
    font-size: 12px !important;
  }
  .pillar-cell-code {
    font-size: 10px !important;
  }
  .pillar-cell-char {
    font-size: 13px !important;
  }
  .pillar-arrow-btn {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
  .hour-grid,
  #monthGrid,
  #yearGrid {
    gap: 3px !important;
  }
  .hour-chip,
  .jump-chip {
    padding: 5px 1px !important;
    min-height: 54px !important;
  }
  .hour-chip .cal-day-num,
  #monthGrid .jump-chip .cal-day-num,
  #yearGrid .jump-chip .cal-day-num {
    font-size: 11px !important;
  }
}

/* ==========================================
   FIXED MOBILE BOTTOM NAVIGATION BAR
   ========================================== */
body {
  padding-bottom: 76px !important;
}

.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 62px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 9999;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

.bottom-nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  padding: 4px 2px 2px 2px;
  color: #64748b;
  transition: color 0.15s ease, transform 0.15s ease;
  text-decoration: none;
  font-family: inherit;
  min-width: 0;
}

.bottom-nav-item:active {
  transform: scale(0.93);
}

.bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  margin-bottom: 2px;
  color: inherit;
}

.bottom-nav-label {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: #64748b;
}

.bottom-nav-item.active {
  color: #16a34a;
}

.bottom-nav-item.active .bottom-nav-label {
  font-weight: 800;
  color: #16a34a;
}

.bottom-nav-indicator {
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: transparent;
  border-radius: 3px 3px 0 0;
  transition: background 0.2s ease;
}

.bottom-nav-item.active .bottom-nav-indicator {
  background: #16a34a;
}

.bottom-nav-bazi-pill {
  font-size: 11px;
  font-weight: 900;
  padding: 1px 7px;
  border: 1.5px solid #16a34a;
  border-radius: 7px;
  letter-spacing: 0.02em;
  line-height: 1.15;
  display: inline-block;
  color: #16a34a;
  background: #dcfce7;
}

@media print {
  .app-bottom-nav {
    display: none !important;
  }
  body {
    padding-bottom: 0 !important;
  }
}



