/* ════════════════════════════════════════════════════════════════════════════
   css/tb1-school-map.css — แผนผังโรงเรียน 3 มิติ (school_map.php) · 14 ต.ค. 2569
   ใช้คู่กับ css/tb1-info-page.css (ตัวแปร --ip-*) · คำนำหน้า sm-
   มือถือก่อน · โหมดมืด ([data-theme=dark] / html.dark-mode) · ความคมชัดสูง (html.tb1-contrast-high) · พิมพ์ (แสดงผัง 2 มิติ)
   ════════════════════════════════════════════════════════════════════════════ */

.sm {
    --sm-bg: #dbe6f2;
    --sm-ground: #e3e8dc;
    --sm-lot: #ece6d8;
    --sm-field: #7dbb6a;
    --sm-field-text: #10301a;
    --sm-road: #b7bbc2;
    --sm-road-main: #6b717b;
    --sm-fence: #7f8fd6;
    --sm-ctx: #d5d9df;
    --sm-ctx-line: #b5bbc4;
    --sm-bld-line: #4f5aa6;
    --sm-halo: #ffffff;
    --sm-lbl-bg: rgba(255, 255, 255, .93);
    --sm-lbl-ink: #0f172a;
    --sm-on: var(--ip-navy);
    --sm-on-ink: #fff;
    position: relative;
}

[data-theme="dark"] .sm,
html.dark-mode .sm {
    --sm-bg: #0d1727;
    --sm-ground: #1b2431;
    --sm-lot: #2b3240;
    --sm-field: #2f6a37;
    --sm-field-text: #eaf6e6;
    --sm-road: #3c4350;
    --sm-road-main: #2a2f38;
    --sm-fence: #8597dc;
    --sm-ctx: #2a3342;
    --sm-ctx-line: #3b4658;
    --sm-bld-line: #a5b4fc;
    --sm-halo: #0a1322;
    --sm-lbl-bg: rgba(17, 28, 46, .93);
    --sm-lbl-ink: #f1f5f9;
    --sm-on: #93c5fd;
    --sm-on-ink: #0a1322;
}

.sm * {
    box-sizing: border-box;
}

.sm-sec {
    margin-top: 1.5rem;
}

/* ═══ แถบเครื่องมือ ═══ */
.sm-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .65rem;
}

.sm-bar[hidden] {
    display: none;
}

.sm-tool,
.sm-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 40px;
    padding: .3rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--ip-line2);
    background: var(--ip-card);
    color: var(--ip-ink1);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.sm-tool i {
    color: var(--ip-blue);
}

.sm-tool:hover,
.sm-chip:hover {
    border-color: var(--ip-brand);
    background: color-mix(in srgb, var(--ip-blue) 8%, var(--ip-card));
}

.sm-tool[aria-pressed="true"],
.sm-chip[aria-pressed="true"] {
    background: var(--sm-on);
    border-color: var(--sm-on);
    color: var(--sm-on-ink);
}

.sm-tool[aria-pressed="true"] i,
.sm-chip[aria-pressed="true"] i {
    color: inherit;
}

.sm :is(.sm-tool, .sm-chip, .sm-zbtn, .sm-compass, .sm-fs, .ip-btn):focus-visible,
.sm-card-go:focus-visible {
    outline: 3px solid var(--ip-brand);
    outline-offset: 2px;
}

/* ═══ พื้นที่แผนที่ ═══ */
.sm-body {
    display: grid;
    gap: .8rem;
}

@media (min-width: 960px) {
    .sm-body {
        grid-template-columns: minmax(0, 1fr) 300px;
        align-items: start;
    }
}

.sm-stage {
    position: relative;
    min-width: 0;
    border-radius: var(--ip-r);
    overflow: hidden;
    background: var(--ip-card);
    border: 1px solid var(--ip-line);
    box-shadow: var(--ip-sh);
    isolation: isolate;
}

.sm.is-3d .sm-stage {
    height: clamp(340px, 62svh, 620px);
    background: var(--sm-bg);
}

.sm-stage:focus-visible {
    outline: 3px solid var(--ip-brand);
    outline-offset: 3px;
}

.sm-stage:fullscreen {
    height: 100vh;
    border-radius: 0;
    border: 0;
}

.sm-stage:-webkit-full-screen {
    height: 100vh;
    width: 100vw;
    border-radius: 0;
}

.sm-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.sm:not(.is-3d) .sm-canvas,
.sm:not(.is-3d) .sm-labels,
.sm:not(.is-3d) .sm-compass,
.sm:not(.is-3d) .sm-zoom,
.sm:not(.is-3d) .sm-fs,
.sm:not(.is-3d) .sm-side,
.sm:not(.is-3d) .sm-help {
    display: none;
}

/* ผัง 2 มิติ: แสดงเมื่อไม่มีภาพ 3 มิติ หรือกดปุ่ม "ผัง 2 มิติ" */
.sm-plan {
    margin: 0;
}

.sm.is-3d .sm-plan {
    display: none;
}

.sm.is-3d.is-plan .sm-plan {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    background: var(--ip-card);
}

.sm.is-3d.is-plan :is(.sm-canvas, .sm-labels, .sm-compass, .sm-zoom, .sm-fs, .sm-hint) {
    display: none;
}

.sm-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 78svh;
    background: var(--sm-ground);
}

.sm.is-3d.is-plan .sm-svg {
    flex: 1;
    min-height: 0;
    height: 100%;
    max-height: none;
}

.sm-plan-cap {
    padding: .45rem .85rem;
    font-size: .82rem;
    color: var(--ip-ink3);
    border-top: 1px solid var(--ip-line);
    background: var(--ip-card);
}

.sm-svg .p-ground {
    fill: var(--sm-ground);
}

.sm-svg .p-road {
    fill: none;
    stroke: var(--sm-road);
    stroke-linejoin: round;
}

.sm-svg .p-road.is-main {
    stroke: var(--sm-road-main);
}

.sm-svg .p-cl {
    fill: none;
    stroke: #efc23a;
    stroke-width: .3;
    stroke-dasharray: 2.5 2;
}

.sm-svg .p-lot {
    fill: var(--sm-lot);
    stroke: var(--sm-fence);
    stroke-width: .9;
}

.sm-svg .p-field {
    fill: var(--sm-field);
    stroke: #c9cfd8;
    stroke-width: .5;
}

.sm-svg .p-garden {
    fill: var(--sm-field);
    stroke: #c6cbbd;
    stroke-width: .35;
}
.sm-svg .p-tree {
    fill: #456b36;
    stroke: #dce7cd;
    stroke-width: .25;
}
html.tb1-contrast-high .sm-svg :is(.p-garden, .p-tree) {
    stroke: #fff;
    stroke-width: .6;
}

.sm-svg .p-ctx {
    fill: var(--sm-ctx);
    stroke: var(--sm-ctx-line);
    stroke-width: .3;
}

.sm-svg .p-bld {
    stroke: var(--sm-bld-line);
    stroke-width: .5;
}

.sm-svg .p-pitch :is(rect, path, circle) {
    fill: none;
    stroke: #fff;
    stroke-width: .3;
    opacity: .9;
}

.sm-svg .p-gate rect {
    fill: var(--sm-fence);
}

.sm-svg .p-flag circle {
    fill: #a51931;
    stroke: #fff;
    stroke-width: .5;
}

.sm-svg .p-north circle {
    fill: var(--ip-card);
    stroke: var(--ip-line2);
    stroke-width: .4;
}

.sm-svg .p-north path {
    fill: #c0392b;
}

.sm-svg .p-scale path {
    fill: none;
    stroke: var(--ip-ink1);
    stroke-width: .5;
}

.sm-svg .p-t {
    font-family: var(--ip-fb);
    font-size: 4.2px;
    font-weight: 700;
    fill: var(--ip-ink1);
    paint-order: stroke;
    stroke: var(--sm-halo);
    stroke-width: .9px;
    stroke-linejoin: round;
}

.sm-svg .p-t.is-sm {
    font-size: 3px;
    font-weight: 600;
}

.sm-svg .p-t.is-road {
    font-size: 3.1px;
    font-weight: 600;
    fill: #fff;
    stroke: rgba(0, 0, 0, .55);
}

.sm-svg .p-t.is-ctx {
    fill: var(--ip-ink3);
}

.sm-svg .p-t.is-field {
    font-size: 3.3px;
    fill: var(--sm-field-text);
    stroke: none;
}

.sm-svg .p-t.is-field.is-sm {
    font-size: 2.6px;
    font-weight: 600;
}

/* ═══ ป้ายชื่อในภาพ 3 มิติ ═══ */
.sm-labels {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.no-labels .sm-lbl:not(.is-on) {
    display: none;
}

.sm-lbl {
    /* labels move every frame: never animate them (the site's reduced-motion rule gives everything a 0.15s transition) */
    transition-property: none;
    position: absolute;
    left: 0;
    top: 0;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: var(--sm-lbl-bg);
    color: var(--sm-lbl-ink);
    font-family: var(--ip-fb);
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .2);
    will-change: transform;
}

.sm-lbl.is-bld {
    pointer-events: auto;
    cursor: pointer;
    margin-top: -6px;
    border: 1px solid color-mix(in srgb, var(--ip-brand) 30%, transparent);
}

.sm-lbl.is-bld::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -5px;
    width: 8px;
    height: 8px;
    background: inherit;
    border-right: inherit;
    border-bottom: inherit;
    transform: translateX(-50%) rotate(45deg);
}

.sm-lbl.is-hover {
    border-color: var(--ip-brand);
}

.sm-lbl.is-on {
    background: var(--sm-on);
    color: var(--sm-on-ink);
    border-color: var(--sm-on);
    font-size: .88rem;
}

.sm-lbl.is-dim {
    opacity: .6;
}

.sm-lbl.is-road {
    padding: 0;
    background: none;
    box-shadow: none;
    color: #fff;
    font-size: .74rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .85), 0 0 5px rgba(0, 0, 0, .6);
}

.sm-lbl.is-ctx,
.sm-lbl.is-sm {
    padding: .1rem .45rem;
    font-size: .72rem;
    font-weight: 600;
    opacity: .92;
}

/* ═══ ปุ่มบนแผนที่ ═══ */
.sm-compass,
.sm-fs,
.sm-zbtn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--ip-line2);
    background: var(--ip-card);
    color: var(--ip-ink1);
    font-size: 1rem;
    cursor: pointer;
}

.sm-compass {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    border-radius: 50%;
    box-shadow: var(--ip-sh);
}

.sm-needle {
    transition-property: none;
    position: relative;
    display: block;
    width: 40px;
    height: 40px;
}

.sm-needle::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 9px;
    width: 10px;
    height: 24px;
    margin-left: -5px;
    background: linear-gradient(#d32f2f 0 50%, #94a3b8 50% 100%);
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.sm-n {
    position: absolute;
    left: 0;
    right: 0;
    top: -1px;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    color: #b91c1c;
}

[data-theme="dark"] .sm-n,
html.dark-mode .sm-n {
    color: #fca5a5;
}

.sm-fs {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    border-radius: 12px;
    box-shadow: var(--ip-sh);
}

.sm-zoom {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--ip-sh);
}

.sm-zbtn {
    border-radius: 0;
}

.sm-zbtn + .sm-zbtn {
    border-top: 0;
}

.sm-zbtn:first-child {
    border-radius: 12px 12px 0 0;
}

.sm-zbtn:last-child {
    border-radius: 0 0 12px 12px;
}

.sm-compass:hover,
.sm-fs:hover,
.sm-zbtn:hover {
    background: color-mix(in srgb, var(--ip-blue) 10%, var(--ip-card));
}

.sm-hint {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    max-width: 90%;
    padding: .55rem .9rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, .85);
    color: #fff;
    font-size: .9rem;
    text-align: center;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

.sm-hint.is-on {
    opacity: 1;
}

.sm-note {
    position: absolute;
    left: 50%;
    top: 12px;
    z-index: 6;
    display: none;
    width: max-content;
    max-width: min(92%, 440px);
    padding: .7rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--ip-line2);
    background: var(--ip-card);
    color: var(--ip-ink1);
    font-size: .92rem;
    text-align: center;
    box-shadow: var(--ip-sh2);
    transform: translateX(-50%);
}

.sm-note.is-on {
    display: block;
}

.sm-note.is-busy {
    top: 50%;
    transform: translate(-50%, -50%);
}

.sm-note .ip-btn {
    margin-top: .5rem;
}

.sm-spin {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .5em;
    vertical-align: -.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: sm-spin .8s linear infinite;
}

@keyframes sm-spin {
    to {
        transform: rotate(360deg);
    }
}

.sm-help,
.sm-credit {
    margin: .5rem 0 0 !important;
    font-size: .82rem;
    color: var(--ip-ink3);
}

.sm-credit {
    font-size: .78rem;
}

.sm-credit a {
    color: var(--ip-link);
}

/* ═══ แผงข้าง: เลือกอาคาร + รายละเอียด ═══ */
.sm-side {
    display: grid;
    gap: .75rem;
    min-width: 0;
}

/* grid cells must not grow to the width of the scrolling chip row (phones scrolled sideways) */
.sm-body > *,
.sm-side > * {
    min-width: 0;
}

.sm-pick[hidden] {
    display: none;
}

.sm-pick-h {
    margin: 0 0 .4rem !important;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ip-ink3);
}

.sm-chips {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    padding-bottom: .3rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.sm-chip {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (min-width: 960px) {
    .sm-chips {
        flex-direction: column;
        overflow: visible;
        padding-bottom: 0;
    }

    .sm-chip {
        width: 100%;
        border-radius: 12px;
        text-align: left;
    }
}

.sm-info {
    min-height: 4rem;
    padding: 1rem;
    border-radius: var(--ip-r);
    background: var(--ip-card);
    border: 1px solid var(--ip-line);
    box-shadow: var(--ip-sh);
}

.sm-info-hint {
    margin: 0 !important;
    font-size: .92rem;
    color: var(--ip-ink3);
}

.sm-info-h {
    margin: 0 0 .25rem !important;
    font-family: var(--ip-fd);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ip-ink1);
}

.sm-info-use {
    margin: 0 0 .6rem !important;
    color: var(--ip-ink2);
    font-size: .95rem;
}

.sm-info-facts,
.sm-info-rooms {
    display: grid;
    gap: .35rem;
    margin: 0 !important;
    padding: 0;
    list-style: none;
    font-size: .92rem;
    color: var(--ip-ink2);
}

.sm-info-rooms {
    margin-top: .6rem !important;
    padding-left: 1.1rem;
    list-style: disc;
}

.sm-info-facts i {
    width: 1.2em;
    color: var(--ip-blue);
    text-align: center;
}

.sm-info-src {
    margin: .65rem 0 0 !important;
    font-size: .78rem;
    color: var(--ip-ink3);
}

.sm-tbc {
    display: inline-block;
    padding: .02rem .45rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, #f59e0b 50%, var(--ip-line));
    background: color-mix(in srgb, #f59e0b 16%, var(--ip-card));
    color: var(--ip-ink1);
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ═══ Google Maps ═══ */
.sm-gmap .cm-map-cover > i {
    background: #1a73e8;
}

.sm-gmap-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    margin: .8rem 0 0 !important;
    padding: 0;
    list-style: none;
}

/* ═══ รายการอาคาร ═══ */
.sm-cards {
    display: grid;
    gap: .9rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
}

.sm-card {
    display: flex;
    flex-direction: column;
    scroll-margin-top: 132px;
}

.sm-card h3 {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .3rem !important;
    font-family: var(--ip-fd);
    font-size: 1.08rem;
    font-weight: 800;
    color: var(--ip-ink1);
}

.sm-swatch {
    flex: 0 0 auto;
    width: .9rem;
    height: .9rem;
    border-radius: 4px;
    background: var(--c);
    border: 1px solid rgba(0, 0, 0, .18);
}

.sm-card-use {
    margin: 0 0 .6rem !important;
    color: var(--ip-ink2);
    font-size: .92rem;
}

.sm-card-facts {
    display: grid;
    gap: .3rem;
    margin: 0 0 .8rem !important;
}

.sm-card-facts div {
    display: flex;
    gap: .5rem;
    font-size: .9rem;
}

.sm-card-facts dt {
    min-width: 4.3em;
    font-weight: 600;
    color: var(--ip-ink3);
}

.sm-card-facts dd {
    margin: 0;
    color: var(--ip-ink1);
}

.sm-rooms {
    margin: 0 0 .8rem !important;
    padding-left: 1.1rem;
    font-size: .9rem;
    color: var(--ip-ink2);
}

.sm-card .sm-card-go {
    align-self: flex-start;
    margin-top: auto;
}

.sm-card .sm-card-go[hidden] {
    display: none;
}


/* Campus explorer: quiet surfaces give the model and building names priority. */
.sm-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}
.sm-heading h2 { margin: .25rem 0 .4rem; font-family: var(--ip-fd); font-size: clamp(1.4rem, 2.5vw, 2rem); color: var(--ip-ink1); }
.sm-heading p { margin: 0; color: var(--ip-ink3); font-size: .93rem; }
.sm-heading .sm-kicker { color: var(--ip-blue); font-size: .78rem; font-weight: 700; letter-spacing: .04em; }
.sm-heading > .ip-pill { flex-shrink: 0; }
.sm-bar {
    padding: .55rem;
    margin-bottom: .8rem;
    border: 1px solid var(--ip-line);
    border-radius: 18px;
    background: var(--ip-card);
    box-shadow: 0 4px 20px rgba(22, 44, 61, .035);
}
.sm-tool { border-color: transparent; border-radius: 11px; font-size: .84rem; min-height: 42px; }
.sm-tool:first-child { background: var(--sm-on); color: var(--sm-on-ink); }
.sm-tool:first-child i { color: inherit; }
.sm.is-3d .sm-stage { height: clamp(440px, 70svh, 740px); }
.sm-stage { border-radius: 22px; box-shadow: 0 12px 35px rgba(22, 44, 61, .09); }
.sm-compass { top: 18px; left: 18px; }
.sm-fs { top: 18px; right: 18px; }
.sm-zoom { bottom: 18px; right: 18px; }
.sm-lbl { border-radius: 7px; box-shadow: 0 3px 12px rgba(22, 44, 61, .12); font-size: .76rem; padding: .28rem .6rem; }
.sm-lbl.is-bld { border-color: rgba(92, 112, 138, .25); }
.sm-pick {
    padding: 1rem;
    border: 1px solid var(--ip-line);
    border-radius: 20px;
    background: var(--ip-card);
}
.sm-pick-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem !important; color: var(--ip-ink1); }
.sm-pick-count { font-size: .73rem; font-weight: 500; color: var(--ip-ink3); }
.sm-chips { counter-reset: building; gap: .35rem; }
.sm-chip { border-color: transparent; border-radius: 10px; min-height: 43px; font-size: .82rem; font-weight: 500; }
.sm-chip[data-sm-go]:not([data-sm-go=""])::before {
    counter-increment: building;
    content: counter(building, decimal-leading-zero);
    display: grid;
    place-items: center;
    flex: 0 0 26px;
    height: 26px;
    font-size: .67rem;
    font-weight: 700;
    color: var(--sm-chip-color, var(--ip-blue));
    background: color-mix(in srgb, var(--sm-chip-color, var(--ip-blue)) 10%, var(--ip-card));
    border-radius: 7px;
}
.sm-chip[aria-pressed="true"]::before { color: inherit; background: rgba(255,255,255,.16); }
.sm-info { border-radius: 20px; box-shadow: none; background: color-mix(in srgb, var(--ip-blue) 3%, var(--ip-card)); }
.sm-info-hint { font-size: .85rem; line-height: 1.8; }
.sm-info-hint i { display: block; font-size: 1.25rem; color: var(--ip-blue); margin-bottom: .55rem; }
.sm-card { border-radius: 18px; }
.sm-card h3 { line-height: 1.6; }
@media (min-width: 960px) {
    .sm-body { grid-template-columns: minmax(0, 1fr) 270px; gap: 1rem; }
    .sm-chip { text-align: left; }
}
@media (max-width: 599px) {
    .sm-heading { align-items: start; flex-direction: column; }
    .sm-bar { gap: .2rem; }
    .sm-tool { padding: .4rem .65rem; font-size: .78rem; }
    .sm.is-3d .sm-stage { height: 480px; max-height: 72svh; }
    .sm-pick { padding: .75rem; }
    .sm-pick-h { margin-bottom: .5rem !important; }
}
.sm.is-3d .sm-stage:fullscreen {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
}
.sm.is-3d .sm-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
}
@media print { .sm-heading > .ip-pill { display: none; } }

/* Detailed plan: keep landscaping colours even with older global SVG rules. */
.sm-plan-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.9rem 1.1rem; background:var(--ip-card); border-bottom:1px solid var(--ip-line); }
.sm-plan-head > div { display:grid; gap:.15rem; }
.sm-plan-head span { font-size:.72rem; color:var(--ip-ink3); }
.sm-plan-head strong { font-size:.92rem; color:var(--ip-ink1); }
.sm-plan-direction { font-weight:700; white-space:nowrap; }
.sm-svg { background:#e9eee6; }
.sm-svg .sp-garden { fill:url(#sp-lawn); }
.sm-svg .sp-label text { font-family:var(--ip-fb); }
.sm-plan-cap { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.55rem; padding:.8rem 1rem; font-size:.73rem; }
.sm-plan-legend { display:flex; flex-wrap:wrap; gap:.8rem; }
.sm-plan-legend > span { display:inline-flex; gap:.35rem; align-items:center; }
.sm-plan-legend i { display:inline-block; width:.7rem; height:.7rem; border-radius:3px; background:#cbd6e1; border:1px solid rgba(40,65,50,.12); }
.sm-plan-legend .is-garden { background:#a3ba7a; }
.sm-plan-legend .is-flower { background:#e7859c; border-radius:50%; }
.sm-plan-legend .is-tree { background:#638b4e; border-radius:50%; }
.sm.is-3d.is-plan .sm-stage { height:clamp(740px, 94svh, 1040px); max-height:none; }
.sm.no-labels .sp-label { visibility:hidden; }
html.tb1-contrast-high .sm-svg .sp-label rect { fill:#fff; stroke:#111; stroke-width:.35; }
html.tb1-contrast-high .sm-svg .sp-label text { fill:#111; }
@media(max-width:599px) {
    .sm-plan-head { padding:.65rem .75rem; }
    .sm-plan-head strong { font-size:.8rem; }
    .sm.is-3d.is-plan .sm-stage { height:660px; max-height:none; }
    .sm-plan-cap { font-size:.68rem; padding:.6rem; }
}
@media print {
    .sm-svg { max-height:75vh; print-color-adjust:exact; -webkit-print-color-adjust:exact; }
    .sm-plan-head, .sm-plan-cap { color:#29434e; background:#fff; }
}

/* ═══ ความคมชัดสูง ═══ */
html.tb1-contrast-high .sm {
    --sm-bg: #000;
    --sm-ground: #000;
    --sm-lot: #1a1a1a;
    --sm-field: #0f3d14;
    --sm-field-text: #fff;
    --sm-road: #444;
    --sm-road-main: #333;
    --sm-fence: #facc15;
    --sm-ctx: #222;
    --sm-ctx-line: #fff;
    --sm-bld-line: #facc15;
    --sm-halo: #000;
    --sm-lbl-bg: #000;
    --sm-lbl-ink: #fff;
    --sm-on: #facc15;
    --sm-on-ink: #000;
}

html.tb1-contrast-high .sm :is(.sm-tool, .sm-chip, .sm-zbtn, .sm-compass, .sm-fs, .sm-info, .sm-note),
html.tb1-contrast-high .sm-card .sm-tbc {
    background: #000;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: none;
}

html.tb1-contrast-high .sm :is(.sm-tool, .sm-chip)[aria-pressed="true"] {
    background: #facc15;
    color: #000;
    border-color: #facc15;
}

html.tb1-contrast-high .sm-lbl {
    border: 2px solid #fff;
    box-shadow: none;
}

/* the site's high-contrast mode forces white text on every span: mark the chosen name with a thick yellow frame instead */
html.tb1-contrast-high .sm-lbl.is-on {
    background: #000;
    border: 3px solid #facc15;
}

html.tb1-contrast-high .sm-svg .p-bld {
    stroke-width: .8;
}

/* ═══ ลดการเคลื่อนไหว ═══ */
@media (prefers-reduced-motion: reduce) {
    .sm-spin {
        animation: none;
    }

    .sm-hint,
    .sm-tool,
    .sm-chip {
        transition: none;
    }
}

/* ═══ พิมพ์: ผัง 2 มิติ + รายการอาคาร ═══ */
@media print {
    .sm-bar,
    .sm-side,
    .sm-help,
    .sm-canvas,
    .sm-labels,
    .sm-compass,
    .sm-zoom,
    .sm-fs,
    .sm-hint,
    .sm-note,
    .sm-card-go {
        display: none !important;
    }

    .sm.is-3d .sm-plan,
    .sm.is-3d.is-plan .sm-plan {
        position: static;
        display: block !important;
    }

    .sm.is-3d .sm-stage,
    .sm-stage {
        height: auto !important;
        border: 1px solid #999;
        box-shadow: none;
    }

    .sm-svg {
        max-height: 60vh;
    }

    .sm-card {
        break-inside: avoid;
    }
}
