:root {
  --bg: rgba(14, 16, 24, 0.86);
  --fg: #e6e8ef;
  --muted: #8a90a2;
  --accent: #f0a63a;
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--fg);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }

#panel { position: fixed; top: 10px; left: 10px; bottom: 10px; width: 320px; display: flex; flex-direction: column;
  background: var(--bg); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; transition: transform 0.25s ease; }
body.hide-panel #panel { transform: translateX(-340px); }

#panel header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  border-bottom: 1px solid var(--line); }
#panel h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.3px; }
#panel h1 { flex: 1; cursor: pointer; user-select: none; }
#panel h1::after { content: " ▾"; color: var(--muted); font-size: 12px; }
body.panel-min #panel h1::after { content: " ▸"; }
body.panel-min #panel { bottom: auto; }
body.panel-min #controls, body.panel-min .export, body.panel-min .help { display: none; }
body.panel-min #panel header { border-bottom: 0; }
#panel h1 b { color: var(--accent); font-weight: 600; }
#lang { width: auto; margin-right: 6px; padding: 2px 4px; font-size: 12px; }
#panel-toggle { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
#panel-show { position: fixed; top: 12px; left: 12px; display: none; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; font-size: 18px; padding: 4px 10px; cursor: pointer; }
body.hide-panel #panel-show { display: block; }

#controls { flex: 1; overflow-y: auto; padding: 4px 0; }
details { border-bottom: 1px solid var(--line); padding: 4px 14px 8px; }
summary { cursor: pointer; padding: 6px 0; font-weight: 600; color: var(--accent); list-style: none; }
summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }

.row { display: grid; grid-template-columns: 104px 1fr 84px; align-items: center; gap: 8px; margin: 5px 0; }
.row .lbl { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row select { grid-column: 2 / 4; }
.row.check { grid-template-columns: auto 1fr; cursor: pointer; }
.about { color: var(--muted); margin: 4px 0 8px; font-size: 12px; }

input[type=range] { width: 100%; accent-color: var(--accent); }
select { width: 100%; background: #1b1e2a; color: var(--fg); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 6px; font: inherit; }

.export { padding: 10px 14px; border-top: 1px solid var(--line); }
.export button { width: 100%; margin-top: 6px; padding: 8px; border-radius: 6px; border: 0; font: inherit;
  font-weight: 600; cursor: pointer; background: var(--accent); color: #1a1205; }
.export button.secondary { background: #262a38; color: var(--fg); font-weight: 500; }
.export button:disabled { opacity: 0.7; cursor: progress; }

.help { margin: 0; padding: 8px 14px 12px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); }
.help b { color: var(--fg); font-weight: 600; }

#stats { position: fixed; right: 12px; bottom: 10px; color: rgba(255, 255, 255, 0.55); font-size: 11px;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; pointer-events: none; }
#fatal { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); max-width: 560px; padding: 16px 20px;
  background: #3a1414; border: 1px solid #a33; border-radius: 8px; white-space: pre-wrap; }

.links { display: flex; justify-content: space-between; padding: 6px 14px 10px; font-size: 12px; }
.links a { color: var(--accent); text-decoration: none; }

@media (max-width: 700px) {
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 40vh; border-radius: 12px 12px 0 0; }

  html, body { font-size: 12px; }
  #panel header { padding: 6px 10px; }
  #panel h1 { font-size: 14px; }
  details { padding: 2px 10px 4px; }
  summary { padding: 4px 0; }
  .row { grid-template-columns: 90px 1fr 78px; gap: 6px; margin: 2px 0; }
  .row.text { grid-template-columns: 96px 1fr; }
  select, .row.text input { padding: 2px 4px; font-size: 12px; }
  input[type=range] { height: 18px; margin: 0; }
  .about { margin: 2px 0 4px; font-size: 11px; }
  .export { padding: 6px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
  .export .row { grid-template-columns: auto 1fr; }
  .export button { margin-top: 4px; padding: 6px; }
  .btn-row { margin: 3px 0; }
  .btn-row button { padding: 4px; }
  .crosslink { padding: 4px 10px 6px; }
  body.panel-min #panel { height: auto; bottom: 0; }
  #panel h1::after { content: " ▾"; }
  body.panel-min #panel h1::after { content: " ▴"; }
  #stats { top: 8px; bottom: auto; }
  .help { display: none; }
  .links { padding: 4px 10px 6px; }
  body.hide-panel #panel { transform: translateY(calc(40vh + 20px)); }
}
