:root {
  --bg: #f1e6d2;
  --surface: #fbf4e7;
  --ink: #2f2118;
  --muted: #7b6553;
  --line: #e2d2b9;
  --accent: #d9702a;
  --accent-ink: #fff8ef;
  --sky: #f7e3bd;
  --orb: #f4b860;
  --hills: #c9c08a;
  --grass: #8c9a4a;
  --soil-1: #b67d4b;
  --soil-2: #96603a;
  --soil-3: #74462b;
  --pebble: #cfa77a;
  --root: #5e3b24;
  --tunnel: #3d2518;
  --tunnel-edge: #84532f;
  --hole: #170d07;
  --glow: #ffb15c;
  --mouse: #a69688;
  --mouse-dark: #7d6c5f;
  --belly: #ece1d3;
  --ear-in: #e8a49b;
  --nose: #d46d63;
  --eye: #1d140e;
  --tail: #c99d92;
  --shadow: rgba(47, 33, 24, .18);
  --paper: #fffaf0;
  --sack: #d8b98a;
  --sack-knot: #6b4a2c;
  --track: #e6d6bd;
  --folder-bg: #ecd3aa;
  --folder-door: #9a6234;
  --relic-wood: #6e4325;
  --relic-metal: #8d7f72;
  --relic-dark: #4a2d19;
  --relic-gold: #c99a3e;
  --relic-clay: #a65a36;
  --relic-stone: #7f5434;
  --castle: #a99f6c;
  --label-soil: #f3d9b8;
  --t-img: #6c9a57;
  --t-vid: #c4593a;
  --t-doc: #4a7aa0;
  --t-arc: #b38b25;
  --t-other: #8e7b6a;
  --f-display: "Pangolin", "Comic Sans MS", "Segoe Print", cursive;
  --f-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18110c; --surface: #231912; --ink: #f2e5d3; --muted: #b39b84; --line: #3a2a1e;
    --accent: #f0904a; --accent-ink: #1d120a;
    --sky: #1d2133; --orb: #efe3c2; --hills: #2c3324; --grass: #4c5a2a;
    --soil-1: #5b3b24; --soil-2: #482c1a; --soil-3: #351f12; --pebble: #73513a; --root: #2a170c;
    --tunnel: #130905; --tunnel-edge: #6a4126; --hole: #000; --glow: #ffa64a;
    --mouse: #b3a497; --mouse-dark: #8a786a; --belly: #e6dacb; --shadow: rgba(0,0,0,.4);
    --paper: #f6ecd9; --sack: #c8a676; --track: #3a2b20; --label-soil: #e8c9a3; --folder-bg: #4a3322; --folder-door: #d69a5c; --relic-wood: #3e2414; --relic-metal: #6b5f55; --relic-dark: #1f110a; --relic-gold: #9c7832; --relic-clay: #6f3a22; --relic-stone: #4a2f1d; --castle: #252b1d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18110c; --surface: #231912; --ink: #f2e5d3; --muted: #b39b84; --line: #3a2a1e;
  --accent: #f0904a; --accent-ink: #1d120a;
  --sky: #1d2133; --orb: #efe3c2; --hills: #2c3324; --grass: #4c5a2a;
  --soil-1: #5b3b24; --soil-2: #482c1a; --soil-3: #351f12; --pebble: #73513a; --root: #2a170c;
  --tunnel: #130905; --tunnel-edge: #6a4126; --hole: #000; --glow: #ffa64a;
  --mouse: #b3a497; --mouse-dark: #8a786a; --belly: #e6dacb; --shadow: rgba(0,0,0,.4);
  --paper: #f6ecd9; --sack: #c8a676; --track: #3a2b20; --label-soil: #e8c9a3; --folder-bg: #4a3322; --folder-door: #d69a5c; --relic-wood: #3e2414; --relic-metal: #6b5f55; --relic-dark: #1f110a; --relic-gold: #9c7832; --relic-clay: #6f3a22; --relic-stone: #4a2f1d; --castle: #252b1d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; }
.app { max-width: 1180px; margin: 0 auto; padding-inline: 16px; padding-block: 22px 48px; display: flex; flex-direction: column; gap: 18px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-family: var(--f-display); font-weight: 400; font-size: 34px; line-height: 1; margin: 0; letter-spacing: .3px; }
.brand svg { width: 40px; height: 28px; flex: none; }
.top p { margin: 0; color: var(--muted); max-width: 60ch; text-wrap: pretty; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 20px; align-items: start; }
@media (max-width: 880px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.scene-wrap { position: relative; width: 100%; aspect-ratio: 800 / 560; border-radius: 22px; overflow: hidden; background: var(--sky); box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px var(--shadow); outline: 3px dashed transparent; outline-offset: -3px; transition: outline-color .2s; }
body.dragging .scene-wrap { outline-color: var(--accent); }
#scene { display: block; width: 100%; height: 100%; }

.bubble { position: absolute; left: 66.5%; top: 19%; transform: translate(-18%, -100%); background: var(--paper); color: #2f2118; font-family: var(--f-display); font-size: clamp(13px, 1.9vw, 18px); line-height: 1.15; padding: 8px 12px; border-radius: 14px; box-shadow: 0 6px 16px -8px var(--shadow); max-width: min(46%, 260px); text-wrap: balance; pointer-events: none; animation: pop .25s cubic-bezier(.3,1.6,.5,1); }
.bubble::after { content: ""; position: absolute; left: 18%; bottom: -7px; width: 14px; height: 14px; background: var(--paper); transform: rotate(45deg); border-radius: 2px; }
@keyframes pop { from { transform: translate(-18%, -90%) scale(.85); opacity: 0; } }

.drop-veil { position: fixed; inset: 0; z-index: 40; pointer-events: none; display: grid; place-items: start center; padding-top: calc(18px + env(safe-area-inset-top, 0px)); background: color-mix(in srgb, var(--accent) 7%, transparent); opacity: 0; transition: opacity .2s; }
.drop-veil span { font-family: var(--f-display); font-size: 20px; background: var(--accent); color: var(--accent-ink); padding: 8px 18px; border-radius: 999px; box-shadow: 0 10px 24px -12px var(--shadow); }
body.dragging .drop-veil { opacity: 1; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 700 14px/1 var(--f-body); padding: 11px 16px; border-radius: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform .12s, background .2s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn svg { width: 18px; height: 18px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--track); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px var(--shadow); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }
.spacer { flex: 1 1 auto; }
.note { margin: 0; color: var(--muted); font-size: 13px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.summary { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 590px; overflow-y: auto; }
.item.enter { animation: rowIn .35s ease; }
.item:hover { background: color-mix(in srgb, var(--track) 45%, transparent); }
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } }
.badge { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font: 500 10px/1 var(--f-mono); color: #fff; letter-spacing: .4px; background: var(--kind); }
.k-img { --kind: var(--t-img); } .k-vid { --kind: var(--t-vid); } .k-doc { --kind: var(--t-doc); } .k-arc { --kind: var(--t-arc); } .k-other { --kind: var(--t-other); }
.meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 6px; background: var(--track); color: var(--muted); }
.bar { height: 5px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--kind); border-radius: inherit; }
.item[data-status="paused"] .bar i { opacity: .45; }
.item[data-status="done"] .bar { display: none; }
.acts { display: flex; gap: 6px; }
.act { appearance: none; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 700 12.5px/1 var(--f-body); padding: 8px 10px; border-radius: 10px; cursor: pointer; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-family: var(--f-display); font-size: 22px; line-height: 1.2; min-width: 0; }
.crumb { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; padding: 3px 7px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .15s, color .15s; }
.crumb:hover { background: var(--track); color: var(--ink); }
.crumb.current { color: var(--ink); cursor: default; }
.crumb.current:hover { background: none; }
.crumb svg { width: 24px; height: 17px; flex: none; }
.crumb-sep { color: var(--muted); opacity: .55; font-size: 18px; }
.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.small svg { width: 15px; height: 15px; }
.ficon { width: 40px; height: 40px; display: block; }
.ficon .bg { fill: var(--folder-bg); }
.ficon .door { fill: var(--folder-door); }
.chev { color: var(--muted); font-size: 22px; line-height: 1; padding-right: 4px; transition: transform .15s; }
.fmoving { color: var(--accent); font-weight: 700; }
.drop-target { background: color-mix(in srgb, var(--accent) 16%, transparent) !important; box-shadow: inset 0 0 0 2px var(--accent); }
.crumb.drop-target { color: var(--ink); }
.item[draggable="true"] { cursor: grab; }
.item.dragging-row { opacity: .4; }
.item.fresh { animation: fresh 1.2s ease; }
@keyframes fresh { 0%, 40% { background: color-mix(in srgb, var(--accent) 20%, transparent); } }
.draft input { width: 100%; min-width: 0; font: 700 15px var(--f-body); color: var(--ink); background: var(--bg); border: 1.5px solid var(--accent); border-radius: 10px; padding: 8px 10px; outline: none; }
.draft .hint { font-size: 12px; color: var(--muted); }
.empty { list-style: none; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 26px 14px; color: var(--muted); border: 2px dashed var(--line); border-radius: 16px; }
.empty svg { width: 64px; height: 40px; }
.empty strong { font-family: var(--f-display); font-weight: 400; font-size: 21px; color: var(--ink); }

.kebab { appearance: none; border: 0; background: none; color: var(--muted); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; margin-right: 4px; }
.kebab:hover, .kebab[aria-expanded="true"] { background: var(--track); color: var(--ink); }
.kebab svg { width: 18px; height: 18px; }
.menu { position: fixed; z-index: 70; min-width: 220px; max-width: min(300px, calc(100vw - 16px)); max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 18px 40px -16px var(--shadow); display: flex; flex-direction: column; gap: 2px; animation: menuIn .14s ease; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } }
.menu button { appearance: none; border: 0; background: none; color: var(--ink); font: 600 14px var(--f-body); text-align: left; padding: 9px 10px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu button:hover, .menu button:focus-visible { background: var(--track); outline: none; }
.menu button[disabled] { opacity: .4; cursor: default; background: none; }
.menu .danger { color: var(--t-vid); }
.menu kbd { margin-left: auto; font: 500 11px var(--f-mono); color: var(--muted); }
.menu .menu-title { font-size: 12px; color: var(--muted); padding: 6px 10px 4px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; width: auto; }

.flycard { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 7px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 30px -14px var(--shadow); white-space: nowrap; font-weight: 700; font-size: 13px; will-change: transform, opacity; }
.fc-badge { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font: 500 8.5px/1 var(--f-mono); color: #fff; background: var(--kind); }
.flycard.heavy { background: var(--sack); color: #3a2614; border-color: transparent; border-radius: 16px 16px 28px 28px; padding: 12px 18px 14px 12px; font-size: 14px; }

.toasts { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 440px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: 0 12px 28px -12px var(--shadow); animation: toastIn .3s cubic-bezier(.3,1.4,.5,1); max-width: 100%; }
.toast { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.toast-act { appearance: none; border: 0; background: var(--accent); color: var(--accent-ink); font: 800 13px/1 var(--f-body); padding: 7px 11px; border-radius: 8px; cursor: pointer; margin-left: auto; }
.toast code { flex-basis: 100%; display: block; margin-top: 0; font: 500 12px/1.3 var(--f-mono); opacity: .8; user-select: all; overflow-wrap: anywhere; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

#scene .sky { fill: var(--sky); }
#scene .orb { fill: var(--orb); }
#scene .hills { fill: var(--hills); }
#scene .grass { fill: var(--grass); }
#scene .soil1 { fill: var(--soil-1); }
#scene .soil2 { fill: var(--soil-2); }
#scene .soil3 { fill: var(--soil-3); }
#scene .pebble { fill: var(--pebble); }
#scene .root { fill: none; stroke: var(--root); stroke-width: 2.4; stroke-linecap: round; }
#scene .tunnel-edge { fill: none; stroke: var(--tunnel-edge); stroke-width: 36; stroke-linecap: round; }
#scene .tunnel { fill: none; stroke: var(--tunnel); stroke-width: 27; stroke-linecap: round; }
#scene .chamber-edge { fill: var(--tunnel-edge); }
#scene .chamber { fill: var(--tunnel); }
#scene .chamber-floor { fill: color-mix(in srgb, var(--tunnel-edge) 45%, var(--tunnel)); }
#scene .ruler line { stroke: var(--label-soil); stroke-width: 1.5; opacity: .7; }
#scene .ruler text, #scene .label { fill: var(--label-soil); font: 500 11px var(--f-mono); }
#scene .label-big { fill: var(--label-soil); font: 15px var(--f-display); }
#scene .depth path, #scene .depth rect { fill: var(--accent); }
#scene .depth text { fill: var(--accent-ink); font: 500 12px var(--f-mono); }
#scene .rim { fill: var(--soil-1); }
#scene .hole-g { transform-box: fill-box; transform-origin: 50% 50%; transition: transform .3s cubic-bezier(.3,1.5,.5,1); }
#scene .hole-g.hungry { transform: scale(1.32, 1.5); }
#scene .hole-g.gulp { animation: gulp .38s ease; }
@keyframes gulp { 35% { transform: scale(1.42, 1.65); } 100% { transform: scale(1); } }
#scene .glow { opacity: .35; transition: opacity .3s; }
body.dragging #scene .glow, .scene-wrap[data-state="busy"] #scene .glow { opacity: .9; }
#scene .sack-body { fill: var(--sack); stroke: var(--kind); stroke-width: 2.2; }
#scene .sack-knot { fill: none; stroke: var(--sack-knot); stroke-width: 2; stroke-linecap: round; }
#scene .sack-f.paused { opacity: .55; }
#scene .rubble path { fill: var(--soil-2); stroke: var(--tunnel-edge); stroke-width: 1.5; }
#scene .lamp-glow { opacity: .8; }

.mouse .fur { fill: var(--mouse); }
.mouse .fur-dark { fill: var(--mouse-dark); }
.mouse .belly { fill: var(--belly); }
.mouse .ear-in { fill: var(--ear-in); }
.mouse .nose { fill: var(--nose); }
.mouse .eye-dot { fill: var(--eye); }
.mouse .shine { fill: #fff; }
.mouse .eye-closed { fill: none; stroke: var(--eye); stroke-width: 1.6; stroke-linecap: round; }
.mouse .whiskers path { fill: none; stroke: var(--mouse-dark); stroke-width: .8; stroke-linecap: round; }
.mouse .tail { fill: none; stroke: var(--tail); stroke-width: 3.2; stroke-linecap: round; }
.mouse .shadow { fill: var(--shadow); }
.mouse .zzz text { fill: var(--label-soil); font: 15px var(--f-display); }
.mouse .dirt circle { fill: var(--soil-1); }
.mouse .note rect { fill: var(--paper); stroke: var(--mouse-dark); stroke-width: .8; }
.mouse .note path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.mouse .sackm path:first-child { fill: var(--sack); stroke: var(--sack-knot); stroke-width: 1.4; }
.mouse .sackm path + path { fill: none; stroke: var(--sack-knot); stroke-width: 1.8; stroke-linecap: round; }

.mouse .body-g, .mouse .headg, .mouse .ears, .mouse .tail, .mouse .eye, .mouse .whiskers, .mouse .paw-wave, .mouse .zzz text, .mouse .dirt circle { transform-box: fill-box; }
.mouse .body-g { transform-origin: 50% 100%; transition: transform .35s cubic-bezier(.3,1.4,.5,1); }
.mouse .headg { transform-origin: 70% 80%; transition: transform .3s; }
.mouse .ears { transform-origin: 50% 100%; transition: transform .25s; }
.mouse .tail { transform-origin: 0% 100%; animation: sway 2.6s ease-in-out infinite; }
.mouse .eye { transform-origin: 50% 50%; animation: blink 4.2s infinite; }
.mouse .whiskers { transform-origin: 100% 50%; animation: twitch 3.4s infinite; }
.mouse .eye-closed, .mouse .zzz, .mouse .dirt, .mouse .note, .mouse .sackm, .mouse .paw-wave { display: none; }

.m-alert .body-g { transform: rotate(-6deg); }
.m-alert .ears { transform: scale(1.18); }
.m-alert .tail { animation-duration: .9s; }
.m-wave .body-g { transform: rotate(-9deg) translateX(-3px); }
.m-wave .ears { transform: scale(1.22); }
.m-wave .tail { animation-duration: .6s; }
.m-wave .paw-wave, .m-celebrate .paw-wave { display: inline; transform-origin: 100% 100%; animation: wave .4s ease-in-out infinite alternate; }
.m-wave .paw-rest, .m-celebrate .paw-rest { display: none; }
.m-sleep .eye { display: none; }
.m-sleep .eye-closed, .m-sleep .zzz { display: inline; }
.m-sleep .body-g { animation: breathe 2.4s ease-in-out infinite; }
.m-sleep .headg { transform: rotate(9deg) translateY(3px); }
.m-sleep .tail { animation-duration: 5s; }
.m-sleep .whiskers { animation: none; }
.m-sleep .zzz text { animation: zfloat 2.4s ease-in infinite; }
.m-sleep .zzz text:nth-child(2) { animation-delay: .8s; }
.m-sleep .zzz text:nth-child(3) { animation-delay: 1.6s; }
.m-dig .body-g { animation: dig .3s ease-in-out infinite alternate; }
.m-dig .dirt { display: inline; }
.m-dig .dirt circle { animation: kick .6s ease-out infinite; }
.m-dig .dirt circle:nth-child(2) { animation-delay: .15s; }
.m-dig .dirt circle:nth-child(3) { animation-delay: .3s; }
.m-dig .dirt circle:nth-child(4) { animation-delay: .45s; }
.m-celebrate .body-g { animation: hop .5s cubic-bezier(.3,.7,.4,1) 3; }
.m-share .note { display: inline; }
.m-share .body-g { animation: hop .6s ease 1; }
.m-share .ears { transform: scale(1.1); }
.m-heave .sackm { display: inline; }
.m-heave .body-g { animation: push .22s ease-in-out infinite alternate; }

@keyframes sway { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(9deg); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes twitch { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-7deg); } 90% { transform: rotate(5deg); } }
@keyframes wave { from { transform: rotate(-28deg); } to { transform: rotate(26deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, .965); } }
@keyframes zfloat { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(10px, -20px); opacity: 0; } }
@keyframes dig { from { transform: rotate(-12deg) translateY(0); } to { transform: rotate(-20deg) translateY(3px); } }
@keyframes kick { 0% { transform: translate(0, 0); opacity: 1; } 100% { transform: translate(var(--dx), -18px); opacity: 0; } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-16px) rotate(-4deg); } }
@keyframes push { from { transform: rotate(-15deg) translateX(-5px); } to { transform: rotate(-19deg) translateX(-9px); } }

.no-motion .mouse *, .no-motion .hole-g, .no-motion .bubble, .no-motion .item, .no-motion .toast, .no-motion .menu { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon-btn { appearance: none; border: 0; background: none; color: var(--muted); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; font: 700 16px/1 var(--f-body); flex: none; }
.icon-btn:hover { background: var(--track); color: var(--ink); }
.act.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.act.danger, .btn.danger { color: var(--t-vid); }
.btn.danger { background: transparent; }
.act:disabled { opacity: .45; cursor: default; }
.ficon .door-stroke { stroke: var(--folder-door); }

.tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs [role=tab] { appearance: none; flex: 1 0 auto; border: 0; background: none; color: var(--muted); font: 700 13px/1 var(--f-body); padding: 9px 10px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.tabs [role=tab]:hover { color: var(--ink); }
.tabs [role=tab][aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px var(--shadow); }
.tabs .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--track); color: var(--ink); font: 700 11px/18px var(--f-body); text-align: center; }

.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: 600 14px var(--f-body); outline: none; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd { font: 500 11px var(--f-mono); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 5px; }

.panel-bar { min-height: 34px; }
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sort select { appearance: none; font: 600 12.5px var(--f-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 7px 26px 7px 9px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.seg button { appearance: none; border: 0; background: none; color: var(--muted); border-radius: 8px; padding: 5px 7px; cursor: pointer; display: grid; place-items: center; font: 700 13px/1 var(--f-body); }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px var(--shadow); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; padding: 9px 6px; }

.bulk-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 6px 6px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.bulk-bar strong { margin-right: auto; font-size: 13.5px; }

.notice { border-radius: 14px; padding: 12px; background: color-mix(in srgb, var(--t-doc) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--t-doc) 35%, transparent); display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.notice.conflict { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.notice-head strong { font-size: 14px; overflow-wrap: anywhere; }
.notice-note { margin: 0; color: var(--muted); font-size: 12.5px; }
.notice-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notice-row .meta { flex: 1 1 140px; }
.notice-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check-line input { accent-color: var(--accent); width: 16px; height: 16px; }

.list { min-height: 120px; }
.item { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; padding: 0; border-radius: 14px; }
.item .open { appearance: none; width: 100%; min-width: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; border-radius: 14px; cursor: pointer; }
.item.folder .open { grid-template-columns: 40px minmax(0, 1fr) auto; }
.item.folder .open:hover .chev { transform: translateX(3px); color: var(--ink); }
.item .acts { align-items: center; padding-right: 4px; }
.item.selected { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.item.selected:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.icon-wrap { width: 40px; height: 40px; display: block; }
.badge { overflow: hidden; }
.badge.has-thumb { background: var(--track); }
.badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sel { position: absolute; left: 2px; top: 2px; z-index: 2; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; padding: 0; }
.sel svg { width: 14px; height: 14px; }
.item:hover .sel, .item:focus-within .sel, .panel.selecting .sel { opacity: 1; }
.sel[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); opacity: 1; }
.shared-mark { color: var(--accent); display: grid; place-items: center; width: 22px; }
.shared-mark svg { width: 17px; height: 17px; }
.meta .bar { margin-top: 2px; }
.status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.item.draft { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; padding: 8px; }
.item.dead .name, .item.dead .icon-wrap { opacity: .55; }
.item.dead .sub { color: var(--t-vid); }

.list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; align-content: start; }
.list.grid .empty, .list.grid .draft { grid-column: 1 / -1; }
.list.grid .item { display: block; border: 1px solid var(--line); background: var(--bg); }
.list.grid .item.selected { border-color: var(--accent); }
.list.grid .item .open { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 8px; }
.list.grid .badge, .list.grid .icon-wrap { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 10px; font-size: 15px; }
.list.grid .icon-wrap .ficon { width: 100%; height: 100%; }
.list.grid .chev { display: none; }
.list.grid .sub { gap: 4px 6px; }
.list.grid .item .acts { position: absolute; top: 12px; right: 8px; padding: 0; }
.list.grid .kebab { background: color-mix(in srgb, var(--surface) 85%, transparent); margin: 0; width: 30px; height: 30px; }
.list.grid .act.toggle { padding: 6px 8px; }
.list.grid .sel { left: 14px; top: 14px; }

.quota { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.quota-text { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.quota-bar { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--t-img); border-radius: inherit; transition: width .4s; }
.quota.warn .quota-bar i { background: var(--t-vid); }
.quota.warn #quotaHint { color: var(--t-vid); font-weight: 700; }

dialog { color: var(--ink); }
.dlg { border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(480px, calc(100vw - 32px)); background: var(--surface); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .5); }
.dlg::backdrop, .viewer::backdrop { background: rgba(20, 12, 6, .55); backdrop-filter: blur(2px); }
.dlg[open] { animation: dlgIn .18s ease; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-body { display: flex; flex-direction: column; gap: 14px; padding: 18px; margin: 0; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dlg-head h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 23px; line-height: 1.15; overflow-wrap: anywhere; }
.dlg-sub { margin: -6px 0 0; color: var(--muted); font-size: 13.5px; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; font: 500 12.5px var(--f-mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; height: 38px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 700; font-size: 13.5px; }
.field-note { color: var(--muted); font-size: 12.5px; }
.field-note:empty { display: none; }
.field input[type=text], .field input[type=number] { font: 600 14px var(--f-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.field input:focus { border-color: var(--accent); outline: none; }
.limit-row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.limit-row input { width: 90px; }
.dlg .switch { color: var(--ink); font-size: 13.5px; font-weight: 700; }
.dlg-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 14px; }
a.btn { text-decoration: none; }
.versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.version { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); flex-wrap: wrap; }
.version .meta { flex: 1 1 160px; }
.version .meta span { color: var(--muted); font-size: 12.5px; }
.version.current { border: 1px solid var(--accent); }
.version .acts { display: flex; gap: 6px; }

.viewer { border: 0; padding: 0; width: min(1100px, calc(100vw - 24px)); height: min(820px, calc(100vh - 24px)); max-width: none; max-height: none; border-radius: 20px; background: var(--surface); display: none; flex-direction: column; overflow: hidden; }
.viewer[open] { display: flex; animation: dlgIn .18s ease; }
.v-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.v-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.v-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title span { color: var(--muted); font-size: 12.5px; }
.v-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.v-stage { flex: 1; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; background: var(--bg); }
.v-content { height: 100%; min-height: 0; display: grid; place-items: center; padding: 12px; overflow: auto; }
.v-content img, .v-content video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.v-content audio { width: min(420px, 100%); }
.v-content iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #fff; }
.v-text { align-self: stretch; justify-self: stretch; margin: 0; padding: 16px; background: var(--surface); border-radius: 10px; font: 500 13px/1.5 var(--f-mono); white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto; }
.v-nav { appearance: none; border: 0; background: none; color: var(--muted); font: 400 44px/1 var(--f-body); width: 52px; height: 100%; cursor: pointer; }
.v-nav:hover:not(:disabled) { color: var(--ink); background: color-mix(in srgb, var(--track) 50%, transparent); }
.v-nav:disabled { opacity: .2; cursor: default; }
.v-placeholder { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 420px; }
.v-placeholder .v-badge { width: 110px; height: 110px; border-radius: 26px; display: grid; place-items: center; background: var(--kind); color: #fff; font: 500 22px var(--f-mono); }
.v-placeholder p { margin: 0; color: var(--muted); }
@media (max-width: 600px) {
  .v-nav { width: 34px; font-size: 34px; }
  .viewer { width: 100vw; height: 100%; border-radius: 0; }
}

.toast { flex-wrap: wrap; }
.no-motion .dlg[open], .no-motion .viewer[open] { animation: none; }

.copy-btn svg { width: 18px; height: 18px; }
.list.grid .icon-wrap { background: var(--folder-bg); display: grid; place-items: center; }
.list.grid .icon-wrap .ficon { width: auto; height: 72%; }
.dlg-head h3 { font-family: var(--f-body); font-weight: 800; font-size: 19px; line-height: 1.25; }

.userbox { order: 3; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.userbox a { text-decoration: none; }
.who-name { font-weight: 800; font-size: 14px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#scene .castle-body { fill: var(--castle); }
#scene .castle-pole { stroke: var(--castle); stroke-width: 1; }
#scene .castle-flag { fill: var(--accent); }
#scene .castle-window { fill: var(--castle); }
#scene .castle-gate { fill: color-mix(in srgb, var(--castle) 70%, #000); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #scene .castle-window { fill: var(--glow); } }
:root[data-theme="dark"] #scene .castle-window { fill: var(--glow); }
#scene .relics { opacity: .9; }
#scene .r-wood { fill: var(--relic-wood); }
#scene .r-metal { fill: var(--relic-metal); }
#scene .r-dark { fill: var(--relic-dark); }
#scene .r-gold { fill: var(--relic-gold); stroke: var(--relic-dark); stroke-width: .6; }
#scene .r-stone { fill: var(--relic-stone); }
#scene .r-clay { fill: var(--relic-clay); }
#scene .r-shine { fill: var(--relic-metal); opacity: .7; }
#scene .r-line, #scene .r-dark-stroke { fill: none; stroke: var(--relic-dark); stroke-width: 1.4; stroke-linecap: round; }
#scene .r-blade { fill: none; stroke: var(--relic-metal); stroke-width: 3.2; stroke-linecap: round; }
#scene .r-gold-stroke { fill: none; stroke: var(--relic-gold); stroke-width: 2; stroke-linecap: round; }
#scene .r-shoe { fill: none; stroke: var(--relic-metal); stroke-width: 3.2; stroke-linecap: round; }
#scene .r-key { fill: none; stroke: var(--relic-gold); stroke-width: 1.9; stroke-linecap: round; }
#scene .r-clay-stroke { fill: none; stroke: var(--relic-clay); stroke-width: 2; stroke-linecap: round; }
