:root {
    --jh-maroon-950: #260d10;
    --jh-maroon-900: #351115;
    --jh-maroon-800: #4a171b;
    --jh-maroon-700: #67232a;
    --jh-saffron: #d9a520;
    --jh-saffron-light: #f2d77d;
    --jh-parchment: #f7f0df;
    --jh-parchment-deep: #eadcc0;
    --jh-ink: #382b27;
    --jh-muted: #786a60;
    --jh-gold: #b78417;
    --jh-gold-deep: #7d570d;
    --jh-canvas: #eee3cf;
    --jh-line: rgba(125, 87, 13, 0.19);
    --jh-shadow: 0 18px 44px rgba(48, 24, 17, 0.12);
}

body {
    background-color: var(--jh-canvas) !important;
    background-image:
        radial-gradient(ellipse at 50% -8%, rgba(91, 28, 35, 0.25), transparent 36%),
        radial-gradient(circle at 7% 24%, rgba(183, 134, 43, 0.10), transparent 23%),
        radial-gradient(circle at 93% 64%, rgba(91, 28, 35, 0.065), transparent 28%),
        linear-gradient(145deg, #eadcc5 0%, #f5eddf 44%, #eee1cb 100%) !important;
    background-size: cover !important;
    background-attachment: fixed !important;
}

.file-protocol-notice {
    position: sticky;
    top: 0;
    z-index: 10040;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    color: #fff4d8;
    background: #4c271e;
    box-shadow: 0 8px 24px rgba(38, 13, 16, 0.24);
}

.file-protocol-notice.hidden { display: none; }
.file-protocol-notice > div { display: grid; gap: 2px; }
.file-protocol-notice strong { font-size: 0.76rem; }
.file-protocol-notice span { color: rgba(255, 244, 216, 0.74); font-size: 0.62rem; }
.file-protocol-notice button {
    flex: none;
    width: 32px;
    height: 32px;
    color: inherit;
    background: rgba(255, 255, 255, 0.10);
    border: 0;
    border-radius: 10px;
    font-size: 1rem;
}

.sacred-atmosphere {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    contain: paint;
    pointer-events: none;
}

.sacred-atmosphere::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.28;
    background-image:
        radial-gradient(circle, rgba(70, 39, 28, 0.36) 0.65px, transparent 0.9px),
        radial-gradient(circle, rgba(183, 134, 43, 0.28) 0.5px, transparent 0.75px);
    background-position: 0 0, 4px 6px;
    background-size: 9px 9px, 13px 13px;
    mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
}

.sacred-orbit {
    position: absolute;
    left: 50%;
    border: 1px solid rgba(217, 165, 32, 0.11);
    border-radius: 50%;
    transform: translateX(-50%);
    will-change: opacity;
}

.sacred-orbit::before,
.sacred-orbit::after {
    content: '';
    position: absolute;
    inset: 9%;
    border: 1px dashed rgba(103, 35, 42, 0.08);
    border-radius: inherit;
}

.sacred-orbit::after {
    inset: 22%;
    border-style: solid;
    border-color: rgba(217, 165, 32, 0.08);
}

.sacred-orbit-one {
    top: -270px;
    width: 620px;
    height: 620px;
    animation: sacred-orbit-turn 70s linear infinite;
}

.sacred-orbit-two {
    right: -240px;
    bottom: 4%;
    left: auto;
    width: 460px;
    height: 460px;
    opacity: 0.55;
    transform: none;
    animation: sacred-orbit-turn-reverse 90s linear infinite;
}

.sacred-ray {
    position: absolute;
    top: -360px;
    left: 50%;
    width: 760px;
    height: 760px;
    background: repeating-conic-gradient(
        from 0deg,
        transparent 0deg 11deg,
        rgba(217, 165, 32, 0.035) 11deg 12deg
    );
    border-radius: 50%;
    transform: translateX(-50%);
    animation: sacred-breathe 9s ease-in-out infinite;
    will-change: transform, opacity;
}

.gold-particles {
    opacity: 0.12 !important;
}

.app-shell {
    z-index: 2;
}

.sacred-header {
    isolation: isolate;
    position: relative;
    overflow: visible !important;
    padding: 26px 22px 23px;
    color: #fff7df;
    background:
        radial-gradient(circle at 50% -25%, rgba(242, 215, 125, 0.24), transparent 48%),
        linear-gradient(145deg, var(--jh-maroon-800), var(--jh-maroon-950));
    border: 1px solid rgba(242, 215, 125, 0.32);
    border-radius: 26px;
    box-shadow:
        0 24px 55px rgba(38, 13, 16, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 0 0 6px rgba(255, 255, 255, 0.025);
}

.sacred-header::before,
.sacred-header::after {
    content: '๙';
    position: absolute;
    top: 12px;
    z-index: 1;
    color: rgba(242, 215, 125, 0.30);
    font-family: Georgia, serif;
    font-size: 14px;
}

.sacred-header::before { left: 15px; }
.sacred-header::after { right: 15px; }

.header-mandala {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 0;
    width: 530px;
    height: 530px;
    background:
        repeating-conic-gradient(from 0deg, rgba(242, 215, 125, 0.06) 0deg 2deg, transparent 2deg 15deg),
        radial-gradient(circle, transparent 20%, rgba(242, 215, 125, 0.10) 21% 22%, transparent 23% 40%, rgba(242, 215, 125, 0.07) 41% 42%, transparent 43% 58%, rgba(242, 215, 125, 0.04) 59% 65%, transparent 68%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    filter: blur(1.2px);
    opacity: 0.82;
    box-shadow: 0 0 35px rgba(242, 215, 125, 0.05);
    animation: sacred-orbit-turn 50s linear infinite;
}

.brand-seal {
    display: grid;
    width: 34px;
    height: 34px;
    margin: 0 auto 8px;
    place-items: center;
    color: var(--jh-maroon-900);
    background: linear-gradient(145deg, #f8e6a6, #c99318);
    border: 1px solid #ffeeba;
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(242, 215, 125, 0.08), 0 8px 22px rgba(0, 0, 0, 0.22);
    font-size: 17px;
    font-weight: 700;
}

.header-kicker {
    margin: 0 0 3px;
    color: rgba(255, 247, 223, 0.58);
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.sacred-brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.sacred-header .brand-title {
    font-family: 'Cinzel Decorative', 'Marcellus', Georgia, serif !important;
    font-weight: 900 !important;
    margin: 0 !important;
    color: #fff3cc !important;
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: #fff3cc;
    /* Avoid Safari rasterizing the animated, clipped text as a blurred rectangle. */
    filter: none !important;
    text-shadow:
        0 2px 0 rgba(61, 20, 16, 0.96),
        0 4px 5px rgba(18, 5, 6, 0.56) !important;
    -webkit-text-stroke: 0.55px #dca633;
    font-size: clamp(2rem, 8vw, 2.85rem) !important;
    letter-spacing: 0.045em !important;
    line-height: 1.08;
    -webkit-font-smoothing: antialiased;
    will-change: transform;
}

.brand-flourish {
    color: #e6bb47;
    font-size: 1.25rem;
    opacity: 0.74;
}

.brand-flourish-mirror {
    transform: scaleX(-1);
}

.sacred-header .brand-subtitle {
    margin-top: 7px;
    color: rgba(255, 247, 223, 0.82) !important;
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.12em;
}

.header-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 13px auto 9px;
}

.header-divider span {
    width: 42px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(242, 215, 125, 0.65));
}

.header-divider span:last-child {
    transform: scaleX(-1);
}

.header-divider i {
    width: 5px;
    height: 5px;
    background: #e2b13b;
    border: 1px solid #ffe9a4;
    transform: rotate(45deg);
}

.header-blessing {
    margin: 0;
    color: rgba(255, 239, 190, 0.82);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 2px rgba(24, 7, 7, 0.72);
}

.app-tabs {
    position: relative;
    z-index: 2;
    padding: 5px !important;
    background: rgba(255, 252, 245, 0.94) !important;
    border-color: rgba(183, 134, 43, 0.32) !important;
    box-shadow:
        0 12px 28px rgba(48, 24, 17, 0.12),
        0 -6px 20px rgba(242, 215, 125, 0.22) !important;
    backdrop-filter: blur(10px);
}

.app-tabs .tab-btn {
    color: #76665a !important;
}

.app-tabs .tab-btn::before {
    background: linear-gradient(145deg, #5d3024, #3b1d17) !important;
}

.app-tabs .tab-btn:hover:not(.active) {
    color: #5d3024 !important;
    background: rgba(93, 48, 36, 0.07) !important;
}

.app-tabs .tab-btn.active {
    color: #fff8e7 !important;
    background: linear-gradient(145deg, #5d3024, #3b1d17) !important;
    box-shadow: 0 7px 18px rgba(48, 24, 17, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
}

.slip-meta-card {
    overflow: hidden;
    padding: 0 !important;
    background: rgba(250, 246, 235, 0.90) !important;
    border-color: rgba(125, 87, 13, 0.20) !important;
    border-radius: 18px !important;
    box-shadow: 0 12px 30px rgba(48, 24, 17, 0.08) !important;
}

.slip-meta-toggle {
    display: grid;
    width: 100%;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    color: var(--jh-ink);
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.slip-meta-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #f3d77d;
    background: linear-gradient(145deg, var(--jh-maroon-700), var(--jh-maroon-950));
    border: 1px solid rgba(217, 165, 32, 0.34);
    border-radius: 12px;
    box-shadow: 0 7px 16px rgba(53, 17, 21, 0.18);
    transition: transform 0.35s ease-out;
}

.slip-meta-toggle:hover .slip-meta-icon,
.slip-meta-toggle[aria-expanded='true'] .slip-meta-icon {
    transform: rotate(45deg);
}

.slip-meta-toggle-copy {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.slip-meta-card .slip-meta-eyebrow {
    color: var(--jh-gold);
    font-size: 0.62rem;
}

.slip-meta-title {
    font-size: 0.86rem;
    font-weight: 700;
}

.slip-meta-summary {
    overflow: hidden;
    color: var(--jh-muted);
    font-size: 0.68rem;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slip-meta-card.has-data .slip-meta-summary {
    color: var(--jh-gold-deep);
    font-weight: 600;
}

.slip-meta-card.has-data .slip-meta-icon {
    box-shadow: 0 0 0 4px rgba(217, 165, 32, 0.10), 0 7px 16px rgba(53, 17, 21, 0.18);
}

.slip-meta-chevron {
    width: 9px;
    height: 9px;
    margin-right: 4px;
    border-right: 2px solid #9a866d;
    border-bottom: 2px solid #9a866d;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.35s ease-out;
}

.slip-meta-toggle[aria-expanded='true'] .slip-meta-chevron {
    transform: rotate(225deg) translate(-2px, -2px);
}

.slip-meta-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    border-top: 1px solid transparent;
    transition: grid-template-rows 0.38s ease-out, opacity 0.30s ease-out, border-color 0.30s ease-out;
}

.slip-meta-panel-inner {
    min-height: 0;
    overflow: hidden;
}

.slip-meta-card.is-open .slip-meta-panel {
    grid-template-rows: 1fr;
    opacity: 1;
    border-color: rgba(125, 87, 13, 0.14);
}

.slip-meta-grid {
    padding: 15px 15px 10px;
}

.slip-field input {
    background: rgba(255, 253, 247, 0.88);
    border-color: rgba(125, 87, 13, 0.22);
}

.slip-meta-footer button {
    color: var(--jh-maroon-700);
    background: #fff8e8;
    border: 1px solid rgba(125, 87, 13, 0.23);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.draw-date-choice {
    color: #735e42;
    background: rgba(255, 253, 247, 0.82);
    border: 1px solid rgba(125, 87, 13, 0.22);
    box-shadow: 0 3px 10px rgba(76, 39, 30, 0.04);
    transition: color 0.28s ease-out, background 0.28s ease-out,
        border-color 0.28s ease-out, transform 0.28s ease-out;
}

.draw-date-choice:hover {
    color: var(--jh-maroon-800);
    border-color: rgba(183, 132, 23, 0.52);
    transform: translateY(-1px);
}

.draw-date-choice:active { transform: translateY(1px) scale(0.985); }

.draw-date-choice.is-recommended::after {
    content: 'แนะนำ';
    position: absolute;
    top: 8px;
    right: 9px;
    padding: 2px 6px;
    color: #93691b;
    background: #f8ecc8;
    border-radius: 999px;
    font-size: 0.52rem;
    font-weight: 700;
}

.draw-date-choice.active {
    color: #fff7df;
    background: linear-gradient(135deg, #6b3024, #4b211a);
    border-color: #8d5c2b;
}

.draw-date-choice.active::after {
    color: #5a2a20;
    background: #f4d98e;
}

.draw-date-calendar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    color: #7b551d;
    background: #f8edcc;
    border-radius: 9px;
    font-size: 1rem;
}

.slip-meta-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 15px 14px;
    color: #8a7a6a;
    font-size: 0.64rem;
}

.slip-meta-footer button {
    padding: 7px 9px;
}

.entry-heading {
    display: grid;
    justify-items: center;
    margin: 0 0 22px;
    text-align: center;
}

.entry-heading > span {
    margin-bottom: 5px;
    padding: 4px 9px;
    color: #f7df95;
    background: var(--jh-maroon-800);
    border: 1px solid rgba(217, 165, 32, 0.28);
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.entry-heading h3 {
    margin: 0;
    color: var(--jh-ink);
    font-size: 1.08rem;
    font-weight: 700;
}

.entry-heading p {
    margin: 4px 0 0;
    color: var(--jh-muted);
    font-size: 0.72rem;
}

.card {
    position: relative;
    background:
        linear-gradient(145deg, rgba(255, 254, 250, 0.97), rgba(248, 240, 223, 0.95)) !important;
    border-color: rgba(125, 87, 13, 0.18) !important;
    box-shadow: 0 16px 40px rgba(48, 24, 17, 0.10) !important;
}

.card::before {
    background: linear-gradient(90deg, transparent, rgba(183, 132, 23, 0.72), transparent) !important;
}

.hero-input-container {
    background: linear-gradient(180deg, #fffdf8, #fbf5e8) !important;
    border: 2px solid #b78417 !important;
    border-radius: 18px !important;
    box-shadow: 0 0 0 1px rgba(183, 132, 23, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.82), inset 0 -10px 28px rgba(183, 132, 23, 0.035) !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
}

.hero-input-container label,
.hero-input-container .desktop-hint {
    color: #8a6758 !important;
}

.hero-input-container input[type="tel"] {
    color: #4c271e !important;
    background: transparent !important;
}

.hero-input-container input[type="tel"]::placeholder {
    color: #b39484 !important;
}

.hero-input-container:hover,
.hero-input-container.input-focused {
    background: linear-gradient(180deg, #fffefb, #fbf3e3) !important;
    border: 2px solid #95630d !important;
    box-shadow: 0 0 0 3px rgba(183, 132, 23, 0.10), 0 8px 22px rgba(70, 39, 28, 0.10) !important;
}

.hero-input-container:active {
    border: 2px solid #8b6117 !important;
    box-shadow: 0 0 0 2px rgba(183, 132, 23, 0.09) !important;
}

.gold-btn {
    color: #fff8e7 !important;
    background: linear-gradient(135deg, #5d3024 0%, #4c271e 55%, #351914 100%) !important;
    border: 1px solid rgba(203, 165, 86, 0.55) !important;
    box-shadow: 0 11px 24px rgba(48, 24, 17, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.13) !important;
}

.choice-chip.active {
    color: #fff4d2 !important;
    background: linear-gradient(145deg, #5d3024, #3b1d17) !important;
    border-color: rgba(185, 144, 61, 0.45) !important;
    box-shadow: 0 3px 7px rgba(48, 24, 17, 0.18), 0 10px 22px rgba(48, 24, 17, 0.10) !important;
}

.choice-chips {
    margin: 0 !important;
    padding: 8px 4px 14px !important;
    overflow: visible !important;
}

#govTypeChips,
#ugTypeChips {
    display: grid !important;
    align-items: stretch;
    width: 100%;
    gap: 10px !important;
}

#govTypeChips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#ugTypeChips {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

#ugTypeChips > .choice-chip {
    grid-column: span 2;
}

#ugTypeChips > .choice-chip:nth-child(4) {
    grid-column: 2 / span 2;
}

#ugTypeChips > .choice-chip:nth-child(5) {
    grid-column: 4 / span 2;
}

#govTypeChips > .choice-chip,
#ugTypeChips > .choice-chip {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 9px 8px;
    white-space: normal;
    line-height: 1.3;
}

.choice-chip.chip-bon:not(.active) {
    color: #752a31 !important;
    background: #fff8f3 !important;
    border-color: #dec4bd !important;
}

.choice-chip.chip-lang:not(.active) {
    color: #304b5d !important;
    background: #f5f8f9 !important;
    border-color: #c8d5dc !important;
}

.choice-chip.chip-lang.active {
    color: #fff4d2 !important;
    background: linear-gradient(145deg, #5d3024, #3b1d17) !important;
    border-color: rgba(185, 144, 61, 0.45) !important;
    box-shadow: 0 3px 7px rgba(48, 24, 17, 0.18), 0 10px 22px rgba(48, 24, 17, 0.10) !important;
}

.filter-strip {
    margin: -4px -8px -8px;
    padding: 8px 10px 12px !important;
    scroll-padding-inline: 10px;
}

.type-bon {
    color: #752a31 !important;
    background: #fff4ef !important;
    border-color: #dec4bd !important;
}

.type-lang {
    color: #304b5d !important;
    background: #f1f6f8 !important;
    border-color: #c8d5dc !important;
}

.filter-chip.active {
    color: #fff8df !important;
    background: #4c271e !important;
    border-color: #7d4b3c !important;
}

.chip-selected {
    color: #fff7df !important;
    background: #4c271e !important;
    border-color: #7d4b3c !important;
}

#btnShare,
#pwaInstallBanner button:last-child,
.preview-selection .bg-gold-500 {
    color: #fff8e7 !important;
    background: linear-gradient(135deg, #5d3024, #351914) !important;
}

#offlineIndicator {
    background: #752a31 !important;
}

#confirmModalContent .text-red-500 {
    color: #8c3035 !important;
}

.danger-btn {
    color: #7b3438;
    background: rgba(255, 253, 248, 0.82);
    border: 1px solid #d9b9b5;
}

.danger-btn:hover {
    color: #65252b;
    background: #fbefed;
    border-color: #b87978;
}

.modal-overlay {
    background: rgba(32, 12, 15, 0.72) !important;
}

.modal-content {
    background: #fbf7ef !important;
    border-color: #d8c5a5 !important;
    box-shadow: 0 24px 65px rgba(25, 7, 10, 0.34) !important;
}

.modal-mode-btn {
    color: #746860 !important;
}

.modal-mode-btn.active {
    color: #5f2027 !important;
    background: #fffdf8 !important;
    box-shadow: 0 2px 8px rgba(48, 24, 17, 0.11) !important;
}

#toast {
    color: #fff7df;
    background: linear-gradient(135deg, #511921, #2c0d12) !important;
    border: 1px solid rgba(224, 183, 77, 0.34);
    box-shadow: 0 10px 28px rgba(38, 13, 16, 0.32) !important;
}

.numpad-overlay {
    background: rgba(32, 12, 15, 0.58) !important;
    z-index: 10020 !important;
}

.numpad-container {
    background: linear-gradient(180deg, #fffdf8, #f3e9d7) !important;
    border: 1px solid rgba(93, 48, 36, 0.34) !important;
    box-shadow: 0 24px 64px rgba(38, 13, 16, 0.30), 0 0 0 1px rgba(255, 255, 255, 0.55) !important;
}

.numpad-display {
    background: #f7efdf !important;
    border-color: #d8c6a7 !important;
}

.numpad-display .text-3xl {
    color: #4b171d !important;
}

.numpad-display .text-sm {
    color: #7e6e60 !important;
}

.numpad-btn {
    color: #3c302b !important;
    background: #fffdf9 !important;
    border-color: #ddcdb2 !important;
    box-shadow: 0 3px 0 #cbb795, 0 7px 13px rgba(48, 24, 17, 0.08) !important;
}

.numpad-btn:active {
    background: #f0e4cf !important;
    box-shadow: 0 1px 0 #cbb795 !important;
}

.numpad-special {
    color: #6f2a30 !important;
    background: #f7ebe7 !important;
}

.numpad-actions button:last-child,
.numpad-confirm-btn {
    color: #fff7df !important;
    background: linear-gradient(135deg, #5d3024, #351914) !important;
    box-shadow: 0 4px 0 #26110d !important;
}

.numpad-actions button:first-child {
    color: #5d3024 !important;
    background: #fffaf5 !important;
    border-color: #d7bdae !important;
    box-shadow: 0 3px 0 #cbb2a4, 0 6px 11px rgba(48, 24, 17, 0.07) !important;
}

#toast {
    z-index: 10030 !important;
}

.quick-price-btn {
    color: #5d3024 !important;
    background: #f7eee5 !important;
    border: 1px solid #d7bdae !important;
    border-radius: 11px;
    box-shadow: 0 3px 0 #cbb2a4, 0 6px 11px rgba(48, 24, 17, 0.07) !important;
}

.quick-price-btn:active {
    color: #fff7df !important;
    background: #4c271e !important;
    box-shadow: 0 1px 0 #351914 !important;
    transform: translateY(2px) scale(0.97);
}

.glab-locked {
    color: #fff7df !important;
    background: linear-gradient(135deg, #5d3024, #351914) !important;
    border-color: #7d4b3c !important;
}

#pwaInstallBanner {
    background: linear-gradient(145deg, #fffdf8, #f3e8d4) !important;
    border-color: #cda95f !important;
}

.pwa-install-banner {
    position: fixed;
    right: auto;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: 50%;
    z-index: 60;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: min(720px, calc(100vw - 48px));
    padding: 14px;
    gap: 18px;
    overflow: hidden;
    border: 1px solid #cda95f;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(48, 24, 17, 0.22), 0 3px 10px rgba(48, 24, 17, 0.08);
    opacity: 0;
    transform: translate(-50%, calc(100% + 36px));
    transition: opacity 0.32s ease-out, transform 0.36s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0.32s ease-out;
    visibility: hidden;
}

.pwa-install-banner.hidden { display: none; }

.pwa-install-banner.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
    visibility: visible;
}

.pwa-install-main {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.pwa-install-copy {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.pwa-install-copy > span {
    color: #a27420;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.025em;
}

.pwa-install-copy strong {
    color: #3f2921;
    font-size: 1rem;
    line-height: 1.35;
}

.pwa-install-copy p {
    overflow: hidden;
    margin: 1px 0 0;
    color: #786e66;
    font-size: 0.78rem;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pwa-install-actions {
    display: grid;
    grid-template-columns: auto auto;
    gap: 8px;
}

.pwa-install-actions button {
    min-height: 44px;
    padding: 9px 16px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 700;
    transition: color 0.28s ease-out, background 0.28s ease-out, border-color 0.28s ease-out,
        transform 0.28s ease-out;
}

.pwa-install-later {
    min-width: 92px;
    color: #6f6259;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(92, 65, 50, 0.17);
}

.pwa-install-later span {
    margin-right: 4px;
    font-size: 1rem;
    line-height: 0;
}

.pwa-install-confirm {
    min-width: 104px;
    color: #fff8e7;
    background: linear-gradient(135deg, #5d3024, #351914);
    border: 1px solid #7d4b3c;
    box-shadow: 0 7px 16px rgba(53, 17, 21, 0.19);
}

.pwa-install-actions button:hover { transform: translateY(-1px); }
.pwa-install-actions button:active { transform: translateY(1px) scale(0.98); }

body.numpad-open #pwaInstallBanner {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translate(-50%, 24px) !important;
}

.app-install-icon {
    flex: none;
    border: 1px solid #c79a3b;
    border-radius: 12px;
    box-shadow: 0 7px 16px rgba(53, 17, 21, 0.18);
}

.list-item {
    background: rgba(255, 253, 247, 0.80) !important;
    border-color: rgba(125, 87, 13, 0.13) !important;
}

/* รายการที่กำลังแก้ไขอยู่ในฟอร์มด้านบน (outline ถูกปิดทั้งแอป จึงใช้ box-shadow แทน) */
.list-item.is-editing {
    background: rgba(246, 237, 217, 0.95) !important;
    border-color: var(--jh-gold) !important;
    box-shadow: inset 0 0 0 2px var(--jh-gold) !important;
}

.device-vault {
    overflow: hidden;
    color: var(--jh-ink);
    background: rgba(255, 253, 248, 0.88);
    border: 1px solid rgba(93, 48, 36, 0.16);
    border-radius: 16px;
    box-shadow: 0 10px 26px rgba(48, 24, 17, 0.07);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: border-color 0.3s ease-out, box-shadow 0.3s ease-out, transform 0.3s ease-out;
}

.device-vault.is-open {
    border-color: rgba(93, 48, 36, 0.28);
    box-shadow: 0 16px 36px rgba(48, 24, 17, 0.11);
}

.device-vault-toggle {
    display: grid;
    width: 100%;
    grid-template-columns: 34px minmax(0, 1fr) 26px;
    align-items: center;
    gap: 11px;
    min-height: 58px;
    padding: 10px 12px;
    color: inherit;
    text-align: left;
    background: transparent;
    border: 0;
}

.device-vault-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: #fff1cf;
    background: linear-gradient(145deg, #5d3024, #351914);
    border-radius: 11px;
    box-shadow: 0 6px 13px rgba(48, 24, 17, 0.18);
}

.device-vault-icon svg { width: 18px; height: 18px; }

.device-vault-copy {
    display: grid;
    gap: 1px;
}

.device-vault-copy strong { font-size: 0.78rem; }

.device-vault-copy small {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #85766c;
    font-size: 0.64rem;
}

.device-status-dot {
    width: 6px;
    height: 6px;
    background: #71845d;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(113, 132, 93, 0.12);
}

.device-vault-chevron {
    color: #8b7568;
    font-size: 1.25rem;
    text-align: center;
    transform: translateY(-2px);
    transition: transform 0.35s ease-out;
}

.device-vault.is-open .device-vault-chevron { transform: rotate(180deg) translateY(2px); }

.device-vault-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    border-top: 1px solid transparent;
    transition: grid-template-rows 0.4s ease-out, opacity 0.3s ease-out, border-color 0.3s ease-out;
}

.device-vault.is-open .device-vault-panel {
    grid-template-rows: 1fr;
    opacity: 1;
    border-top-color: rgba(93, 48, 36, 0.11);
}

.device-vault-panel-inner {
    min-height: 0;
    overflow: hidden;
    padding: 0 12px;
}

.device-vault.is-open .device-vault-panel-inner { padding-top: 12px; padding-bottom: 12px; }

.device-vault-note {
    margin: 11px 0;
    color: #8b7d72;
    font-size: 0.62rem;
    line-height: 1.55;
}

.device-vault .data-tools-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.paper-preview {
    border: 1px solid rgba(125, 87, 13, 0.22);
    box-shadow: 0 18px 44px rgba(48, 24, 17, 0.16) !important;
}

footer {
    opacity: 0.78;
}

@keyframes sacred-orbit-turn {
    from { transform: translateX(-50%) rotate(0deg); }
    to { transform: translateX(-50%) rotate(360deg); }
}

@keyframes sacred-orbit-turn-reverse {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@keyframes sacred-breathe {
    0%, 100% { opacity: 0.42; transform: translateX(-50%) scale(0.97); }
    50% { opacity: 0.72; transform: translateX(-50%) scale(1.03); }
}

@media (max-width: 640px) {
    .modal-overlay {
        max-width: 100vw;
        padding-right: max(12px, env(safe-area-inset-right)) !important;
        padding-left: max(12px, env(safe-area-inset-left)) !important;
        overflow-x: hidden;
    }

    .modal-overlay > .modal-content {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0;
        margin: 0 !important;
        align-self: stretch;
    }

    .app-shell > .sacred-header {
        padding: 22px 16px 20px !important;
        border-radius: 24px !important;
    }

    .sacred-brand-row {
        gap: 10px;
    }

    .slip-meta-card {
        border-radius: 16px !important;
    }

    .slip-meta-grid {
        grid-template-columns: 1fr;
    }

    .slip-meta-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .slip-meta-footer button {
        width: 100%;
    }

    .pwa-install-banner {
        bottom: max(12px, env(safe-area-inset-bottom));
        grid-template-columns: 1fr;
        width: calc(100vw - 24px);
        padding: 12px;
        gap: 11px;
        border-radius: 16px;
    }

    .pwa-install-main { gap: 10px; }

    .app-install-icon {
        width: 44px;
        height: 44px;
        border-radius: 11px;
    }

    .pwa-install-copy > span { font-size: 0.68rem; }
    .pwa-install-copy strong { font-size: 0.94rem; }
    .pwa-install-copy p {
        font-size: 0.75rem;
        white-space: normal;
    }

    .pwa-install-actions {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    }

    .pwa-install-actions button {
        width: 100%;
        min-width: 0;
        min-height: 46px;
        font-size: 0.8rem;
    }
}

/* Sacred Custom Confirm Modal */
.sacred-confirm-backdrop {
    background: rgba(18, 12, 10, 0.62) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
}

.sacred-confirm-card {
    background: linear-gradient(160deg, #FFFDF8 0%, #FAF3E6 100%) !important;
    border: 1.5px solid #d4c4a8 !important;
    box-shadow: 0 24px 50px rgba(45, 16, 12, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    border-radius: 26px !important;
    max-width: 360px !important;
    width: 92% !important;
    padding: 26px 22px 22px !important;
}

.sacred-modal-title {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: #3a1510 !important;
    margin-bottom: 8px !important;
    font-family: 'Prompt', sans-serif !important;
    letter-spacing: -0.01em !important;
}

.sacred-modal-text {
    font-size: 0.88rem !important;
    line-height: 1.55 !important;
    color: #6b5849 !important;
    margin-bottom: 22px !important;
    white-space: pre-line !important;
    font-family: 'Prompt', sans-serif !important;
}

.sacred-modal-actions {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    width: 100% !important;
}

.sacred-modal-btn {
    flex: 1 !important;
    min-height: 48px !important;
    padding: 10px 16px !important;
    border-radius: 14px !important;
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    font-family: 'Prompt', sans-serif !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    outline: none !important;
}

.sacred-modal-btn-cancel {
    background: #fffdf9 !important;
    border: 1.5px solid #dcd0ba !important;
    color: #4a3728 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

.sacred-modal-btn-cancel:hover,
.sacred-modal-btn-cancel:active {
    background: #f7eedf !important;
    border-color: #caa045 !important;
    color: #3a1510 !important;
    transform: translateY(-1px) !important;
}

.sacred-modal-btn-ok {
    background: linear-gradient(135deg, #7c2629 0%, #5a191c 100%) !important;
    border: 1px solid #caa045 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(124, 38, 41, 0.35) !important;
}

.sacred-modal-btn-ok:hover,
.sacred-modal-btn-ok:active {
    background: linear-gradient(135deg, #8f2d31 0%, #681e21 100%) !important;
    box-shadow: 0 6px 18px rgba(124, 38, 41, 0.45) !important;
    transform: translateY(-1px) !important;
}

.sacred-modal-btn-ok.gold-btn {
    background: linear-gradient(135deg, #b9903d 0%, #8c6721 100%) !important;
    border: 1px solid #f3d790 !important;
    box-shadow: 0 4px 14px rgba(185, 144, 61, 0.35) !important;
}

/* ============================================
   UX polish: readability, clarity, accessibility
   ============================================ */

/* A lottery number is one unit: never break "123456" across lines */
.saved-entry-number {
    white-space: nowrap;
    overflow-wrap: normal !important;
    font-variant-numeric: tabular-nums;
}

#ugTotal,
.saved-entry-value strong,
.export-number,
.export-summary-value {
    font-variant-numeric: tabular-nums;
}

/* Thai placeholder text must not be letter-spaced ("ร ะ บุ ร า ค า") */
#ugPriceDirect:placeholder-shown,
#ugPriceTod:placeholder-shown,
#ugPriceDirect::placeholder,
#ugPriceTod::placeholder {
    letter-spacing: normal;
}

/* Tod toggle: a labelled button instead of a bare "+" circle */
.tod-toggle-btn {
    min-height: 44px;
    padding: 10px 18px;
    border: 1.5px dashed rgba(148, 97, 22, 0.55);
    border-radius: 999px;
    background: rgba(252, 248, 238, 0.9);
    color: var(--jh-gold-deep);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.tod-toggle-btn[aria-expanded="true"] {
    border-style: solid;
    color: var(--jh-muted);
}

/* Toast with an action (e.g. undo delete) must be tappable */
#toast {
    width: max-content;
    max-width: calc(100vw - 32px);
}

#toast.has-action {
    display: flex;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
}

.toast-action {
    flex-shrink: 0;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.toast-action.hidden {
    display: none;
}

/* Keyboard users need to see where focus is (earlier rules removed it) */
.tab-btn:focus-visible,
.choice-chip:focus-visible,
.filter-chip:focus-visible,
.numpad-btn:focus-visible,
.gold-btn:focus-visible,
.danger-btn:focus-visible,
.tod-toggle-btn:focus-visible,
.edit-cancel-btn:focus-visible,
.toast-action:focus-visible,
.list-item:focus-visible {
    outline: 2px solid #b7862b !important;
    outline-offset: 2px !important;
}

/* Scrolling inside a sheet should not scroll the page behind it */
.modal-content,
#selectionList,
.numpad-overlay {
    overscroll-behavior: contain;
}

/* Respect the system "reduce motion" setting */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   Compact header: the form is the first thing on screen
   ============================================ */
.app-shell > .sacred-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px !important;
    padding: 12px 16px !important;
    overflow: hidden !important;
    text-align: left;
    border-radius: 18px !important;
}

.app-shell > .sacred-header::before,
.app-shell > .sacred-header::after,
.sacred-header .header-kicker,
.sacred-header .header-divider,
.sacred-header .header-blessing,
.sacred-header .brand-flourish {
    display: none;
}

.sacred-header .brand-seal {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin: 0;
    font-size: 16px;
}

.sacred-header .sacred-brand-row {
    justify-content: flex-start;
}

.sacred-header .brand-title {
    font-size: 1.6rem !important;
    line-height: 1.1;
}

.sacred-header .brand-subtitle {
    margin: 0 0 0 auto;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    text-align: right;
    white-space: nowrap;
}

.sacred-header .header-mandala {
    left: 18%;
    opacity: 0.5;
}

@media (max-width: 440px) {
    .sacred-header .brand-subtitle {
        display: none;
    }
}

/* ============================================
   Tod type chips (โต๊ด / กลับ 3 / กลับ 6)
   ============================================ */
.tod-type-chips {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.tod-type-chips .choice-chip {
    min-width: 76px;
}

.tod-glab-hint {
    max-width: 24rem;
    margin: 4px auto 0;
    padding: 10px 14px;
    border: 1px dashed rgba(148, 97, 22, 0.45);
    border-radius: 12px;
    color: var(--jh-gold-deep);
    background: rgba(252, 248, 238, 0.9);
    font-size: 0.9rem;
    text-align: center;
}

/* ============================================
   Underground total: the one place the sum is shown
   ============================================ */
#ugSummary > div {
    align-items: baseline;
}

.ug-summary-label {
    color: var(--jh-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.ug-summary-total {
    color: var(--jh-gold-deep);
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tod-copy-btn {
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid rgba(148, 97, 22, 0.35);
    border-radius: 999px;
    background: rgba(246, 237, 217, 0.9);
    color: var(--jh-gold-deep);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

/* ============================================
   Readable small text: nothing below 12px on a phone
   (Thai vowels/tone marks become illegible below that)
   ============================================ */
.slip-meta-eyebrow,
.entry-heading > span,
.saved-entry-value small,
#drawDatePrevious > span,
#drawDateNext > span {
    font-size: 0.75rem !important;
}

#slipMetaSummary,
.draw-date-manual-label,
#drawDateRuleHint,
#slipMetaStatus,
.slip-meta-footer button,
.entry-heading p,
.device-vault-copy small,
.device-vault-note,
.data-tool-btn {
    font-size: 0.8125rem !important;
}
