/* ============================================================================
   Mushrooms — Material 3 Expressive theme (ported from m3_expressive_v14).
   Colours come from the live M3 engine in app.js, which injects the
   --md-sys-color-* tokens into <style id="dyn">. This file maps the app's
   legacy design vars onto those tokens (so every component re-colours from the
   seed/scheme) and restyles all components to M3 Expressive. Three appearance
   modes (m3e / glass / glassplus) via html[data-appear]; scheme via data-mode.
   ============================================================================ */
:root{
/* shape + elevation + motion (M3) */
--r-none:0px;--r-xs:4px;--r-sm:8px;--r-md:12px;--r-lg:16px;--r-lgi:20px;
--r-xl:28px;--r-xli:32px;--r-xxl:48px;--r-full:9999px;
--e1:0 1px 2px rgb(0 0 0/.30),0 1px 3px 1px rgb(0 0 0/.15);
--e2:0 1px 2px rgb(0 0 0/.30),0 2px 6px 2px rgb(0 0 0/.15);
--e3:0 4px 8px 3px rgb(0 0 0/.15),0 1px 3px rgb(0 0 0/.30);
--m-spatial-fast:350ms cubic-bezier(.42,1.67,.21,.9);
--m-spatial:500ms cubic-bezier(.38,1.21,.22,1);
--m-effects:200ms cubic-bezier(.34,.8,.34,1);
--blur-amt:18px;
--glass-blur:saturate(165%) blur(var(--blur-amt));
--font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang TC",
"Noto Sans TC","Microsoft JhengHei",sans-serif;
/* Font Awesome duotone defaults. Colours are overridden live by the engine
   (mode-dependent tones of the seed's Tint palette — see faPair); both opacities
   are pinned to 1 so every icon is a solid two-tone, never transparent. */
--fa-primary-color:#612106;
--fa-secondary-color:#da6639;
--fa-primary-opacity:1;
--fa-secondary-opacity:1;
/* ---- legacy design vars mapped onto the M3 tokens (fallbacks = light seed) ---- */
--bg:var(--md-sys-color-background,#fafaf8);
--surface:var(--md-sys-color-surface-container-low,#ffffff);
--surface-2:var(--md-sys-color-surface-container-high,#f1efec);
--text:var(--md-sys-color-on-surface,#1c1917);
--muted:var(--md-sys-color-on-surface-variant,#78716c);
--border:var(--md-sys-color-outline-variant,#e7e5e4);
--accent:var(--md-sys-color-primary,#c2410c);
--accent-soft:var(--md-sys-color-primary-container,#fff1ea);
--on-accent:var(--md-sys-color-on-primary,#ffffff);
--shadow:var(--e1);
--radius:var(--r-xl);
/* semantic status colours (not seed-derived) */
--ok:#15803d;--ok-soft:#e9f6ed;--warn:#b45309;--warn-soft:#fdf3e3;
}
/* Static M3 tokens for the DEFAULT seed (#c2410c) in light mode — so first paint
   (before app.js injects <style id="dyn">) already shows the correct M3 colours
   instead of bare fallbacks. The live engine's later :root rule overrides these
   for the actual seed/scheme. */
:root{
--md-sys-color-primary:oklch(0.4000 0.1699 38.40);--md-sys-color-on-primary:oklch(1.0000 0.0383 38.40);
--md-sys-color-primary-container:oklch(0.9000 0.0909 38.40);--md-sys-color-on-primary-container:oklch(0.1000 0.0909 38.40);
--md-sys-color-secondary:oklch(0.4000 0.0578 38.40);--md-sys-color-on-secondary:oklch(1.0000 0.0130 38.40);
--md-sys-color-secondary-container:oklch(0.9000 0.0309 38.40);--md-sys-color-on-secondary-container:oklch(0.1000 0.0309 38.40);
--md-sys-color-tertiary:oklch(0.4000 0.1190 98.40);--md-sys-color-on-tertiary:oklch(1.0000 0.0268 98.40);
--md-sys-color-tertiary-container:oklch(0.9000 0.0636 98.40);--md-sys-color-on-tertiary-container:oklch(0.1000 0.0636 98.40);
--md-sys-color-error:oklch(0.4000 0.1955 27.00);--md-sys-color-on-error:oklch(1.0000 0.0440 27.00);
--md-sys-color-error-container:oklch(0.9000 0.1045 27.00);--md-sys-color-on-error-container:oklch(0.1000 0.1045 27.00);
--md-sys-color-background:oklch(0.9800 0.0017 38.40);--md-sys-color-on-background:oklch(0.1000 0.0031 38.40);
--md-sys-color-surface:oklch(0.9800 0.0017 38.40);--md-sys-color-on-surface:oklch(0.1000 0.0031 38.40);
--md-sys-color-surface-variant:oklch(0.9000 0.0094 38.40);--md-sys-color-on-surface-variant:oklch(0.3000 0.0161 38.40);
--md-sys-color-surface-container-lowest:oklch(1.0000 0.0013 38.40);--md-sys-color-surface-container-low:oklch(0.9600 0.0021 38.40);
--md-sys-color-surface-container:oklch(0.9400 0.0025 38.40);--md-sys-color-surface-container-high:oklch(0.9200 0.0028 38.40);
--md-sys-color-surface-container-highest:oklch(0.9000 0.0031 38.40);
--md-sys-color-outline:oklch(0.5000 0.0180 38.40);--md-sys-color-outline-variant:oklch(0.8000 0.0134 38.40);
}
html[data-mode="dark"],html[data-mode="black"]{
--ok:#4ade80;--ok-soft:#16301f;--warn:#fbbf24;--warn-soft:#33260f;
}
html[data-reduce="1"]{--m-spatial-fast:1ms linear;--m-spatial:1ms linear;--m-effects:1ms linear;}

*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent;}
button,input,select,textarea{font:inherit;color:inherit;}
html,body{height:100%;}
body{
font-family:var(--font);
background:var(--bg);
color:var(--text);
line-height:1.55;
font-size:15px;
display:flex;
flex-direction:column;
min-height:100dvh;
overscroll-behavior-y:contain;
transition:background var(--m-effects),color var(--m-effects);
}
:focus-visible{outline:2px solid var(--md-sys-color-primary,var(--accent));outline-offset:2px;border-radius:6px;}

/* glass field background + displacement filter defs (Liquid G / G+ only) */
.field-bg{display:none;position:fixed;inset:0;z-index:-1;
background:var(--md-sys-color-background,var(--bg));transition:background var(--m-effects);}
.glass-defs{position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;}
html[data-glass="1"] .field-bg{display:block;}

/* ---- Top app bar: the M3 Expressive v14 bar in every appearance mode
   (M3E = plain surface-container bar; Liquid G / G+ add the glass treatment). ---- */
header.app{
position:sticky;top:0;z-index:600;
display:flex;align-items:center;gap:12px;
width:calc(100% - 32px);max-width:760px;margin-inline:auto;
padding:max(env(safe-area-inset-top),12px) 20px 12px;
background:var(--md-sys-color-surface-container,var(--surface));
color:var(--md-sys-color-on-surface,var(--text));
transition:background var(--m-effects);
}
header.app h1{font-size:1.25rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
header.app .logo{font-size:1.4rem;line-height:1;}
header.app .net{margin-left:auto;font-size:12px;color:var(--muted);display:flex;align-items:center;gap:6px;flex:none;}
.dot{width:8px;height:8px;border-radius:50%;background:var(--muted);transition:background var(--m-effects);}
.dot.on{background:var(--ok);}
.dot.warn{background:#f59e0b;}
/* glass bar (Liquid G / G+) */
html[data-glass="1"] header.app{
position:sticky;top:max(env(safe-area-inset-top),10px);
margin:10px auto 0;width:calc(100% - 24px);max-width:760px;
border:1px solid color-mix(in srgb,var(--md-sys-color-on-surface) 12%,transparent);
border-radius:var(--r-full);padding:10px 18px;
background:color-mix(in srgb,var(--md-sys-color-surface-container) 56%,transparent);
-webkit-backdrop-filter:var(--glass-blur);backdrop-filter:var(--glass-blur);
box-shadow:inset 0 1px 0 rgb(255 255 255/.16),0 16px 44px -18px rgb(0 0 0/.45);
}
html[data-plus="1"] header.app{
-webkit-backdrop-filter:var(--glass-blur) url(#glass-blur);backdrop-filter:var(--glass-blur) url(#glass-blur);
box-shadow:inset 2px 2px 3px rgb(255 255 255/.42),inset -2px -2px 3px rgb(255 255 255/.42),0 18px 46px -18px rgb(0 0 0/.5);
}

/* Content canvas = the M3E v14 .wrap: a light `surface` block the panels sit on
   (in glass modes it goes translucent). The body behind it is darker
   (surface-container on desktop), giving the layered M3E depth. */
main{flex:1;width:100%;max-width:760px;margin:8px auto 0;padding:14px 16px 110px;
border-radius:var(--r-xl);corner-shape:squircle;}
html[data-appear=m3e] main{background:var(--md-sys-color-surface,#fff);}
html[data-glass="1"] main{background:color-mix(in srgb,var(--md-sys-color-surface-container) 24%,transparent);}
section.view{display:none;animation:fade var(--m-spatial);}
section.view.active{display:block;}
@keyframes fade{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:none;}}
html[data-reduce="1"] section.view.active{animation:none;}

.bar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:14px;}
.bar .grow{flex:1;}
h2.title{font-size:13px;font-weight:600;color:var(--muted);letter-spacing:.5px;
text-transform:uppercase;margin-bottom:12px;}

/* ---- M3 buttons ---- */
button,.btn{
position:relative;font-family:inherit;font-size:14px;font-weight:600;
border:1px solid var(--border);
background:var(--surface);color:var(--text);
padding:0 18px;height:42px;border-radius:var(--r-full);
cursor:pointer;overflow:hidden;isolation:isolate;
display:inline-flex;align-items:center;justify-content:center;gap:8px;
transition:border-radius var(--m-spatial),box-shadow var(--m-effects),background var(--m-effects);
}
button::before,.btn::before{content:"";position:absolute;inset:0;background:currentColor;opacity:0;
border-radius:inherit;transition:opacity var(--m-effects);z-index:-1;}
button:hover::before,.btn:hover::before{opacity:.08;}
button:active{border-radius:var(--r-md);}
button:active::before{opacity:.10;}
button.primary,.btn.primary{background:var(--md-sys-color-primary,var(--accent));
color:var(--md-sys-color-on-primary,#fff);border-color:transparent;}
button.ghost{background:transparent;border-color:transparent;color:var(--md-sys-color-primary,var(--accent));}
button.danger{background:transparent;color:var(--md-sys-color-error,#dc2626);
border-color:color-mix(in srgb,var(--md-sys-color-error,#dc2626) 45%,transparent);}
button.sm{padding:0 12px;height:34px;font-size:13px;}
/* explicit M3 button variants (appearance panel etc.) */
.m3-btn{position:relative;display:inline-flex;align-items:center;gap:8px;border:none;cursor:pointer;
height:44px;padding:0 24px;border-radius:var(--r-full);font-weight:600;font-size:.9rem;overflow:hidden;
isolation:isolate;transition:border-radius var(--m-spatial),box-shadow var(--m-effects);}
.m3-btn::before{content:"";position:absolute;inset:0;background:currentColor;opacity:0;border-radius:inherit;
transition:opacity var(--m-effects);z-index:-1;}
.m3-btn:hover::before{opacity:.08;}
.m3-btn:active{border-radius:var(--r-md);}
.m3-btn:active::before{opacity:.10;}
.m3-btn.filled{background:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);}
.m3-btn.tonal{background:var(--md-sys-color-secondary-container);color:var(--md-sys-color-on-secondary-container);}
.m3-btn.outlined{background:transparent;color:var(--md-sys-color-primary);
box-shadow:inset 0 0 0 1px var(--md-sys-color-outline);}
.m3-btn.text{background:transparent;color:var(--md-sys-color-primary);padding:0 16px;}
/* icon-only button (tune, etc.) */
.icon-btn{width:46px;height:46px;flex:none;border-radius:var(--r-full);border:none;cursor:pointer;
background:transparent;color:var(--md-sys-color-on-surface-variant,var(--muted));font-size:1.1rem;
display:inline-flex;align-items:center;justify-content:center;position:relative;overflow:hidden;}
.icon-btn::before{content:"";position:absolute;inset:0;background:currentColor;opacity:0;border-radius:inherit;
transition:opacity var(--m-effects);}
.icon-btn:hover::before{opacity:.08;}
.icon-btn:active::before{opacity:.12;}

/* ---- fields ---- */
select,input,textarea{
font-family:inherit;font-size:14px;width:100%;padding:11px 14px;
border:1px solid var(--border);border-radius:var(--r-sm);
background:var(--md-sys-color-surface-container-highest,var(--surface-2));color:var(--text);
}
select:focus,input:focus,textarea:focus{outline:none;border-color:var(--md-sys-color-primary,var(--accent));
box-shadow:inset 0 0 0 1px var(--md-sys-color-primary,var(--accent));}
input[readonly]{opacity:.55;cursor:not-allowed;}
input[type=range]{padding:0;width:100%;accent-color:var(--md-sys-color-primary,var(--accent));cursor:pointer;
background:transparent;border:none;box-shadow:none;}
input[type=color]{padding:0;border:none;background:none;}

/* ---- cards / lists ---- */
/* M3E surfaces are flat + tonal (no border, no shadow); depth comes from the
   tonal step against the lighter main/wrap surface. */
.card{background:var(--md-sys-color-surface-container,var(--surface));border-radius:var(--r-xl);
padding:20px;margin-bottom:14px;transition:background var(--m-effects);}
.empty{text-align:center;color:var(--muted);padding:48px 18px;border:1px dashed var(--border);
border-radius:var(--r-xl);font-size:14px;}
.mlist{display:flex;flex-direction:column;gap:10px;}
.mrow{background:var(--md-sys-color-surface-container-high,var(--surface-2));
border-radius:var(--r-lg);padding:12px 14px;display:flex;align-items:center;gap:12px;
transition:background var(--m-effects);}
.swatch{width:38px;height:38px;border-radius:var(--r-md);flex:none;
border:1px solid rgba(0,0,0,.12);display:flex;align-items:center;justify-content:center;font-size:16px;}
/* mushroom-swatch glyphs follow the swatch's own (inline) text colour for legibility */
.swatch .fa-duotone{--fa-primary-color:currentColor;--fa-secondary-color:currentColor;
--fa-primary-opacity:1;--fa-secondary-opacity:1;}
.mrow .info{flex:1;min-width:0;}
.mrow .info .nm{font-weight:600;font-size:14px;display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
.mrow .info .sub{font-size:12px;color:var(--muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tag{font-size:11px;padding:3px 9px;border-radius:var(--r-full);background:var(--md-sys-color-surface-container-highest,var(--surface-2));
color:var(--muted);font-weight:600;}
.tag.unknown{background:var(--warn-soft);color:var(--warn);}
.tag.ready{background:var(--ok-soft);color:var(--ok);}
.tag.respawn{background:var(--warn-soft);color:var(--warn);font-variant-numeric:tabular-nums;}
.tag.count{background:var(--md-sys-color-primary-container,var(--accent-soft));
color:var(--md-sys-color-on-primary-container,var(--accent));font-variant-numeric:tabular-nums;}
.mrow .acts{display:flex;gap:6px;flex:none;}
.iconbtn{width:38px;height:38px;padding:0;border-radius:var(--r-full);font-size:14px;}

#map{aspect-ratio:1/1;border-radius:var(--r-xl);border:1px solid var(--border);overflow:hidden;z-index:1;}
.map-msg{display:flex;align-items:center;justify-content:center;height:62vh;min-height:340px;text-align:center;
color:var(--muted);border:1px dashed var(--border);border-radius:var(--r-xl);padding:24px;}
.loc{font-size:12px;color:var(--muted);margin-top:8px;font-variant-numeric:tabular-nums;}

/* ---- guide: each topic is a collapsible subsection inside the 攻略速查 card.
   Reuses the .collapse mechanics; the head reads as a normal topic title (not the
   uppercase muted settings-section style). ---- */
#guideList .collapse{margin-bottom:0;}
#guideList .collapse-head{font-size:14.5px;font-weight:600;text-transform:none;letter-spacing:0;
color:var(--text);}
.guide-body{padding:2px 2px 10px;font-size:14px;color:var(--text);}
.guide-body p{margin-bottom:9px;}
.guide-body ul{margin:0 0 9px 18px;}
.guide-body li{margin-bottom:4px;}
.guide-body table{width:100%;border-collapse:collapse;font-size:12.5px;margin:6px 0 10px;}
.guide-body th,.guide-body td{border:1px solid var(--border);padding:5px 7px;text-align:right;}
.guide-body th:first-child,.guide-body td:first-child{text-align:left;}
.guide-body th{background:var(--md-sys-color-surface-container-high,var(--surface-2));font-weight:600;}
.guide-body .gsw{display:inline-block;width:.85em;height:.85em;border-radius:3px;
border:1px solid rgba(128,128,128,.55);vertical-align:-.08em;margin-right:.28em;}

/* ---- modal sheet ---- */
.modal-bg{position:fixed;inset:0;background:rgba(20,16,12,.45);z-index:800;display:none;align-items:flex-end;justify-content:center;}
.modal-bg.open{display:flex;}
.modal{background:var(--md-sys-color-surface-container-high,var(--surface));width:100%;max-width:520px;
border-radius:var(--r-xl) var(--r-xl) 0 0;padding:20px;max-height:88vh;overflow:auto;animation:rise var(--m-spatial);}
@media(min-width:560px){.modal-bg{align-items:center;}.modal{border-radius:var(--r-xl);}}
@keyframes rise{from{transform:translateY(24px);opacity:.6;}to{transform:none;opacity:1;}}
html[data-reduce="1"] .modal{animation:none;}
.modal h2{font-size:18px;margin-bottom:14px;}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:10px;}
.row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;}
.modal .foot{display:flex;gap:10px;margin-top:16px;}
.modal .foot button{flex:1;}

/* ---- chips ---- */
.chips{display:flex;gap:8px;flex-wrap:wrap;}
.chip{display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;cursor:pointer;
border-radius:var(--r-sm);background:var(--md-sys-color-surface-container,var(--surface));
color:var(--md-sys-color-on-surface-variant,var(--muted));
border:1px solid var(--md-sys-color-outline-variant,var(--border));font-weight:600;font-size:.85rem;
transition:background var(--m-effects),color var(--m-effects);}
.chip.on{background:var(--md-sys-color-secondary-container,var(--accent-soft));
color:var(--md-sys-color-on-secondary-container,var(--accent));border-color:transparent;}

/* ---- segmented control ---- */
.seg{display:inline-flex;background:var(--md-sys-color-surface-container-highest,var(--surface-2));
border-radius:var(--r-full);padding:4px;gap:4px;flex-wrap:wrap;}
.seg button{border:none;background:none;height:auto;cursor:pointer;display:inline-flex;align-items:center;gap:8px;
padding:9px 16px;border-radius:var(--r-full);font-weight:600;font-size:.875rem;
color:var(--md-sys-color-on-surface-variant,var(--muted));transition:background var(--m-effects),color var(--m-effects);}
.seg button::before{display:none;}
.seg button[aria-pressed=true]{background:var(--md-sys-color-primary,var(--accent));color:var(--md-sys-color-on-primary,#fff);}
@media (max-width:599.98px){.seg button:not([aria-pressed=true]) span{display:none;}}

.hint{font-size:12px;color:var(--muted);margin-top:-4px;margin-bottom:12px;}
.ocr-sug{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:-4px 0 12px;font-size:12px;color:var(--muted);
background:var(--md-sys-color-secondary-container,var(--accent-soft));border:1px solid var(--border);
border-radius:var(--r-sm);padding:7px 9px;}
.ocr-sug .k{flex:none;}
.ocr-sug-val{flex:1;min-width:0;color:var(--text);font-weight:600;word-break:break-all;}

/* ---- appearance panel (theme settings) ---- */
.field-block{margin-bottom:22px;}
.field-block>label{display:block;font-weight:600;font-size:.9rem;margin-bottom:10px;}
.seed-row{display:flex;align-items:center;gap:14px;flex-wrap:wrap;}
.seed-pick{position:relative;width:60px;height:60px;flex:none;border-radius:var(--r-lg);overflow:hidden;
box-shadow:var(--e1);cursor:pointer;border:none;padding:0;}
.seed-pick::before{display:none;}
.seed-pick input{position:absolute;inset:-20%;width:140%;height:140%;border:none;cursor:pointer;background:none;}
.seed-hex{font-variant-numeric:tabular-nums;font-weight:600;letter-spacing:.04em;color:var(--muted);}
.presets{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px;}
.cswatch{width:38px;height:38px;border-radius:var(--r-full);border:2px solid transparent;cursor:pointer;
box-shadow:var(--e1);padding:0;transition:transform var(--m-spatial-fast),border-color var(--m-effects);}
.cswatch::before{display:none;}
.cswatch:hover{transform:scale(1.08);}
.cswatch[aria-pressed=true]{border-color:var(--md-sys-color-on-surface,var(--text));}
.sub-label{display:block;font-size:.75rem;font-weight:600;margin:14px 0 8px;color:var(--muted);letter-spacing:.04em;}
.tune{margin-top:14px;padding:14px;border-radius:var(--r-lg);background:var(--md-sys-color-surface-container-high,var(--surface-2));
display:flex;flex-direction:column;gap:10px;}
.tune[hidden]{display:none;}
.tune-row{display:flex;align-items:center;gap:12px;}
.tune-row>span{width:1.2em;font-weight:600;font-size:.8rem;color:var(--muted);}
.tune-row input[type=range]{flex:1;}
.tune-row output{font-variant-numeric:tabular-nums;font-weight:600;min-width:2.6em;text-align:right;font-size:.8rem;color:var(--muted);}
.hex-in{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-weight:600;letter-spacing:.06em;
text-transform:uppercase;}
.range{display:flex;align-items:center;gap:14px;}
.range input[type=range]{flex:1;}
.range output{font-variant-numeric:tabular-nums;font-weight:600;min-width:3.4em;text-align:right;color:var(--muted);}
.range .ax{width:1.2em;font-weight:600;font-size:.8rem;color:var(--muted);}
.tune-btn{width:44px;height:44px;}
/* appearance-dependent field visibility (mirrors the reference) */
#linField,#radField{display:none;}
html[data-appear=m3e] #blurField,html[data-appear=m3e] #bgField,html[data-appear=m3e] #bgColorField{display:none;}
html[data-glass="1"][data-bg=linear] #linField{display:block;}
html[data-glass="1"][data-bg=radial] #radField{display:block;}

/* ---- bottom navigation bar (mobile) ---- */
.navbar{position:fixed;left:0;right:0;bottom:0;z-index:40;display:flex;justify-content:space-around;
padding:10px 8px max(env(safe-area-inset-bottom),10px);
background:var(--md-sys-color-surface-container,var(--surface));transition:background var(--m-effects);}
.navbar button{border:none;background:none;height:auto;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:4px;
padding:4px 6px;color:var(--md-sys-color-on-surface-variant,var(--muted));font-size:.72rem;font-weight:600;
transition:color var(--m-effects);}
.navbar button::before{display:none;}
.navbar .ind{display:flex;align-items:center;justify-content:center;width:64px;height:32px;border-radius:var(--r-full);
transition:background var(--m-spatial-fast);}
.navbar button i{font-size:1.2rem;}
.navbar button[aria-pressed=true]{color:var(--md-sys-color-on-secondary-container,var(--accent));}
.navbar button[aria-pressed=true] .ind{background:var(--md-sys-color-secondary-container,var(--accent-soft));}

/* ---- navigation rail (desktop) ---- */
.navrail{position:fixed;left:0;top:0;bottom:0;z-index:20;width:var(--rail-w,80px);display:none;
flex-direction:column;align-items:center;gap:14px;padding:76px 0 16px;
background:var(--md-sys-color-surface-container,var(--surface));
transition:background var(--m-effects),width var(--m-spatial);}
.rail-menu{margin-bottom:6px;}
.navrail button{border:none;background:none;height:auto;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:4px;
padding:4px;width:100%;font-size:.68rem;font-weight:600;text-align:center;line-height:1.15;
color:var(--md-sys-color-on-surface-variant,var(--muted));transition:color var(--m-effects);}
.navrail button::before{display:none;}
.navrail .ind{display:flex;align-items:center;justify-content:center;width:56px;height:32px;border-radius:var(--r-full);
transition:background var(--m-spatial-fast);}
.navrail button i{font-size:1.25rem;}
.navrail button[aria-pressed=true]{color:var(--md-sys-color-on-secondary-container,var(--accent));}
.navrail button[aria-pressed=true] .ind{background:var(--md-sys-color-secondary-container,var(--accent-soft));}
html[data-rail=expanded]{--rail-w:216px;}
html[data-rail=expanded] .navrail{align-items:stretch;padding:72px 12px 16px;gap:6px;}
html[data-rail=expanded] .navrail button{flex-direction:row;justify-content:flex-start;gap:14px;padding:12px 18px;
border-radius:var(--r-full);font-size:.92rem;line-height:1.2;}
html[data-rail=expanded] .navrail .ind{width:auto;height:auto;background:none;}
html[data-rail=expanded] .navrail button[aria-pressed=true]{background:var(--md-sys-color-secondary-container,var(--accent-soft));
color:var(--md-sys-color-on-secondary-container,var(--accent));}
html[data-rail=expanded] .rail-menu{align-self:flex-start;}
@media (min-width:600px){
.navbar{display:none;}
.navrail{display:flex;}
body{padding-left:var(--rail-w,80px);}
main{padding-bottom:40px;}
footer.privacy{padding-bottom:40px;}
html[data-appear=m3e] body{background:var(--md-sys-color-surface-container,var(--surface));}
html[data-appear=m3e] main{min-height:calc(100dvh - 64px);}
}
/* glassplus floating pill navbar */
html[data-appear=glassplus] .navbar{left:50%;right:auto;transform:translateX(-50%);
bottom:max(env(safe-area-inset-bottom),16px);width:auto;justify-content:center;gap:4px;
border-radius:var(--r-full);padding:8px 10px;}

.toast{position:fixed;bottom:96px;left:50%;transform:translateX(-50%) translateY(20px);
background:var(--md-sys-color-inverse-surface,var(--text));color:var(--md-sys-color-inverse-on-surface,var(--bg));
padding:11px 18px;border-radius:var(--r-full);font-size:13px;z-index:900;opacity:0;transition:.25s;
pointer-events:none;max-width:90%;text-align:center;box-shadow:var(--e2);}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);}
.update-banner{position:fixed;left:12px;right:12px;bottom:88px;z-index:850;display:none;align-items:center;gap:12px;
justify-content:center;flex-wrap:wrap;background:var(--md-sys-color-primary,var(--accent));
color:var(--md-sys-color-on-primary,#fff);padding:12px 16px;font-size:13px;font-weight:600;
max-width:736px;margin:0 auto;border-radius:var(--r-lg);box-shadow:var(--e2);}
.update-banner.show{display:flex;}
.update-banner button{background:#fff;color:var(--md-sys-color-primary,var(--accent));border:none;font-weight:600;height:34px;padding:0 14px;}
@media (min-width:600px){.update-banner{left:calc(var(--rail-w,80px) + 12px);}}

.sel-mode .mrow{cursor:pointer;}
.mrow.picked{background:var(--md-sys-color-secondary-container,var(--accent-soft));
box-shadow:inset 0 0 0 2px var(--md-sys-color-primary,var(--accent));}
.divider{height:1px;background:var(--border);margin:16px 0;}
.kv{display:flex;justify-content:space-between;font-size:13px;padding:4px 0;}
.kv span:first-child{color:var(--muted);}
/* settings sub-section label */
.sublabel{font-size:12px;font-weight:600;color:var(--muted);letter-spacing:.3px;margin-bottom:8px;}
/* collapsible settings section (collapsed by default) */
.collapse{margin-bottom:12px;}
.collapse>.collapse-head{display:flex;align-items:center;gap:8px;width:100%;height:auto;cursor:pointer;
background:none;border:none;border-radius:0;padding:0;margin:0 0 10px;font:inherit;font-size:13px;font-weight:600;
color:var(--muted);letter-spacing:.5px;text-transform:uppercase;}
.collapse>.collapse-head::before{display:none;}
.collapse>.collapse-head .chev{margin-left:auto;color:var(--muted);transition:transform var(--m-spatial-fast);font-size:13px;}
.collapse.open>.collapse-head .chev{transform:rotate(90deg);}
.collapse>.collapse-body{display:none;}
.collapse.open>.collapse-body{display:block;}

footer.privacy{font-size:11px;color:var(--muted);line-height:1.6;padding:20px 16px 120px;max-width:760px;margin:0 auto;
border-top:1px solid var(--border);}
footer.privacy b{color:var(--text);font-weight:600;}
footer.privacy ul{margin:6px 0 0 16px;}
footer.privacy .foot-toggle{display:flex;align-items:center;gap:8px;width:100%;height:auto;background:none;border:none;
border-radius:0;padding:0;margin:0;cursor:pointer;font-size:11px;color:var(--muted);}
footer.privacy .foot-toggle::before{display:none;}
footer.privacy .foot-toggle .foot-right{margin-left:auto;display:flex;align-items:center;gap:10px;}
footer.privacy .foot-toggle .chev{color:var(--muted);transition:transform var(--m-spatial-fast);font-size:10px;}
footer.privacy.open .foot-toggle .chev{transform:rotate(90deg);}
footer.privacy .foot-body{display:none;}
footer.privacy.open .foot-body{display:block;}
footer.privacy .foot-ver{white-space:nowrap;}

.qr-box{display:flex;justify-content:center;padding:8px 0;}
#qrCanvas,#inviteCanvas{width:100%;max-width:320px;height:auto;image-rendering:pixelated;border:1px solid var(--border);border-radius:var(--r-sm);background:#fff;}
#qrVideo{width:100%;max-width:360px;border-radius:var(--r-sm);background:#000;}
#qrTxpImg{width:100%;max-width:320px;height:auto;image-rendering:pixelated;border:1px solid var(--border);border-radius:var(--r-sm);background:#fff;}
#qrFileBox i{font-size:54px;color:var(--muted);}
label.f{display:block;margin-bottom:12px;}
label.f span{display:block;font-size:12px;color:var(--muted);margin-bottom:5px;font-weight:600;}

.leaflet-popup-content{font-family:var(--font);font-size:13px;}
.pop b{font-size:14px;}
.pop button{margin-top:8px;}
/* SVG markers: size=shape, status=outline colour, type=fill */
.mk-icon{background:none;border:none;}
.mk-icon svg{display:block;filter:drop-shadow(0 1px 1.5px rgba(0,0,0,.35));}

/* ---- glass layers (Liquid G / G+) ---- */
html[data-glass="1"] .card,
html[data-glass="1"] .modal,
html[data-glass="1"] .navbar,
html[data-glass="1"] .navrail{
background:color-mix(in srgb,var(--md-sys-color-surface-container) 56%,transparent);
-webkit-backdrop-filter:var(--glass-blur);backdrop-filter:var(--glass-blur);
border:1px solid color-mix(in srgb,var(--md-sys-color-on-surface) 12%,transparent);
box-shadow:inset 0 1px 0 rgb(255 255 255/.16),0 16px 44px -18px rgb(0 0 0/.45);}
html[data-glass="1"] .mrow,
html[data-glass="1"] .acc,
html[data-glass="1"] .seg,
html[data-glass="1"] .chip,
html[data-glass="1"] .tune,
html[data-glass="1"] .ocr-sug{
background:color-mix(in srgb,var(--md-sys-color-surface-container-highest) 50%,transparent);}
html[data-plus="1"] .card,
html[data-plus="1"] .modal,
html[data-plus="1"] .navbar,
html[data-plus="1"] .navrail{
-webkit-backdrop-filter:var(--glass-blur) url(#glass-blur);backdrop-filter:var(--glass-blur) url(#glass-blur);
box-shadow:inset 2px 2px 3px rgb(255 255 255/.42),inset -2px -2px 3px rgb(255 255 255/.42),0 18px 46px -18px rgb(0 0 0/.5);}

/* ---- Small-screen mode: minimal map + edit for a tiny floating window ---- */
.small{display:none;}
body.small-mode>header.app,
body.small-mode>main,
body.small-mode>nav.tabs,
body.small-mode>.navbar,
body.small-mode>.navrail,
body.small-mode>footer.privacy,
body.small-mode>.update-banner,
body.small-mode>.field-bg,
body.small-mode>.modal-bg{display:none!important;}
body.small-mode{padding-left:0;}
body.small-mode>.small{display:block;}
.small{position:fixed;inset:0;z-index:1000;background:var(--bg);}
.sm-view{display:none;position:absolute;inset:0;flex-direction:column;padding:4px;gap:4px;}
.sm-view.active{display:flex;}
.sm-bar{display:flex;gap:4px;flex:0 0 auto;}
.sm-bar button{flex:1;min-width:0;height:auto;justify-content:center;padding:8px 4px;border-radius:var(--r-sm);}
#smMap{flex:1 1 auto;min-height:0;border-radius:var(--r-sm);border:1px solid var(--border);overflow:hidden;z-index:1;background:var(--surface-2);}
.sm-form{display:flex;flex-direction:column;gap:4px;height:100%;min-height:0;overflow:auto;}
.sm-form>*{flex:0 0 auto;}
.sm-form select,.sm-form input{padding:8px;border-radius:var(--r-sm);font-size:14px;}
.sm-form button{padding:8px;border-radius:var(--r-sm);font-size:14px;height:auto;}
.sm-form .sm-x{align-self:flex-end;width:auto;padding:6px 8px;}
.sm-foot{display:flex;gap:4px;margin-top:2px;}
.sm-foot button{flex:1;}
.sm-row3{display:flex;gap:4px;}
.sm-row3 input{flex:1;min-width:0;width:auto;text-align:center;padding:6px 2px;}
.sm-row3 input::-webkit-outer-spin-button,.sm-row3 input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}
.sm-row3 input[type=number]{-moz-appearance:textfield;appearance:textfield;}
@media(max-width:200px),(max-height:200px){
.sm-view{padding:2px;gap:2px;}
.sm-bar{gap:2px;}
.sm-bar button{padding:3px 2px;font-size:12px;}
.sm-form{gap:2px;}
.sm-form select,.sm-form input,.sm-form button{padding:3px 4px;font-size:11px;border-radius:6px;}
.sm-foot button span,.sm-bar button span{display:none;}
.sm-row3{gap:2px;}
.sm-form .sm-x{padding:2px 5px;}
#smMap{border-radius:6px;}
}

/* ---- Group bookshelf ---- */
.bs-card .bs-head{display:flex;align-items:center;gap:8px;margin-bottom:6px;}
.bs-card .bs-name{font-weight:600;font-size:15px;word-break:break-word;}
.bs-role{font-size:11px;padding:2px 8px;border-radius:var(--r-full);background:var(--md-sys-color-secondary-container,var(--accent-soft));
color:var(--md-sys-color-on-secondary-container,var(--accent));white-space:nowrap;}
.bs-status{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);margin-bottom:10px;}
.bs-members{margin-top:4px;}
.bs-missing-row{opacity:.95;}
