#mart-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: #bdcda9;
    color: #355344;
    font:
        14px/1.5 system-ui,
        'Microsoft JhengHei',
        sans-serif;
}
#mart-dialog::backdrop {
    background: #243b30b0;
}
#mart-dialog * {
    box-sizing: border-box;
}
#mart-dialog [hidden],
#mart-minimized[hidden] {
    display: none !important;
}
#mart-dialog button,
#mart-dialog select {
    font: inherit;
    font-weight: 600;
    color: #193a2a;
}
#mart-dialog button {
    cursor: pointer;
}
#mart-dialog button:disabled,
#mart-dialog select:disabled {
    opacity: 1;
    color: #4b554b;
    background: #e2e5dc;
    border: 1px dashed #879582;
    cursor: default;
}
#mart-dialog button:focus-visible,
#mart-dialog select:focus-visible {
    outline: 3px solid #193a2a;
    outline-offset: 3px;
}
#mart-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}
.mart-expansion-preview {
    display: flex;
    min-height: 125px;
    margin: 20px 0;
    border: 2px solid #70957b;
    border-radius: 10px;
    overflow: hidden;
    background:
        repeating-linear-gradient(0deg, transparent 0 23px, #c5bfa740 24px 25px),
        repeating-linear-gradient(90deg, #f2e9d4 0 23px, #c5bfa740 24px 25px);
}
.mart-expansion-preview span {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 4px;
    min-width: 0;
    font-size: 12px;
}
.mart-new-floor {
    background: #acd4a9bd;
    border-left: 2px dashed #70957b;
}
.mart-brand {
    position: absolute;
    right: auto;
    display: block;
    top: max(20px, env(safe-area-inset-top));
    left: 24px;
    pointer-events: none;
    text-shadow: 0 1px 2px #fff6;
}
.mart-brand h2 {
    margin: 0;
    font-family: inherit;
    font-size: 23px;
    letter-spacing: 1px;
}
.mart-brand small {
    font-size: 12px;
    display: block;
    margin-top: 3px;
}
.mart-window {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    right: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.mart-icon {
    border: 1px solid #fff9;
    border-bottom: 3px solid #e6ddc8;
    border-radius: 15px;
    background: #fff9eb;
    box-shadow: 0 4px 12px #354f3918;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    font-size: 23px;
    position: relative;
    padding: 0;
}
.mart-icon svg {
    width: 23px;
    height: 23px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.mart-window .mart-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 19px;
}
.mart-wallet {
    position: absolute;
    right: 20px;
    top: 72px;
    background: #fff9eb;
    border-radius: 18px;
    padding: 8px 14px;
    font-weight: 650;
    font-size: 13px;
}
.mart-tools {
    position: absolute;
    bottom: max(25px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    align-items: center;
}
.mart-count {
    position: absolute;
    right: -4px;
    top: -5px;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    background: #824117;
    color: white;
    font-size: 11px;
    padding: 0 4px;
}
.mart-tip {
    position: absolute;
    bottom: 58px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff9eb;
    color: #193a2a;
    padding: 5px 9px;
    border-radius: 9px;
    white-space: nowrap;
    font-size: 12px;
    box-shadow: 0 3px 12px #354f3920;
    visibility: hidden;
    pointer-events: none;
}
.mart-icon:hover .mart-tip,
.mart-icon:focus-visible .mart-tip {
    visibility: visible;
}
.mart-zoom {
    position: absolute;
    bottom: 25px;
    right: 20px;
    display: flex;
    gap: 6px;
}
.mart-zoom .mart-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 18px;
}
.mart-status {
    position: absolute;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    max-width: min(620px, 90%);
    background: #fff9ebed;
    border-radius: 15px;
    padding: 7px 15px;
    font-size: 12px;
    text-align: center;
    pointer-events: none;
}
.mart-overlay {
    position: absolute;
    inset: 0;
    background: #213c3033;
    display: grid;
    place-items: center;
    padding: 18px;
    z-index: 3;
}
.mart-popup {
    background: #fffaf0;
    border: 3px solid #fffdf6;
    border-radius: 22px;
    box-shadow: 0 20px 80px #1f392d33;
    width: min(610px, 100%);
    max-height: calc(100dvh - 36px);
    overflow: auto;
    padding: 22px;
}
.mart-popup-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 17px;
}
.mart-popup h3 {
    font-size: 20px;
    margin: 0;
}
.mart-popup p {
    font-size: 12px;
    color: #4c5f50;
    margin: 6px 0 12px;
}
.mart-popup .mart-icon {
    width: 34px;
    height: 34px;
    font-size: 21px;
    flex-shrink: 0;
}
.mart-tabs {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin: 0 0 15px;
}
.mart-tabs button,
.mart-action {
    border: 0;
    border-radius: 10px;
    background: #e9eddf;
    padding: 9px 12px;
    font-size: 12px;
}
#mart-dialog button[aria-pressed='true']:enabled,
#mart-dialog .mart-action.primary:enabled {
    background: #28533c;
    color: #ffffff;
}
/* Explicit colors beat the shared button inheritance and brightness filter. */
#mart-dialog button:enabled:hover,
#mart-minimized button:hover {
    filter: none;
    background: #dce7d8;
    color: #193a2a;
}
#mart-dialog button[aria-pressed='true']:enabled:hover,
#mart-dialog .mart-action.primary:enabled:hover {
    background: #193a2a;
    color: #ffffff;
}
#mart-dialog button:enabled:active,
#mart-minimized button:active {
    filter: none;
    background: #193a2a;
    color: #ffffff;
}
.mart-products {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.mart-product {
    padding: 13px;
    border: 1px solid #e1dfcf;
    border-radius: 14px;
    min-width: 0;
}
.mart-product figure {
    margin: 0 0 10px;
    display: grid;
    place-items: center;
    background: #edf0e4;
    border-radius: 11px;
    height: 78px;
    font-size: 41px;
}
.mart-product strong {
    font-size: 14px;
    display: block;
}
.mart-product small {
    font-size: 11px;
    display: block;
    margin-top: 5px;
    color: #4c5f50;
}
.mart-product button {
    width: 100%;
    margin-top: 12px;
}
.mart-staff,
.mart-order {
    padding: 14px;
    border: 1px solid #e1dfcf;
    border-radius: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}
.mart-staff .mart-person {
    font-size: 32px;
    background: #edf0e4;
    border-radius: 13px;
    padding: 7px;
}
.mart-staff div {
    flex: 1;
}
.mart-staff strong,
.mart-order strong {
    display: block;
    font-size: 14px;
}
.mart-staff small,
.mart-order small {
    font-size: 12px;
    color: #4c5f50;
}
.mart-staff select {
    padding: 8px;
    border: 1px solid #dedfcc;
    border-radius: 9px;
    background: #f0f1e6;
}
.mart-order div {
    flex: 1;
}
.mart-theme {
    display: flex;
    gap: 10px;
}
.mart-theme button {
    flex: 1;
}
.mart-edit-banner {
    position: absolute;
    left: 50%;
    top: 22px;
    transform: translateX(-50%);
    padding: 8px 19px;
    background: #fff9eb;
    border-radius: 20px;
    font-weight: 650;
}
.mart-editbar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #fff9eb;
    border-radius: 17px;
    padding: 9px;
    flex-wrap: wrap;
    max-width: calc(100% - 30px);
    width: max-content;
}
.mart-editbar select {
    background: #eef0e3;
    border: 0;
    border-radius: 9px;
    padding: 9px;
    font-size: 12px;
    max-width: 160px;
}
.mart-editbar .mart-action {
    min-height: 40px;
}
.mart-edit-hint {
    position: absolute;
    bottom: 93px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    background: #fff9ebed;
    border-radius: 12px;
    padding: 6px 12px;
    text-align: center;
    max-width: 85%;
    width: max-content;
}
#mart-dialog[data-editing='true'] .mart-status {
    bottom: 135px;
}
#mart-dialog[data-editing='true'] .mart-wallet {
    display: none;
}
#mart-minimized {
    position: fixed;
    right: 14px;
    bottom: 115px;
    z-index: 45;
    display: flex;
    gap: 5px;
    background: #fff9eb;
    color: #355344;
    padding: 7px;
    border-radius: 15px;
    box-shadow: 0 5px 20px #25463030;
    max-width: calc(100vw - 28px);
}
#mart-minimized button {
    border: 0;
    background: transparent;
    color: #193a2a;
    padding: 6px;
    cursor: pointer;
}
#mart-minimized button:focus-visible {
    outline: 3px solid #193a2a;
    outline-offset: 3px;
}
#mart-minimized strong {
    font-size: 12px;
}
#mart-minimized small {
    display: block;
    font-size: 11px;
}
@media (max-width: 650px) {
    #mart-dialog .mart-brand {
        max-width: calc(100% - 155px);
        text-align: left;
    }
    #mart-dialog .mart-brand h2 {
        font-size: 16px;
        letter-spacing: 0;
    }
}
@media (max-width: 650px) {
    .mart-brand {
        left: 15px;
        top: 16px;
    }
    .mart-brand h2 {
        font-size: 18px;
    }
    .mart-window {
        right: 12px;
        top: 14px;
        gap: 5px;
    }
    .mart-wallet {
        right: 12px;
        top: 64px;
        font-size: 12px;
    }
    .mart-tools {
        gap: 6px;
        bottom: 22px;
    }
    .mart-tools .mart-icon {
        width: 36px;
        height: 42px;
    }
    .mart-icon {
        width: 43px;
        height: 43px;
        border-radius: 13px;
    }
    .mart-zoom {
        right: 12px;
        bottom: 82px;
        flex-direction: column;
    }
    .mart-popup {
        padding: 16px;
    }
    .mart-products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .mart-product:last-child {
        grid-column: 1/-1;
    }
    .mart-product:last-child figure {
        height: 53px;
    }
    .mart-product {
        padding: 10px;
    }
    .mart-staff {
        padding: 10px;
        gap: 8px;
    }
    .mart-staff select {
        max-width: 100px;
    }
    .mart-edit-banner {
        top: 70px;
        font-size: 13px;
    }
    .mart-editbar {
        gap: 5px;
        padding: 7px;
        bottom: 16px;
        min-width: 285px;
    }
    .mart-editbar select {
        width: 100%;
        max-width: none;
        flex-basis: 100%;
    }
    .mart-editbar .mart-action {
        padding: 8px;
    }
    .mart-edit-hint {
        bottom: 125px;
        max-width: 90%;
    }
    #mart-dialog[data-editing='true'] .mart-status {
        bottom: 185px;
    }
    .mart-status {
        bottom: 80px;
        width: max-content;
        max-width: 85%;
    }
    .mart-popup-head {
        margin-bottom: 12px;
    }
    .mart-popup h3 {
        font-size: 18px;
    }
}

/* Keep customer comments readable, without covering controls or intercepting taps. */
.mart-customer-speech {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.mart-customer-bubble {
    position: absolute;
    transform: translate(-50%, -100%);
    width: max-content;
    max-width: 190px;
    padding: 9px 12px;
    border: 1px solid #76917b;
    border-radius: 15px 15px 15px 3px;
    background: #fffbefed;
    box-shadow: 0 3px 9px #314b3025;
    color: #344b3b;
    font-size: 13px;
    line-height: 1.45;
}
.mart-customer-bubble[data-personality='impatient'],
.mart-customer-bubble[data-personality='picky'] {
    border-color: #ad8e65;
    background: #fff1ddeb;
}
.mart-customer-bubble[hidden] {
    display: none;
}
.mart-expansion-preview {
    position: relative;
}
.mart-expansion-preview .mart-existing-floor {
    position: absolute;
    bottom: 0;
    left: 0;
    background: #fff8e4dd;
    border-top: 2px dashed #70957b;
    border-right: 2px dashed #70957b;
}
@media (max-width: 650px) {
    .mart-customer-bubble {
        font-size: 12px;
        max-width: 165px;
    }
}
