:root {
  --bg: #0e1016;
  --panel: rgba(18, 20, 28, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8eaf0;
  --muted: #9aa0ad;
  --accent: #6fbf4a;
  --accent-ink: #0d1a08;
  --field: rgba(255, 255, 255, 0.06);
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.4 Inter, system-ui, sans-serif; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#panel { position: fixed; top: 16px; left: 16px; width: 340px; max-height: calc(100% - 32px); overflow: auto;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); }
#panel header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: inherit; }
h1 { font: 18px/1 Silkscreen, monospace; margin: 0; letter-spacing: 0.5px; color: #fff; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
section:last-child { border-bottom: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.hint:empty { display: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--field); color: var(--text);
  padding: 8px 12px; border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; filter: none; }
.icon { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }

input[type=url], input[type=number], select { width: 100%; background: var(--field); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 7px 9px; font: inherit; min-width: 0; }
#url-form input { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 label, label.range { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.range { margin-top: 10px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
.checks label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); }
label.inline-select { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
label.inline-select select { flex: 1; }
#no-assets { margin-top: 10px; }
a { color: var(--accent); }

.world-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.world-name { font-weight: 600; font-size: 15px; word-break: break-word; }
.nav { margin-top: 12px; align-items: stretch; }
.dpad { display: grid; grid-template-columns: repeat(3, 32px); grid-template-rows: repeat(3, 32px); gap: 3px; }
.dpad button { background: var(--field); border: 1px solid var(--line); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 11px; }
.dpad button:hover { background: rgba(255, 255, 255, 0.14); }
.dpad [data-dz="-1"] { grid-area: 1 / 2; } .dpad [data-dx="-1"] { grid-area: 2 / 1; }
.dpad [data-dx="1"] { grid-area: 2 / 3; } .dpad [data-dz="1"] { grid-area: 3 / 2; }

#hud { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; max-width: calc(100% - 32px); }
#status, #hover { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#status.error { border-color: #c0504d; color: #ffb4ae; }
#status.idle #progress { display: none; }
#progress { height: 3px; background: var(--field); border-radius: 2px; margin-top: 6px; overflow: hidden; min-width: 160px; }
#progress div { height: 100%; width: 30%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
#progress.determinate div { animation: none; transition: width 0.15s; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
#hover:empty { display: none; }

#drop-overlay { position: fixed; inset: 0; display: none; place-items: center; background: rgba(20, 40, 15, 0.55);
  border: 3px dashed var(--accent); font: 22px Silkscreen, monospace; color: #fff; z-index: 10; pointer-events: none; }
body.dragging #drop-overlay { display: grid; }

#panel.collapsed .panel-body { display: none; }

@media (max-width: 640px) {
  #panel { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; max-height: 55%; }
  #hud { top: 16px; bottom: auto; right: 16px; }
}

.grid2.slim { margin-top: 8px; align-items: end; }
.row.tools { margin: 4px 0 10px; }
#hover { font-family: ui-monospace, Consolas, monospace; }
#fly-hint { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; pointer-events: none; z-index: 5; max-width: calc(100% - 32px); text-align: center; }

.saves { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; }
.save { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--field); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; color: var(--text); font: inherit; cursor: pointer; }
.save:hover { background: rgba(255, 255, 255, 0.12); }
.save img, .save .noicon { width: 40px; height: 40px; image-rendering: pixelated; border-radius: 4px; flex: none; background: #2a2d36; }
.save-text { display: flex; flex-direction: column; min-width: 0; }
.save-text b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-text small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-wrap { margin-top: 10px; }
#chunk-map { width: 100%; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); cursor: grab; touch-action: none; image-rendering: pixelated; display: block; }
.map-legend { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 4px 6px; align-items: center; flex-wrap: wrap; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.sw.gen { background: #4f7a3a; } .sw.sel { border: 2px solid #f2d24b; } .sw.pl { background: #5ab0ff; border-radius: 50%; } .sw.sp { background: #ff6b6b; border-radius: 50%; }
.row.map-actions { margin-top: 6px; }
.map-info { font: 11px ui-monospace, Consolas, monospace; color: var(--muted); margin-left: auto; }
.dim-hint { margin: 8px 0 0; }
.version-name { color: var(--text); font-size: 13px; }
