:root {
  --bg: #070a12;
  --glass: rgba(16, 20, 32, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8ecf5;
  --muted: #8a93a8;
  --accent: #8b7bff;
  --accent2: #3ee0d0;
  --radius: 16px;
  font-family: Inter, "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
#app { position: fixed; inset: 0;
  background: radial-gradient(1200px 800px at 60% 40%, #121a2e 0%, #070a12 70%); }

.glass {
  position: fixed; z-index: 5;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.brand { top: 16px; left: 16px; padding: 14px 16px; width: 360px; }
.logo { font-weight: 700; letter-spacing: 0.08em; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo .thin { font-weight: 500; color: var(--muted); letter-spacing: 0.14em; font-size: 12px; margin-left: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%;
  background: conic-gradient(var(--accent), var(--accent2), var(--accent));
  box-shadow: 0 0 14px var(--accent); }
.sub { color: var(--muted); font-size: 12px; margin: 2px 0 10px 18px; }
.search { position: relative; }
.search input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.2); }
#results {
  list-style: none; margin: 6px 0 0; padding: 4px; max-height: 320px; overflow: auto;
  background: rgba(12, 15, 25, 0.96); border: 1px solid var(--line); border-radius: 10px;
  position: absolute; width: 100%; z-index: 10;
}
#results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: center; }
#results li:hover, #results li.sel { background: rgba(139, 123, 255, 0.16); }
#results .ja { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }

.presets { top: 16px; left: 50%; transform: translateX(-50%); padding: 6px; display: flex; gap: 4px; }
.presets button, .seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 500;
  padding: 8px 12px; border-radius: 10px; cursor: pointer; transition: all .2s;
}
.presets button:hover, .seg button:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.presets button.on, .seg button.on { color: #fff; background: linear-gradient(135deg, rgba(139,123,255,.55), rgba(62,224,208,.35)); }

.panel { top: 16px; right: 16px; width: 300px; padding: 6px 16px 14px; max-height: calc(100vh - 90px); overflow: auto; }
.panel h3 { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }
.explode { display: flex; gap: 10px; align-items: center; }
.explode input { flex: 1; accent-color: var(--accent); }
.btn { border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); padding: 8px 12px;
  border-radius: 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5c8dff); border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(139,123,255,.35); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(139,123,255,.5); }

.stack { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column-reverse; gap: 6px; }
.stack li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03); cursor: pointer; transition: all .25s;
  transform: perspective(400px) rotateX(18deg); font-size: 12.5px;
}
.stack li:hover { background: rgba(255,255,255,.07); }
.stack li.off { opacity: .38; }
.stack li .plate { width: 22px; height: 14px; border-radius: 4px; transform: skewX(-18deg); flex: none;
  box-shadow: 0 0 12px currentColor; }
.stack li .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.stack li .solo { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0 2px; }
.stack li .solo:hover { color: var(--accent2); }

.seg { display: flex; flex-wrap: wrap; gap: 4px; background: rgba(255,255,255,.04); padding: 4px; border-radius: 12px; }
.legend { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 11.5px; color: #c9cfdc; }
.legend div { display: flex; align-items: center; gap: 7px; }
.legend .ramp { grid-column: 1 / -1; height: 10px; border-radius: 6px; }
.legend .ends { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--muted); }

.toggles { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; font-size: 12.5px; }
.toggles input[type=checkbox] { accent-color: var(--accent); margin-right: 8px; }
.toggles select { margin-left: 6px; background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 6px; font: inherit; font-size: 12px; }

.card { left: 16px; bottom: 64px; width: 360px; padding: 16px 18px; animation: rise .25s ease; }
.card .close { position: absolute; top: 8px; right: 10px; border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.card h2 { margin: 0 0 2px; font-size: 18px; font-weight: 700; }
.card .ja { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; margin: 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.card .also { margin-top: 10px; font-size: 12px; color: var(--muted); }
.card .also a { color: var(--accent2); cursor: pointer; text-decoration: none; }

.foot { bottom: 16px; left: 16px; right: 16px; padding: 8px 14px; display: flex; gap: 16px; align-items: center;
  font-size: 11.5px; color: var(--muted); border-radius: 12px; }
.foot .credit { margin-left: auto; }
.link { background: none; border: 0; color: var(--accent2); font: inherit; cursor: pointer; padding: 0; }

dialog { position: fixed; max-width: 560px; color: var(--text); padding: 22px 26px; line-height: 1.55; font-size: 14px; }
dialog::backdrop { background: rgba(3, 5, 10, .6); backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; }
dialog .muted { color: var(--muted); font-size: 12.5px; }

#tooltip { position: fixed; z-index: 20; pointer-events: none; padding: 8px 10px; border-radius: 10px; font-size: 12px;
  background: rgba(10, 13, 22, .92); border: 1px solid var(--line); max-width: 260px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#tooltip b { font-size: 13px; }
#tooltip .m { color: var(--muted); }

#loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; z-index: 30;
  background: var(--bg); color: var(--muted); font-size: 13px; letter-spacing: .08em; transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255,255,255,.08);
  border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 900px) {
  .brand { width: calc(100% - 32px); }
  .presets { top: auto; bottom: 64px; }
  .panel { top: auto; bottom: 112px; width: calc(100% - 32px); max-height: 38vh; }
  .card { width: calc(100% - 32px); bottom: 112px; z-index: 6; }
  .foot .credit { display: none; }
}
