/* Redcode page widgets and the debugger. Like the arena, they are dark "screens" in both site themes. */
.rc {
  --bg: #0b0f17; --panel: #111827; --line: rgba(148, 163, 184, .18); --ink: #e2e8f0; --muted: #8b98ad; --accent: #1e9fd0;
  margin: 1.4rem 0; padding: clamp(.6rem, 2vw, 1rem);
  background: radial-gradient(120% 80% at 50% 0%, #131c2e 0%, var(--bg) 60%);
  color: var(--ink); border: 1px solid var(--line); border-radius: .9rem;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.rc * { box-sizing: border-box; }
.rc code, .rc textarea, .rc-list { font-family: "JetBrains Mono Variable", ui-monospace, monospace; }
.rc code { color: #fff; background: rgba(148, 163, 184, .14); padding: 0 .25em; border-radius: .25em; font-size: .92em; }
.rc h4 { color: var(--ink); margin: 0 0 .45rem; font-size: .9rem; font-weight: 600; display: flex; gap: .5rem; align-items: baseline; }
.rc h4 small { color: var(--muted); font-weight: 400; font-family: ui-monospace, monospace; margin-left: auto; white-space: nowrap; overflow: hidden; }

.rc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .6rem; margin-bottom: .6rem; }
.rc button, .rc select, .rc input:not([type]), .rc input[size], .rc textarea, .rc .rc-in {
  font: inherit; color: var(--ink); background: #1b2436; border: 1px solid var(--line); border-radius: .5rem;
}
.rc button { padding: .32rem .75rem; cursor: pointer; }
.rc button:hover:not(:disabled) { background: #24314a; }
.rc button:disabled { opacity: .45; cursor: default; }
.rc button:focus-visible, .rc select:focus-visible, .rc input:focus-visible, .rc textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rc .rc-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.rc .rc-primary:hover:not(:disabled) { background: #2bb1e3; }
.rc select { padding: .32rem .4rem; }
.rc input:not([type]), .rc input[size] { padding: .3rem .5rem; width: 5.5rem; }
.rc input.rc-in { padding: .35rem .6rem; width: min(22rem, 70vw); font-family: ui-monospace, monospace; }
.rc label { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.rc-toggle input, .rc-speed input, .rc input[type=range] { accent-color: var(--accent); }
.rc-speed output { min-width: 7.5em; color: var(--ink); font-size: .8rem; }
.rc-pick { padding: .1rem .2rem .1rem .55rem; border-radius: .6rem; background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--ink) !important; }
.rc-pick select { border: 0 !important; background: transparent !important; font-weight: 600; }
.rc-pick option { background: var(--panel); }
.rc-status { margin-left: auto; min-width: 15rem; text-align: right; font: .82rem ui-monospace, monospace; color: var(--muted); }
.rc-hint { color: var(--muted); font-size: .8rem; }
.rc-err { color: #fb7185; }
.rc-explain { margin: .5rem 0 0; min-height: 3em; font-size: .88rem; }

/* ---------------------------------------------------------------- memory listing */
.rc-list { position: relative; font-size: .8rem; user-select: none; }
.rc-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 2; font: 600 10px ui-monospace, monospace; }
.rc-fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.rc-row {
  display: grid; grid-template-columns: .9rem 5.2rem 3.1rem minmax(0, 4.4rem) 4.3rem 4.4rem 4.4rem 1fr; align-items: center;
  height: 1.75rem; padding-right: .4rem; border-radius: .3rem; white-space: nowrap; transition: background .25s;
}
.rc-row > span { overflow: hidden; text-overflow: ellipsis; padding: .05rem .2rem; border-radius: .25rem; transition: background .25s, color .25s; }
.rc-row .rc-ad { color: var(--muted); border-left: 3px solid var(--o); padding-left: .35rem; border-radius: 0; }
.rc-row .rc-lb { color: #94a3b8; font-style: italic; }
.rc-row .rc-op { font-weight: 600; }
.rc-row.dat .rc-op { color: #7c8aa1; }
.rc-row .rc-bp { width: .62rem; height: .62rem; padding: 0; border-radius: 50%; cursor: pointer; justify-self: center; border: 1px solid transparent; }
.rc-dbg .rc-row .rc-bp:hover { border-color: #fb7185; }
.rc-row.bp .rc-bp, .rc-bpdot { background: #fb7185; }
.rc-bpdot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: middle; }
.rc-row.pc { background: rgba(148, 163, 184, .1); }
.rc-row.hl { background: color-mix(in srgb, var(--h) 20%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--h) 70%, transparent); }
.rc-row span.hl { background: color-mix(in srgb, var(--h) 32%, transparent); color: #fff; box-shadow: 0 0 0 1px var(--h); }
.rc-row .rc-pr { display: flex; gap: .2rem; }
.rc-row .rc-pr i { display: inline-grid; place-items: center; min-width: .75rem; height: .75rem; padding: 0 .15rem; border-radius: 99px; background: var(--c); color: #0b0f17; font: 700 9px/1 ui-monospace, monospace; font-style: normal; }
.rc-bubble { position: absolute; font: 700 .85rem ui-monospace, monospace; animation: rc-up 1s ease-out forwards; }
@keyframes rc-up { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-1.4rem); opacity: 0; } }
.rc-chip {
  position: absolute; z-index: 3; padding: .12rem .5rem; border-radius: .4rem; white-space: nowrap; font: 600 .75rem ui-monospace, monospace;
  background: color-mix(in srgb, var(--c) 30%, #0b0f17); border: 1px solid var(--c); color: #fff; box-shadow: 0 4px 18px -4px var(--c);
}

/* ---------------------------------------------------------------- demos */
/* Two columns when there is room, one otherwise (flex-wrap, no container queries). */
.rc-body { display: flex; flex-wrap: wrap; gap: .8rem; }
.rc-body > .rc-mem { flex: 1 1 26rem; max-width: 34rem; min-width: 0; }
.rc-body > .rc-side { flex: 1 1 18rem; min-width: 0; }
.rc-mem { overflow-x: auto; }
/* Fixed heights: the text inside changes every phase, the page around it must not move. */
.rc-say { margin: 0; padding-left: 1.3rem; font-size: .85rem; height: 12.5rem; overflow-y: auto; overscroll-behavior: contain; }
.rc-say li { margin: 0 0 .3rem; animation: rc-in .3s ease-out; }
.rc-say li.rc-hint, .rc-say li.rc-end { list-style: none; margin-left: -1.3rem; }
.rc-say li.rc-end { color: #fbbf24; font-weight: 600; }
.rc-say b { color: #fff; }
@keyframes rc-in { from { opacity: 0; transform: translateX(6px); } }
.rc-queues { margin-top: .6rem; display: grid; gap: .4rem; align-content: start; font-size: .8rem; height: 6.5rem; overflow-y: auto; }
.rc-queues > div { border-left: 3px solid var(--c); padding-left: .5rem; }
.rc-queues span, .rc-queues button { display: inline-block; margin: .15rem .25rem 0 0; padding: .05rem .4rem !important; border-radius: .3rem; background: #1b2436; border: 1px solid var(--line); font: .75rem ui-monospace, monospace; color: var(--ink); }
.rc-queues .now { background: var(--c); color: #0b0f17; font-weight: 700; }
.rc-queues small { color: var(--muted); }

/* ---------------------------------------------------------------- anatomy and ring */
.rc-anat svg { display: block; width: 100%; max-width: 640px; margin: 0 auto; }
.rc-part { cursor: pointer; outline: none; }
.rc-part rect { transition: fill-opacity .2s, stroke-width .2s; }
.rc-part.on rect, .rc-part:hover rect { stroke-width: 3.5; fill-opacity: .6; }
.rc canvas { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.rc output { color: var(--ink); font-family: ui-monospace, monospace; min-width: 2.5em; }

/* ---------------------------------------------------------------- debugger */
.rc-dbg { outline: none; width: min(80rem, calc(100vw - 2rem)); }
.rc-dgrid { display: flex; flex-wrap: wrap; gap: .9rem; }
.rc-dgrid > .rc-dmem { flex: 1 1 30rem; max-width: 36rem; min-width: 0; }
.rc-dgrid > .rc-dside { flex: 1 1 20rem; min-width: 0; }
.rc-dside { display: grid; gap: .7rem; align-content: start; }
.rc-dside section { background: var(--panel); border: 1px solid var(--line); border-radius: .6rem; padding: .55rem .7rem; min-width: 0; }
.rc-dside .rc-say { height: 15rem; }
.rc-dside .d-queues { height: 7.5rem; margin-top: 0; }
.rc-dside .d-hist { height: 20.5rem; overflow-y: auto; align-content: start; }
.rc-dside canvas { width: 100%; image-rendering: pixelated; cursor: pointer; border-radius: .3rem; }
.d-hist { display: grid; gap: .1rem; }
.d-hist button { display: grid; grid-template-columns: 4rem 7.5rem 1fr; gap: .4rem; text-align: left; padding: .1rem .4rem !important; background: transparent !important; border: 0 !important; border-left: 3px solid var(--c) !important; border-radius: 0 !important; font-size: .76rem; }
.d-hist button:hover { background: #1b2436 !important; }
.d-hist span { color: var(--muted); font-family: ui-monospace, monospace; }
.d-hist code { background: none; padding: 0; }
.d-hist em { color: var(--muted); font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-edit { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.d-edit summary { cursor: pointer; font-weight: 600; }
.rc-editors { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); margin: .6rem 0; }
.rc-editors label { display: grid; gap: .3rem; color: var(--c); font-weight: 600; }
.rc textarea { width: 100%; padding: .55rem; font-size: .8rem; line-height: 1.5; background: #0d131f; resize: vertical; tab-size: 8; font-weight: 400; }
.rc-msg { font-size: .8rem; color: #4ade80; }
.rc-msg.err { color: #fb7185; }

@media (max-width: 560px) {
  .rc-row { grid-template-columns: .7rem 3.4rem 2.8rem 0 3.9rem 3.6rem 3.6rem 1fr; font-size: .74rem; }
  .rc-row .rc-lb { visibility: hidden; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { .rc-say li, .rc-bubble { animation: none; } }
.rc-failed { color: #fb7185; font-size: .85rem; }
/* Buttons whose label changes (Run/Pause, Step/Next phase) keep one width, so the bar never re-wraps. */
.rc .rc-step, .rc .d-step { min-width: 8.2rem; }
.rc .rc-run, .rc .d-run { min-width: 6.4rem; }
