/* TerraKit mobile (iPhone / iOS Safari web app). Every rule is scoped to html.m, which is set only on touch screens
   up to 820 px wide, so desktop and laptop layouts never change. */
html.m{--m-ease:cubic-bezier(.22,1,.36,1);--m-top:calc(env(safe-area-inset-top) + 8px);--m-bot:env(safe-area-inset-bottom);--m-peek:118px;-webkit-text-size-adjust:100%}
html.m,html.m body{height:100%;overflow:hidden;overscroll-behavior:none;touch-action:manipulation}
html.m body{-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}
html.m input,html.m textarea,html.m select,html.m [contenteditable]{-webkit-user-select:text;user-select:text;font-size:16px!important}
html.m #map{position:fixed;inset:0;height:100dvh}

/* top bar: one slim pill */
html.m .topbar{top:var(--m-top);left:10px;right:10px;height:44px;padding:0 6px 0 12px;border-radius:14px;background:color-mix(in srgb,var(--panel) 92%,transparent);backdrop-filter:blur(18px) saturate(1.4);-webkit-backdrop-filter:blur(18px) saturate(1.4);box-shadow:0 8px 28px rgba(0,0,0,.28)}
html.m .topbar .brand span{font-size:14px}
html.m .topbar .brand em{display:none}
html.m .topbar-site{display:block!important;flex:1;min-width:0;margin:0 8px;font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:.85}
html.m .topbar-actions>.icon-btn{display:none}
html.m #mMore{display:grid;place-items:center;width:38px;height:38px;border:0;border-radius:11px;background:transparent;color:var(--ink)}
html.m #mMore svg{width:20px;height:20px}
#mMore,#mTools,#mScrim,.m-handle,#mMenu{display:none}

/* bottom sheet (the step panel) */
html.m .panel{position:fixed;top:auto;left:0;right:0;bottom:0;width:auto;height:calc(100dvh - var(--m-top) - 60px);border-radius:22px 22px 0 0;border:0;border-top:1px solid var(--line);
  transform:translate3d(0,calc(100% - var(--m-peek) - var(--m-bot)),0);transition:transform .46s var(--m-ease);will-change:transform;z-index:40;box-shadow:0 -14px 40px rgba(0,0,0,.35);display:flex;flex-direction:column;padding-bottom:var(--m-bot)}
html.m .panel.m-half{transform:translate3d(0,46%,0)}
html.m .panel.m-full{transform:translate3d(0,0,0)}
html.m .panel.m-drag{transition:none}
html.m .m-handle{display:block;flex:none;height:22px;cursor:grab;touch-action:none;position:relative}
html.m .m-handle:after{content:"";position:absolute;left:50%;top:8px;width:42px;height:5px;margin-left:-21px;border-radius:3px;background:var(--line-2,rgba(127,127,127,.5))}
html.m .stepper{flex:none;border-radius:0;touch-action:none}
html.m .stepper button{padding:8px 2px 7px}
html.m .stepper button span{display:block;font-size:10px}
html.m .steps{flex:1;min-height:0;overflow:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;padding-bottom:12px}
html.m .panel:not(.m-half):not(.m-full) .steps{overflow:hidden}
html.m .panel-nav{flex:none;position:relative;border-radius:0}
html.m .panel-nav .btn{min-height:42px}

/* floating tools button + tool grid */
html.m #mTools{display:grid;place-items:center;width:38px;height:38px;border-radius:11px;border:0;background:transparent;color:var(--ink);transition:background .2s}
html.m.m-tools #mTools{background:var(--solid,#111);color:var(--on-solid,#fff)}
html.m #mTools svg{width:19px;height:19px}
html.m .map-tools{position:fixed;top:calc(var(--m-top) + 50px);right:4px;left:4px;bottom:auto;display:grid;grid-template-columns:repeat(5,1fr);gap:8px;padding:12px;background:transparent;border:0;box-shadow:none;z-index:46;pointer-events:none}
html.m .map-tools .popover{pointer-events:auto}
html.m .map-tools>.tool,html.m .map-tools>.tool-wrap>.tool{width:100%;height:54px;border-radius:14px;border:1px solid var(--line);background:var(--panel);box-shadow:0 8px 22px rgba(0,0,0,.25);opacity:0;transform:translateY(-14px) scale(.92);transition:transform .38s var(--m-ease),opacity .22s;pointer-events:none}
html.m .map-tools>.tool[hidden]{display:none}
html.m .map-tools .tool svg{width:21px;height:21px}
html.m .map-tools .tool-wrap{display:contents}
html.m.m-tools .map-tools>.tool,html.m.m-tools .map-tools>.tool-wrap>.tool{opacity:1;transform:none;pointer-events:auto}
html.m.m-tools .map-tools>*:nth-child(2)>.tool,html.m.m-tools .map-tools>.tool:nth-child(2){transition-delay:.02s}
html.m.m-tools .map-tools>*:nth-child(3)>.tool,html.m.m-tools .map-tools>.tool:nth-child(3){transition-delay:.04s}
html.m.m-tools .map-tools>*:nth-child(4)>.tool,html.m.m-tools .map-tools>.tool:nth-child(4){transition-delay:.06s}
html.m.m-tools .map-tools>*:nth-child(5)>.tool,html.m.m-tools .map-tools>.tool:nth-child(5){transition-delay:.08s}
html.m.m-tools .map-tools>*:nth-child(n+6)>.tool,html.m.m-tools .map-tools>.tool:nth-child(n+6){transition-delay:.1s}
html.m .measure-chip{left:12px!important;right:auto!important;top:calc(var(--m-top) + 56px)!important;bottom:auto!important}
html.m .legend-chip{left:12px!important;right:12px!important;bottom:auto!important;top:calc(var(--m-top) + 54px)!important;display:flex!important;flex-wrap:nowrap;gap:12px;overflow-x:auto;white-space:nowrap;padding:6px 10px!important;font-size:10.5px!important;scrollbar-width:none}
html.m .legend-chip[hidden]{display:none!important}
html.m .smodal-card{width:auto!important;max-width:none!important;border-radius:0!important;box-shadow:none!important;border:0!important}

/* every popover / side panel becomes a bottom sheet with a scrim */
html.m #mScrim{display:block;position:fixed;inset:0;z-index:44;background:rgba(0,0,0,.42);opacity:0;pointer-events:none;transition:opacity .3s}
html.m.m-sheet-up #mScrim{opacity:1;pointer-events:auto}
html.m .popover,html.m .lyr-panel,html.m .plot-panel,html.m .menu,html.m #mMenu,html.m .bld-pop,html.m .pal-panel,html.m .smodal{position:fixed!important;left:0!important;right:0!important;top:auto!important;bottom:0!important;width:auto!important;max-width:none!important;max-height:min(80dvh,720px)!important;
  border-radius:22px 22px 0 0!important;padding-bottom:calc(var(--m-bot) + 14px)!important;overflow:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;z-index:45!important;box-shadow:0 -18px 50px rgba(0,0,0,.4)!important;animation:mUp .42s var(--m-ease)}
html.m .popover[hidden],html.m .lyr-panel[hidden],html.m .plot-panel[hidden],html.m .menu[hidden],html.m #mMenu[hidden],html.m .bld-pop[hidden],html.m .smodal[hidden],html.m .pal-panel[hidden]{display:none!important}
html.m .popover:before,html.m .lyr-panel:before,html.m .plot-panel:before,html.m .menu:before,html.m #mMenu:before{content:"";display:block;width:42px;height:5px;margin:8px auto 6px;border-radius:3px;background:var(--line-2,rgba(127,127,127,.5))}
html.m .plot-panel{max-height:88dvh!important}
@keyframes mUp{from{transform:translate3d(0,100%,0)}to{transform:none}}
html.m #mMenu{display:flex;flex-direction:column;gap:6px;padding:4px 14px calc(var(--m-bot) + 14px);background:var(--panel)}
html.m #mMenu button{display:flex;align-items:center;gap:12px;min-height:50px;padding:0 14px;border-radius:14px;border:1px solid var(--line);background:var(--surface,transparent);color:var(--ink);font:600 15px var(--font)}
html.m #mMenu button svg{width:20px;height:20px}
html.m #mMenu small{display:block;margin:6px 4px 2px;font-size:11px;opacity:.6;text-transform:uppercase;letter-spacing:.08em}
html.m .fxpop{width:auto}
html.m .fx-grid{grid-template-columns:repeat(4,1fr)}
html.m .pp-shapes{grid-template-columns:repeat(5,1fr)}
html.m .pp-shape{padding:9px 2px}
html.m .pm-tools button{min-width:34px;height:34px;font-size:15px}

/* map controls clear of the sheet */
html.m .maplibregl-ctrl-bottom-right{bottom:calc(var(--m-peek) + var(--m-bot) + 70px)}
html.m .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group{display:none}
html.m .maplibregl-ctrl-bottom-left{bottom:calc(var(--m-peek) + var(--m-bot))}
html.m #toasts{top:calc(var(--m-top) + 54px)!important;bottom:auto!important;left:12px!important;right:12px!important}

/* studio (report) full screen, thumb-friendly */
html.m .studio{position:fixed;inset:0;height:100dvh;padding-top:env(safe-area-inset-top)}
html.m .studio-bar{flex-wrap:wrap;gap:8px;padding:8px 10px}
html.m .studio-actions{gap:6px}
html.m .studio-actions select{display:none}
html.m .tabs{order:3;width:100%;margin:0;overflow-x:auto;scrollbar-width:none}
html.m .tabs::-webkit-scrollbar{display:none}
html.m .tabs button{flex:1 0 auto;padding:9px 12px}
html.m .gallery{grid-template-columns:1fr;padding:12px 12px calc(var(--m-bot) + 20px)}
html.m .bd-wrap{grid-template-columns:1fr;padding:12px;gap:12px;overflow:auto;height:100%}
html.m .bd-side{overflow:visible}
html.m .bd-themes{grid-template-columns:repeat(2,1fr)}
html.m .bd-view{min-height:60dvh;padding:8px}
html.m .bd-img{width:100%}
html.m .model-wrap{grid-template-columns:1fr!important;grid-template-rows:52% 48%!important}

/* smooth touch feedback */
html.m button,html.m .btn,html.m .tool{transition-property:transform,opacity,background,color;-webkit-touch-callout:none}
html.m button:active,html.m .btn:active,html.m .tool:active{transform:scale(.96)}
@media (prefers-reduced-motion:reduce){html.m .panel,html.m .map-tools .tool,html.m #mTools,html.m .popover{transition:none!important;animation:none!important}}
/* v19b fixes */
html.m .drawer{left:8px;right:8px;bottom:calc(var(--m-peek) + var(--m-bot) + 8px);height:210px;transform:translate3d(0,130%,0);opacity:0;pointer-events:none;transition:transform .42s var(--m-ease),opacity .25s;z-index:41}
html.m .drawer.on{transform:none;opacity:1;pointer-events:auto}
html.m.m-up .drawer.on{opacity:0;pointer-events:none}
html.m.m-studio .panel,html.m.m-studio .topbar,html.m.m-studio .map-tools,html.m.m-studio .legend-chip,html.m.m-studio .drawer{display:none!important}
html.m .studio{z-index:60}
html.m .legend-chip>*{display:inline-flex!important;align-items:center;gap:5px;flex:none}
html.m .map-tools{transition:background .3s,box-shadow .3s,backdrop-filter .3s;border-radius:20px}
html.m.m-tools .map-tools{background:color-mix(in srgb,var(--panel) 80%,transparent);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);box-shadow:0 18px 44px rgba(0,0,0,.35)}
html.m.m-tools .legend-chip,html.m.m-tools .measure-chip{opacity:0;pointer-events:none}
html.m #toasts{position:fixed!important;z-index:80!important;display:flex;flex-direction:column;align-items:stretch;transform:none!important}
html.m #toasts>*{max-width:none!important;width:auto!important;margin:0 0 6px!important}
/* style gallery on phones: pick a card, apply from a sticky bar */
html.m .smodal{display:block;background:var(--panel)!important;padding:0!important}
html.m .smodal-card{height:auto!important;min-height:0;display:flex;flex-direction:column}
html.m .smodal-body{display:flex!important;flex-direction:column;min-height:0}
html.m .sm-preview{display:flex!important;order:9;position:sticky;bottom:calc(-1 * (var(--m-bot) + 14px));z-index:3;flex:none;gap:8px;padding:10px 12px calc(var(--m-bot) + 12px)!important;border-right:0!important;border-top:1px solid var(--line);background:var(--panel);box-shadow:0 -10px 24px rgba(0,0,0,.25)}
html.m .sm-big{display:none!important}
html.m .sm-strip{height:14px;border-radius:7px;overflow:hidden}
html.m .sm-actions{display:grid!important;grid-template-columns:1fr 1fr 1.25fr;gap:6px;margin:0!important}
html.m .sm-actions .btn{min-height:46px;font-size:13.5px;justify-content:center;padding:0 6px}
html.m .sm-card{-webkit-tap-highlight-color:transparent}
html.m .sm-card.on,html.m .sm-card[aria-selected=true]{outline:2px solid var(--accent,#ff7a18);outline-offset:-2px}
html.m .sm-preview{position:fixed!important;left:0;right:0;bottom:0!important;z-index:48}
html.m .smodal-card,html.m .sm-list{overflow:visible!important}
html.m .sm-list{padding-bottom:150px!important}
html.m .smodal[hidden] .sm-preview{display:none!important}
