:root {
  --bg: #0a0f1a;
  --panel: #121a2a;
  --panel2: #1a2438;
  --line: #2a3650;
  --text: #e6ecf5;
  --muted: #8f9bb3;
  --accent: #4fb3ff;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Mode filtering */
body[data-mode="glass"] [data-mode="classic"],
body[data-mode="classic"] [data-mode="glass"] { display: none !important; }

#sidebar {
  width: 420px;
  min-width: 420px;
  height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px;
}
header h1 { font-size: 16px; margin: 0; }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 7px; color: inherit; text-decoration: none; flex: none; }
.brand img { height: 32px; display: block; }
.brand span { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 700; font-style: italic; font-size: 12.5px; line-height: 1.05; }
.seg { display: flex; gap: 0; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { flex: 1; text-align: center; padding: 6px; cursor: pointer; background: var(--panel2); }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent); color: #000; font-weight: 600; }

.box { background: var(--panel2); border-radius: 6px; padding: 8px; margin-bottom: 10px; }
.row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.row.wrap { flex-wrap: wrap; }
.row select { flex: 1; min-width: 0; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.quick button { font-size: 11.5px; padding: 4px 2px; }

button, select, input[type=text], input[type=number] {
  background: #0d1424;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
}
button { cursor: pointer; background: #223049; }
button:hover { background: #2c3b58; }
button.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }

.section { background: var(--panel2); border-radius: 6px; margin-bottom: 8px; padding: 0 8px; }
.section > summary { cursor: pointer; padding: 8px 0; font-weight: 600; user-select: none; }
.section[open] { padding-bottom: 8px; }

.field { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 6px; padding: 3px 0; }
.field label { color: var(--muted); }
.field .hint { display: block; font-size: 10.5px; color: #6b7894; }
.field.chk { grid-template-columns: 18px 1fr; }
.field.chk label { color: var(--text); cursor: pointer; }
.field.disabled { opacity: 0.4; }
.field input[type=text], .field select { width: 100%; }
.numwrap { display: flex; align-items: center; gap: 6px; }
.numwrap input[type=range] { flex: 1; width: 0; min-width: 0; accent-color: var(--accent); }
.numwrap input[type=number] { width: 72px; text-align: right; }
.numwrap .unit { width: 34px; color: var(--muted); font-size: 11px; }

#derived > div { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dotted var(--line); }
#derived span { color: var(--muted); }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
#toolbar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
#toolbar label { color: var(--muted); display: flex; gap: 6px; align-items: center; }
#stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; min-height: 0; }
#stage svg { max-width: 100%; max-height: 100%; width: auto; height: auto; box-shadow: 0 6px 30px rgba(0,0,0,.5); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #000; color: #fff; padding: 8px 14px; border-radius: 6px; opacity: 0; transition: .25s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 800px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: auto; max-height: 50vh; }
  main { height: auto; }
}
