/* "ตัวเลือก": one screen, no page scroll. Desktop = 3-column grid of compact cards; mobile = compact rows. */
.op-view { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden;
  height: calc(100vh - var(--op-top, 66px) - 26px); height: calc(100dvh - var(--op-top, 66px) - 26px); }
.op-head .btn { min-height: 40px; }
.op-note { margin-top: -4px; }
.op-view .error-box { padding: 6px 12px; font-size: 13px; }
.op-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-content: start; align-items: stretch; }
.op-group { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px 12px 12px; }
.op-title { font-weight: 700; font-size: 15px; }
.op-group .seg { flex-wrap: wrap; }
.op-group .seg > button { min-height: 40px; padding: 0 12px; font-size: 14px; }
.op-stack { flex-direction: column; } .op-stack > button { text-align: left; }
.op-group .small { line-height: 1.3; }
.op-check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; }
.op-check input { width: 22px; height: 22px; flex: none; }
@media (max-width: 1100px) { .op-group .seg > button { padding: 0 8px; font-size: 13px; } }
@media (min-width: 901px) and (max-height: 700px) {
  .op-group { gap: 4px; padding: 6px 10px 8px; }
  .op-stack > button { min-height: 36px; font-size: 13px; padding: 0 10px; }
}

/* Mobile (≤ 900px): each group is a tight row — title on the left, segmented buttons on the right; the long
   year-start group and the display group put the title on its own line. */
@media (max-width: 900px) {
  .page:has(> .op-view) { padding-top: 6px; padding-bottom: calc(var(--tabbar-h, 58px) + env(safe-area-inset-bottom) + 6px); gap: 0; }
  .op-view { gap: 6px;
    height: calc(100vh - var(--op-top, 60px) - var(--tabbar-h, 58px) - env(safe-area-inset-bottom) - 6px);
    height: calc(100dvh - var(--op-top, 60px) - var(--tabbar-h, 58px) - env(safe-area-inset-bottom) - 6px); }
  .op-head { flex-wrap: nowrap; gap: 8px; }
  .op-head h1 { font-size: 17px; }
  .op-head .btn { padding: 0 10px; font-size: 13px; white-space: nowrap; }
  .op-note { margin-top: 0; font-size: 12px; line-height: 1.25; }
  .op-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .op-group { display: grid; grid-template-columns: minmax(84px, 36%) minmax(0, 1fr); align-items: center; column-gap: 8px; row-gap: 2px; padding: 4px 8px; border-radius: 8px; }
  .op-title { font-size: 13px; line-height: 1.2; }
  .op-group .seg { display: flex; flex-wrap: nowrap; width: 100%; gap: 4px; }
  .op-group .seg > button { flex: 1 1 0; min-width: 0; padding: 0 4px; min-height: 40px; font-size: 13px; line-height: 1.15; }
  .op-group:has(.op-stack), .op-wide { grid-template-columns: minmax(0, 1fr); }
  .op-group .op-stack { flex-direction: row; }
  .op-group .op-stack > button { flex: 1 1 0; width: auto; padding: 2px 4px; text-align: center; font-size: 12px; line-height: 1.2; }
  .op-group .small { grid-column: 1 / -1; font-size: 12px; line-height: 1.2; }
  .op-check { min-height: 40px; font-size: 13px; }
}

/* Merged page (ดวงBazi + โหงวเฮ้ง): section headings span the grid; face-only controls (face/views/optionform.js look). */
.op-sec { grid-column: 1 / -1; font-size: 16px; margin: 4px 0 -4px; display: flex; align-items: baseline; gap: 8px; }
.op-sec:first-child { margin-top: 0; }
.op-face-note { color: var(--accent); font-weight: 600; }
.op-select { min-height: 40px; }
.op-sub { font-size: 14px; }
.op-themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.op-theme { display: grid; grid-template-columns: repeat(6, 1fr); height: 44px; min-height: 44px; border: 2px solid var(--line); border-radius: 6px; padding: 0; overflow: hidden; background: var(--card); }
.op-theme[aria-pressed="true"] { border-color: var(--accent); }
.op-but { width: 48px; height: 48px; border: 2px solid var(--line); border-radius: 8px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; }
.op-but[aria-pressed="true"] { border-color: var(--accent); }
.op-but img { width: 30px; height: 30px; }
.op-gold { width: 28px; height: 28px; border-radius: 6px; background: var(--fav); }
.op-buts { gap: 6px; }
@media (max-width: 900px) {
  .op-sec { font-size: 14px; margin: 4px 0 0; }
  .op-group:has(.op-select), .op-group:has(.op-themes), .op-group:has(.op-buts) { grid-template-columns: minmax(0, 1fr); }
  .op-themes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .op-theme { height: 44px; }
}
