/* ==========================================================================
   Windows XP (Luna) — base tokens, controls, window chrome, menus, dialogs
   ========================================================================== */
:root {
  --font-ui: Tahoma, Verdana, "Segoe UI", sans-serif;
  --font-title: "Trebuchet MS", Tahoma, "Segoe UI", sans-serif;
  --xp-face: #ECE9D8;
  --xp-face-light: #F5F4EA;
  --xp-shadow: #ACA899;
  --xp-dark: #716F64;
  --xp-hilite: #316AC5;
  --xp-hilite-text: #fff;
  --xp-menu-hilite: #316AC5;
  --xp-link: #0000EE;
  --xp-border-blue: #7F9DB9;
  --xp-taskpane: linear-gradient(to bottom, #7BA2E7, #6375D6);
  --tb-h: 30px;

  /* window chrome (Luna Blue) */
  --win-frame: #0831D9;
  --win-frame-in: #166AEE;
  --win-title: linear-gradient(to bottom, #0997FF 0%, #0053EE 8%, #0050EE 40%, #0066FF 88%, #0066FF 93%, #005BFF 95%, #003DD7 96%, #003DD7 100%);
  --win-title-in: linear-gradient(to bottom, #7697E7 0%, #7E9EE3 3%, #94AFE8 6%, #97B4E9 8%, #82A5E4 14%, #7C9FE2 17%, #7996DE 25%, #7B99E1 56%, #82A9E9 81%, #80A5E7 89%, #7B96E1 94%, #7A93DF 97%, #ABBAE3 100%);
  --win-frame-inactive: #7B97E0;
  --win-title-text: #fff;
  --win-title-text-in: #D8E4F8;
  --btn-blue: radial-gradient(circle at 90% 90%, #0054E9 0%, #2263D5 55%, #4479E4 70%, #A3BBEC 90%, #fff 100%);
  --btn-blue-hover: radial-gradient(circle at 90% 90%, #1B65FF 0%, #3C7BFF 55%, #5E90FF 70%, #BDD0FF 90%, #fff 100%);
  --btn-blue-press: radial-gradient(circle at 10% 10%, #0038B8 0%, #1E4FC4 55%, #3A70E1 80%, #7EA4F2 100%);
  --btn-red: radial-gradient(circle at 90% 90%, #CC4600 0%, #DC6527 55%, #CD7546 70%, #FFCCB2 90%, #fff 100%);
  --btn-red-hover: radial-gradient(circle at 90% 90%, #E5500D 0%, #F07433 55%, #F0915B 70%, #FFDAC8 90%, #fff 100%);
  --btn-red-press: radial-gradient(circle at 10% 10%, #A1300A 0%, #C0451B 60%, #E0764A 100%);
  --btn-inactive-op: .55;

  /* cursors fallbacks (icons.js overrides with authentic XP cursors) */
  --cur-arrow: default; --cur-busy: progress; --cur-wait: wait; --cur-text: text; --cur-hand: pointer;
  --cur-move: move; --cur-ns: ns-resize; --cur-ew: ew-resize; --cur-nwse: nwse-resize; --cur-nesw: nesw-resize;
  --cur-no: not-allowed; --cur-cross: crosshair; --cur-pen: crosshair; --cur-bucket: crosshair; --cur-picker: crosshair;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000;
  font-family: var(--font-ui); font-size: 11px; color: #000;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  cursor: var(--cur-arrow);
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
body.cursor-wait, body.cursor-wait * { cursor: var(--cur-wait) !important; }
body.cursor-busy, body.cursor-busy * { cursor: var(--cur-busy) !important; }
input, textarea, select, button { font-family: inherit; font-size: 11px; }
input, textarea { cursor: var(--cur-text); user-select: text; -webkit-user-select: text; }
a { color: var(--xp-link); cursor: var(--cur-hand); }
.ico { display: inline-block; flex: none; vertical-align: middle; overflow: visible; }
u { text-decoration: underline; }
body:not(.show-accel) .menubar u, body:not(.show-accel) .xp-accel u { text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- scrollbars (Luna) ---------- */
.xp-scroll, .window-body, .xp-list, .xp-textarea, textarea { scrollbar-width: auto; }
::-webkit-scrollbar { width: 17px; height: 17px; background: #FEFEFE; }
::-webkit-scrollbar-track { background: linear-gradient(to right, #F3F1EC, #FEFEFB); }
::-webkit-scrollbar-track:horizontal { background: linear-gradient(to bottom, #F3F1EC, #FEFEFB); }
::-webkit-scrollbar-thumb {
  border: 1px solid #fff; border-radius: 3px;
  background: linear-gradient(to right, #C9D8FC, #B5CAFA 45%, #BFD2FC) padding-box;
  box-shadow: inset 0 0 0 1px #B7CAF5, 0 0 0 1px #9DB3E8;
  background-image: linear-gradient(to right, #C9D8FC, #B5CAFA 45%, #BFD2FC);
}
::-webkit-scrollbar-thumb:horizontal { background-image: linear-gradient(to bottom, #C9D8FC, #B5CAFA 45%, #BFD2FC); }
::-webkit-scrollbar-thumb:hover { background-image: linear-gradient(to right, #DAE6FE, #C6D9FE 45%, #D3E3FE); }
::-webkit-scrollbar-button:single-button { display: block; width: 17px; height: 17px; border-radius: 3px;
  background: #C8D6FB; box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 2px #B7CAF5; }
::-webkit-scrollbar-button:single-button:vertical:decrement { background: #C8D6FB url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17'%3E%3Cpath d='M5 10l3.5-3.5L12 10' fill='none' stroke='%234D6185' stroke-width='2'/%3E%3C/svg%3E") center no-repeat; }
::-webkit-scrollbar-button:single-button:vertical:increment { background: #C8D6FB url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17'%3E%3Cpath d='M5 7l3.5 3.5L12 7' fill='none' stroke='%234D6185' stroke-width='2'/%3E%3C/svg%3E") center no-repeat; }
::-webkit-scrollbar-button:single-button:horizontal:decrement { background: #C8D6FB url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17'%3E%3Cpath d='M10 5L6.5 8.5 10 12' fill='none' stroke='%234D6185' stroke-width='2'/%3E%3C/svg%3E") center no-repeat; }
::-webkit-scrollbar-button:single-button:horizontal:increment { background: #C8D6FB url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17'%3E%3Cpath d='M7 5l3.5 3.5L7 12' fill='none' stroke='%234D6185' stroke-width='2'/%3E%3C/svg%3E") center no-repeat; }
::-webkit-scrollbar-corner { background: var(--xp-face); }

/* ---------- controls ---------- */
.xp-btn {
  min-width: 75px; height: 23px; padding: 0 10px; font-size: 11px; color: #000;
  border: 1px solid #003C74; border-radius: 3px;
  background: linear-gradient(to bottom, #FFFFFF 0%, #F9F9F7 30%, #ECEBE6 85%, #D6D0C5 100%);
  box-shadow: inset -1px -1px 0 rgba(0,0,0,0.04);
  cursor: var(--cur-arrow); position: relative; white-space: nowrap;
}
.xp-btn:hover:not(:disabled) { box-shadow: inset 0 -2px 0 #F8B330, inset 0 2px 0 #FDD889, inset 2px 0 0 #FBCA60, inset -2px 0 0 #FBCA60; }
.xp-btn:focus-visible, .xp-btn.default { box-shadow: inset 0 -2px 0 #98B8EA, inset 0 2px 0 #CEE7FF, inset 2px 0 0 #B7D2F6, inset -2px 0 0 #B7D2F6; outline: none; }
.xp-btn:focus-visible::after { content: ''; position: absolute; inset: 3px; border: 1px dotted #000; border-radius: 1px; pointer-events: none; }
.xp-btn:active:not(:disabled) { background: linear-gradient(to bottom, #E5E4DE 0%, #E3E2DB 70%, #F2F1EE 100%); box-shadow: none; }
.xp-btn:disabled { color: #A19F92; border-color: #C9C7BA; background: #F4F3EE; }
.xp-btn.small { min-width: 0; height: 21px; padding: 0 6px; }

.xp-input, .xp-select, .xp-textarea {
  border: 1px solid var(--xp-border-blue); background: #fff; height: 21px; padding: 2px 3px; color: #000; border-radius: 0;
  outline: none;
}
.xp-textarea { height: auto; resize: none; }
.xp-input:disabled, .xp-select:disabled { background: var(--xp-face); color: #A19F92; }
.xp-select { padding: 1px 2px; appearance: none; -webkit-appearance: none; padding-right: 20px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='19'%3E%3Crect x='.5' y='.5' width='16' height='18' rx='2' fill='%23C3D3FD' stroke='%23fff'/%3E%3Cpath d='M5 8l3.5 3.5L12 8' fill='none' stroke='%234D6185' stroke-width='2'/%3E%3C/svg%3E") right 1px center no-repeat; }
.xp-check, .xp-radio { display: inline-flex; align-items: center; gap: 5px; cursor: var(--cur-arrow); line-height: 16px; }
.xp-check input, .xp-radio input { margin: 0; width: 13px; height: 13px; accent-color: #21A121; }
.xp-group { border: 1px solid #D0D0BF; border-radius: 4px; padding: 6px 8px 8px; margin: 0 0 8px; }
.xp-group > legend { color: #0046D5; padding: 0 3px; }
.xp-field { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.xp-hr { height: 0; border: 0; border-top: 1px solid #ACA899; border-bottom: 1px solid #fff; margin: 8px 0; }
.xp-sunken { border: 1px solid; border-color: #ACA899 #fff #fff #ACA899; box-shadow: inset 1px 1px 0 #716F64; }
.xp-raised { border: 1px solid; border-color: #fff #716F64 #716F64 #fff; }
.xp-list { background: #fff; border: 1px solid var(--xp-border-blue); overflow: auto; }
.xp-list .row { padding: 1px 3px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.xp-list .row.sel { background: var(--xp-hilite); color: #fff; }
.xp-progress { height: 16px; border: 1px solid #686868; border-radius: 3px; background: #fff; padding: 1px; overflow: hidden; }
.xp-progress > .bar { height: 100%; width: 0%;
  background: repeating-linear-gradient(to right, transparent 0 1px, transparent 1px 8px, #fff 8px 10px),
    linear-gradient(to bottom, #ACEDAD 0%, #7BE47D 14%, #4CDA50 28%, #2ED330 42%, #42D845 57%, #76E275 71%, #8FE791 85%, #fff 100%);
  transition: width .2s linear; }
.xp-slider { accent-color: #316AC5; }

.xp-tabs .tab-strip { display: flex; gap: 0; position: relative; z-index: 1; padding-left: 2px; }
.xp-tabs .tab { position: relative; height: 21px; padding: 0 7px; margin-right: -1px; border: 1px solid #919B9C; border-bottom: 0;
  border-radius: 3px 3px 0 0; background: linear-gradient(to bottom, #fff, #ECEBE5 80%, #D8D6CB); color: #000; top: 2px; cursor: var(--cur-arrow); }
.xp-tabs .tab:hover { border-top: 2px solid #FFC83C; }
.xp-tabs .tab.active { background: #FCFCFE; top: 0; height: 23px; border-top: 2px solid #FFC83C; z-index: 2; padding: 0 9px; margin: 0 -1px 0 -2px; }
.xp-tabs .tab-panel { border: 1px solid #919B9C; background: #FCFCFE; padding: 10px; position: relative; top: -1px; box-shadow: 1px 1px 0 #D0CEBF; }

.xp-toolbar { display: flex; align-items: center; gap: 1px; padding: 2px 2px; background: var(--xp-face); border-bottom: 1px solid #D8D2BD; flex-wrap: nowrap; overflow: hidden; }
.xp-toolbtn { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 5px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #000; white-space: nowrap; cursor: var(--cur-arrow); }
.xp-toolbtn.small { height: 24px; }
.xp-toolbtn:hover:not(:disabled) { border-color: #fff #CECEC3 #CECEC3 #fff; background: linear-gradient(to bottom, #fff, #F2F1EA 70%, #E7E5D9); box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.xp-toolbtn:active:not(:disabled), .xp-toolbtn.pressed { border-color: #9D9D92 #fff #fff #9D9D92; background: #E3E1D5; box-shadow: inset 1px 1px 2px rgba(0,0,0,.15); }
.xp-toolbtn:disabled { opacity: .45; filter: grayscale(1); }
.xp-toolbtn .drop { width: 0; height: 0; border: 3px solid transparent; border-top: 3px solid #000; margin-top: 3px; }
.xp-toolbar .sep { width: 1px; align-self: stretch; margin: 3px 2px; background: #C5C2B2; box-shadow: 1px 0 #fff; }
.xp-statusbar { display: flex; gap: 2px; height: 22px; padding: 2px 16px 2px 2px; background: var(--xp-face); border-top: 1px solid #fff; box-shadow: 0 -1px #C5C2B2; position: relative; flex: none; }
.xp-statusbar .part { flex: 1; padding: 2px 4px; border: 1px solid; border-color: #C5C2B2 #fff #fff #C5C2B2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.xp-statusbar .part:not(:first-child) { flex: 0 0 auto; min-width: 90px; }
.xp-statusbar::after { content: ''; position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px;
  background: radial-gradient(circle, #fff 1px, transparent 1.5px) 1px 1px / 4px 4px, radial-gradient(circle, #B6B09A 1px, transparent 1.5px) 0 0 / 4px 4px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.window.maximized .xp-statusbar::after { display: none; }

/* ---------- window chrome ---------- */
#windows { position: absolute; inset: 0 0 var(--tb-h) 0; pointer-events: none; overflow: hidden; }
.window {
  position: absolute; display: flex; flex-direction: column; pointer-events: auto;
  background: var(--win-frame); border-radius: 8px 8px 0 0; padding: 0 3px 3px;
  box-shadow: inset 0 0 0 1px #0019CF, 2px 2px 10px rgba(0,0,0,.35);
  min-width: 120px; min-height: 30px; touch-action: none;
}
.window .titlebar {
  height: 29px; flex: none; margin: 0 -3px; padding: 0 5px 0 5px; display: flex; align-items: center; gap: 3px;
  background: var(--win-title); border-radius: 7px 7px 0 0; position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 1px 0 0 rgba(255,255,255,.15), inset -1px 0 0 rgba(0,0,64,.25);
}
.window .titlebar::before { content: ''; position: absolute; inset: 0; border-radius: 7px 7px 0 0; pointer-events: none;
  background: linear-gradient(to right, rgba(0,20,120,.35), transparent 6px, transparent calc(100% - 6px), rgba(0,20,120,.35)); }
.window .title-icon { width: 16px; height: 16px; flex: none; margin-right: 1px; cursor: var(--cur-arrow); }
.window .title-text {
  flex: 1; min-width: 0; color: var(--win-title-text); font: bold 13px var(--font-title); letter-spacing: 0;
  text-shadow: 1px 1px #0F1089; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 1px;
}
.window .title-buttons { display: flex; gap: 2px; flex: none; }
.window .tbtn {
  width: 21px; height: 21px; border: 1px solid #fff; border-radius: 3px; padding: 0; position: relative;
  background: var(--btn-blue); box-shadow: inset 0 0 1px rgba(0,0,0,.3); cursor: var(--cur-arrow);
}
.window .tbtn:hover { background: var(--btn-blue-hover); }
.window .tbtn:active { background: var(--btn-blue-press); }
.window .tbtn.close { background: var(--btn-red); }
.window .tbtn.close:hover { background: var(--btn-red-hover); }
.window .tbtn.close:active { background: var(--btn-red-press); }
.window .tbtn::before, .window .tbtn::after { content: ''; position: absolute; }
.window .tbtn.min::before { left: 4px; bottom: 4px; width: 7px; height: 3px; background: #fff; }
.window .tbtn.max::before { left: 4px; top: 4px; width: 11px; height: 11px; box-sizing: border-box; border: 1px solid #fff; border-top-width: 3px; }
.window.maximized .tbtn.max::before { left: 7px; top: 3px; width: 8px; height: 8px; }
.window.maximized .tbtn.max::after { left: 3px; top: 7px; width: 8px; height: 8px; box-sizing: border-box; border: 1px solid #fff; border-top-width: 3px; background: inherit; }
.window .tbtn.close::before, .window .tbtn.close::after { left: 9px; top: 3px; width: 2px; height: 13px; background: #fff; transform: rotate(45deg); border-radius: 1px; }
.window .tbtn.close::after { transform: rotate(-45deg); }
.window .tbtn.help::before { content: '?'; inset: 0; color: #fff; font: bold 14px var(--font-title); display: grid; place-items: center; }
.window .tbtn:disabled { opacity: .5; }
.window .window-client { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--xp-face); position: relative; }
.window .window-body { flex: 1; min-height: 0; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.window .window-client.busy::after { content: ''; position: absolute; inset: 0; cursor: var(--cur-wait); z-index: 50; }

.window.inactive { background: var(--win-frame-inactive); box-shadow: inset 0 0 0 1px #6E88D4, 2px 2px 8px rgba(0,0,0,.25); }
.window.inactive .titlebar { background: var(--win-title-in); }
.window.inactive .title-text { color: var(--win-title-text-in); text-shadow: none; }
.window.inactive .tbtn { opacity: var(--btn-inactive-op); }
.window.maximized { border-radius: 0; padding: 0; box-shadow: none; }
.window.maximized .titlebar { border-radius: 0; margin: 0; }
.window.maximized .titlebar::before { border-radius: 0; }
.window.flashing .titlebar { animation: title-flash .16s steps(1) 6; }
@keyframes title-flash { 50% { background: var(--win-title-in); } }
.window.hidden-min { visibility: hidden; pointer-events: none; }
.window .rz { position: absolute; z-index: 5; }
.window .rz.n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: var(--cur-ns); }
.window .rz.s { bottom: -3px; left: 8px; right: 8px; height: 7px; cursor: var(--cur-ns); }
.window .rz.e { right: -3px; top: 8px; bottom: 8px; width: 7px; cursor: var(--cur-ew); }
.window .rz.w { left: -3px; top: 8px; bottom: 8px; width: 7px; cursor: var(--cur-ew); }
.window .rz.ne { right: -3px; top: -3px; width: 12px; height: 12px; cursor: var(--cur-nesw); }
.window .rz.nw { left: -3px; top: -3px; width: 12px; height: 12px; cursor: var(--cur-nwse); }
.window .rz.se { right: -3px; bottom: -3px; width: 14px; height: 14px; cursor: var(--cur-nwse); }
.window .rz.sw { left: -3px; bottom: -3px; width: 12px; height: 12px; cursor: var(--cur-nesw); }
.window.maximized .rz, .window.fixed .rz { display: none; }
.window.dialog .window-client { padding: 0; }
.window.opening { animation: win-open .14s ease-out; }
@keyframes win-open { from { opacity: 0; transform: scale(.96); } }
.zoom-ghost { position: fixed; z-index: 99990; border: 2px solid #D0D0D0; pointer-events: none; background: rgba(90,126,220,.12); border-radius: 6px 6px 0 0; }
.drag-outline { position: fixed; z-index: 99990; border: 3px solid rgba(128,128,128,.8); pointer-events: none; mix-blend-mode: difference; }
.modal-block { position: absolute; inset: 0; z-index: 60; cursor: var(--cur-arrow); }

/* ---------- menubar & menus ---------- */
.menubar { display: flex; flex: none; height: 20px; background: var(--xp-face); border-bottom: 1px solid #fff; box-shadow: 0 1px 0 #D8D2BD; padding: 0 2px; overflow: hidden; }
.menubar .mb-item { padding: 0 6px; line-height: 18px; margin-top: 1px; border: 1px solid transparent; cursor: var(--cur-arrow); white-space: nowrap; }
.menubar .mb-item.open, .menubar.active .mb-item:hover { background: var(--xp-menu-hilite); color: #fff; }
.menubar .mb-item.open u, .menubar.active .mb-item:hover u { text-decoration: underline; }
.menubar .mb-logo { margin-left: auto; width: 38px; height: 18px; border-left: 1px solid #C5C2B2; box-shadow: -1px 0 #fff inset; display: grid; place-items: center; background: #fff; }
.xp-menu {
  position: fixed; z-index: 99000; min-width: 150px; background: #fff; border: 1px solid #ACA899; padding: 2px;
  box-shadow: 3px 3px 3px rgba(0,0,0,.28); font-size: 11px; white-space: nowrap; animation: menu-fade .14s ease-out;
}
@keyframes menu-fade { from { opacity: 0; } }
.xp-menu .mi { display: flex; align-items: center; height: 19px; padding: 0 17px 0 0; cursor: var(--cur-arrow); position: relative; }
.xp-menu .mi .mi-check { width: 21px; flex: none; text-align: center; font-size: 11px; display: grid; place-items: center; }
.xp-menu .mi .mi-label { flex: 1; padding-right: 20px; }
.xp-menu .mi .mi-short { color: inherit; padding-left: 10px; }
.xp-menu .mi.sub::after { content: ''; position: absolute; right: 6px; top: 6px; border: 4px solid transparent; border-left: 4px solid #000; border-right: 0; }
.xp-menu .mi.hot { background: var(--xp-menu-hilite); color: #fff; }
.xp-menu .mi.hot.sub::after { border-left-color: #fff; }
.xp-menu .mi.disabled { color: #ACA899; }
.xp-menu .mi.disabled.hot { background: #ECE9D8; color: #ACA899; }
.xp-menu .mi.bold .mi-label { font-weight: bold; }
.xp-menu .mi-sep { height: 1px; background: #ACA899; margin: 3px 1px; }
.xp-menu .radio-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- message boxes / property sheets ---------- */
.msgbox { display: flex; flex-direction: column; padding: 12px 11px 11px; min-width: 250px; max-width: 460px; }
.msgbox .mb-main { display: flex; gap: 12px; align-items: flex-start; padding: 2px 4px 14px; }
.msgbox .mb-text { white-space: pre-wrap; line-height: 14px; padding-top: 6px; user-select: text; -webkit-user-select: text; max-width: 380px; overflow-wrap: anywhere; }
.msgbox .mb-buttons { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.msgbox.left-buttons .mb-buttons { justify-content: flex-end; }
.propsheet { display: flex; flex-direction: column; padding: 6px 6px 7px; height: 100%; }
.propsheet .xp-tabs { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.propsheet .tab-panel { flex: 1; overflow: auto; }
.propsheet .ps-buttons { display: flex; justify-content: flex-end; gap: 6px; padding-top: 8px; }
.prop-general .pg-row { display: grid; grid-template-columns: 90px 1fr; gap: 4px 6px; align-items: start; padding: 2px 0; }
.prop-general .pg-head { display: flex; align-items: center; gap: 14px; padding-bottom: 8px; }
.prop-general .pg-head .xp-input { flex: 1; }
.prop-general .pg-val { overflow-wrap: anywhere; user-select: text; }
.pie-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; }
.legend-sq { display: inline-block; width: 14px; height: 14px; border: 1px solid #000; vertical-align: middle; margin-right: 6px; }

/* ---------- common file dialog ---------- */
.filedlg { display: flex; flex-direction: column; gap: 6px; padding: 8px; height: 100%; }
.filedlg .fd-top { display: flex; align-items: center; gap: 6px; }
.filedlg .fd-top .xp-select { flex: 1; min-width: 0; }
.filedlg .fd-mid { display: flex; gap: 6px; flex: 1; min-height: 0; }
.filedlg .fd-places { width: 86px; flex: none; background: #F3F1E6; border: 1px solid #9E9A8D; display: flex; flex-direction: column; padding: 2px; overflow: hidden; }
.filedlg .fd-places button { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 1px solid transparent; padding: 6px 0; color: #000; }
.filedlg .fd-places button:hover { border-color: #fff #9E9A8D #9E9A8D #fff; }
.filedlg .fd-list { flex: 1; display: flex; flex-flow: column wrap; align-content: flex-start; gap: 0 12px; padding: 2px; min-width: 0; overflow-x: auto; }
.filedlg .fd-list .row { width: 180px; }
.filedlg .fd-bottom { display: grid; grid-template-columns: auto 1fr auto; gap: 5px 6px; align-items: center; padding-left: 92px; }
@media (max-width: 640px) { .filedlg .fd-places { display: none; } .filedlg .fd-bottom { padding-left: 0; } }

/* ---------- balloons ---------- */
.balloon {
  position: fixed; z-index: 97000; max-width: 300px; min-width: 200px; background: #FFFFE1; border: 1px solid #000;
  border-radius: 7px; padding: 8px 26px 9px 10px; box-shadow: 2px 3px 6px rgba(0,0,0,.35); cursor: var(--cur-arrow);
  opacity: 0; transition: opacity .35s;
}
.balloon.show { opacity: 1; }
.balloon .b-title { font-weight: bold; display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.balloon .b-text { line-height: 14px; white-space: pre-wrap; }
.balloon .b-close { position: absolute; right: 5px; top: 5px; width: 14px; height: 14px; border: 1px solid transparent; border-radius: 2px; background: transparent; padding: 0; }
.balloon .b-close::before, .balloon .b-close::after { content: ''; position: absolute; left: 5px; top: 1px; width: 2px; height: 10px; background: #787878; transform: rotate(45deg); }
.balloon .b-close::after { transform: rotate(-45deg); }
.balloon .b-close:hover { border-color: #D4D0C8; background: #fff; }
.balloon .b-close:hover::before, .balloon .b-close:hover::after { background: #fff; }
.balloon .b-close:hover { background: #E37B5B; border-color: #fff; }
.balloon .b-tail { position: absolute; bottom: -19px; width: 0; height: 0; border-top: 19px solid #000; border-left: 19px solid transparent; }
.balloon .b-tail::after { content: ''; position: absolute; top: -20px; left: -17px; border-top: 18px solid #FFFFE1; border-left: 17px solid transparent; }

/* tooltip */
.xp-tooltip { position: fixed; z-index: 99500; background: #FFFFE1; border: 1px solid #000; padding: 2px 4px; box-shadow: 2px 2px 3px rgba(0,0,0,.25); pointer-events: none; white-space: pre; animation: menu-fade .2s; max-width: 360px; }
