:root {
  --bg: #0f172a; /* slate-900 */
  --panel: #111827; /* gray-900 */
  --muted: #334155; /* slate-600 */
  --text: #e5e7eb; /* gray-200 */
  --accent: #22c55e; /* emerald-500 */
  --accent-2: #38bdf8; /* sky-400 */
  --accent-3: #a78bfa; /* violet-400 */
  --danger: #f43f5e; /* rose-500 */
  --border: #1f2937; /* gray-800 */
  --shadow: 0 10px 30px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body {
  min-height: 100%;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  background-color: var(--bg);
  color: var(--text);
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.container {
  width: min(1600px, 98vw);
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 12px 40px;
}
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
h1 { font-size:  clamp(1.2rem, 1rem + 2vw, 1.8rem); margin: 0; letter-spacing: 0.4px; }

.card { background: radial-gradient(1200px 400px at 10% -10%, rgba(34,197,94,.10), transparent 40%),
                 radial-gradient(1000px 400px at 110% -10%, rgba(56,189,248,.08), transparent 40%),
                 var(--panel);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1300px) { .grid { grid-template-columns: 1.05fr 1fr 1fr 1.1fr; } }

label { display: block; font-size: 14px; color: #cbd5e1; margin: 6px 0; }
textarea, input[type="number"], select { width: 100%; background: #0b1220; color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; }
textarea { min-height: 140px; resize: vertical; line-height: 1.4; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1 1 140px; }

.btns { display: flex; gap: 10px; flex-direction: column; }
.btns button { width: 100%; }
button { appearance: none; border: 1px solid var(--border); background: linear-gradient(180deg, #111827, #0b1220); color: var(--text); padding: 10px 14px; border-radius: 10px; cursor: pointer; transition: transform .06s ease, border-color .2s ease, background .2s ease; }
button:hover { transform: translateY(-1px); border-color: #2a374a; }
.primary { background: var(--accent); color: #0b1220; border-color: #16a34a; }
.primary-blue { background: var(--accent-2); color: #0b1220; border-color: #0ea5e9; }
.primary-purple { background: var(--accent-3); color: #0b1220; border-color: #8b5cf6; }
.ghost { background: #0b1220; }

.muted { color: #93a3b8; font-size: 13px; }

.output { display: grid; gap: 10px; grid-template-columns: 1fr; }
.result { background: #0b1220; border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.result-header { display:flex; justify-content: space-between; align-items: baseline; gap:10px }
.result h3 { margin: 0 0 6px; font-size: 15px; color: #cbd5e1; }
.copy { font-size: 12px; color: #9ca3af; cursor: pointer; }
.clickable { cursor: pointer; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 14px; white-space: pre-wrap; word-break: break-word; }

.list { display: grid; gap: 8px; }
.list-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: #0b1220; display: grid; grid-template-columns: 80px 1fr; gap: 10px; align-items: start; cursor: pointer; }
.list-item strong { color: #cbd5e1; }
.list-item .text { cursor: pointer; }
.list-item.selected { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2) inset; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.modal-backdrop.show { display: flex; }
.modal { width: min(100%, 900px); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal header { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.modal h2 { margin: 0; font-size: 16px; }
.modal .body { padding: 14px; display: grid; gap: 12px; }
.modal .grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 800px) { .modal .grid2 { grid-template-columns: 1fr 340px; } }
.close-btn { background: transparent; border: none; color: #9ca3af; font-size: 20px; cursor: pointer; }
.summary { font-size: 13px; color: #9ca3af; }

canvas { width: 100%; height: 300px; background: #0b1220; border-radius: 10px; border: 1px solid var(--border); }
.legend { display: flex; gap: 14px; align-items: center; font-size: 12px; color: #cbd5e1; }
.legend .swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.swatch.expected { background: var(--accent-2); }
.swatch.actual { background: var(--accent); }

/* Wheel */
.wheel { display: grid; gap: 8px; place-items: center; }
.wheel svg { width: 100%; max-width: 460px; height: auto; background: #0b1220; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.wheel text { fill: #cbd5e1; font-size: 14px; font-weight: 600; letter-spacing: 0.5px; }
/* Role-based coloring overrides ring-based default */
.wheel g.role-plain text { fill: var(--accent-2); }
.wheel g.role-cipher text { fill: var(--accent); }
.wheel .ring { fill: none; stroke: #1f2a3d; stroke-width: 2; }
.wheel .tick { stroke: #223149; stroke-width: 1; }
.wheel .center-label { fill: #9fb0c8; font-size: 12px; text-anchor: middle; }