/* ================================================================== */
/* THEME VARIABLES                                                    */
/* ================================================================== */

:root {
  color-scheme: dark;

  --machine-content-height: clamp(500px, 65vh, 720px);

  --bg: #111318;
  --surface: #191c23;
  --surface-light: #20242d;
  --border: #303641;

  --text: #e6e9ef;
  --muted: #9299a8;

  --accent: #7aa2f7;
  --accent-hover: #89b4ff;

  --green: #9ece6a;
  --red: #f7768e;
  --yellow: #e0af68;

  --code-bg: #0d0f13;
  --code-text: #c9d1d9;

  --scrollbar-track: #0d0f13;
  --scrollbar-thumb: #343a46;
  --scrollbar-thumb-hover: #454c59;

  --mono:
    "SFMono-Regular",
    "Cascadia Code",
    "JetBrains Mono",
    "Fira Code",
    Consolas,
    monospace;
}

body.light {
  color-scheme: light;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-light: #f0f2f5;
  --border: #d6dae1;

  --text: #20242b;
  --muted: #697180;

  --accent: #315fba;
  --accent-hover: #244d9d;

  --green: #3f7d20;
  --red: #c43d55;
  --yellow: #a56b00;

  --code-bg: #f3f4f6;
  --code-text: #303640;

  --scrollbar-track: #eef0f3;
  --scrollbar-thumb: #c2c7d0;
  --scrollbar-thumb-hover: #aeb4bf;
}


/* ================================================================== */
/* GENERAL                                                            */
/* ================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 2rem;

  background: var(--bg);
  color: var(--text);

  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.app {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}


/* ================================================================== */
/* HEADER                                                             */
/* ================================================================== */

header {
  margin-bottom: 1.5rem;
}

header h1 {
  margin: 0;

  font-size: 1.8rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

header p {
  margin: 0.35rem 0 0;

  color: var(--muted);
  font-size: 0.9rem;
}


/* ================================================================== */
/* TOOLBAR                                                            */
/* ================================================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;

  margin-bottom: 1rem;
  padding: 0.75rem 1rem;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 8px;
}

.app-toolbar {
  gap: 0.4rem;

  padding: 0.4rem 0.5rem;

  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.architecture-picker {
  padding-left: 0.35rem;
}

.toolbar-separator {
  align-self: stretch;

  width: 1px;
  margin: 0.15rem 0.2rem;

  background: var(--border);
}

.toolbar label {
  color: var(--muted);

  font-size: 0.85rem;
  font-weight: 600;
}

.toolbar-label {
  color: var(--muted);

  font-size: 0.85rem;
  font-weight: 600;
}

select {
  padding: 0.4rem 2rem 0.4rem 0.65rem;

  color: var(--text);
  background: var(--surface-light);

  border: 1px solid var(--border);
  border-radius: 5px;

  font: inherit;
  cursor: pointer;
}

select:hover {
  border-color: var(--accent);
}

.app-toolbar #version,
.app-toolbar #example-program,
.app-toolbar #number-format,
.app-toolbar .import-menu summary,
.app-toolbar #theme-toggle,
.app-toolbar #help-button {
  height: 2.15rem;
  min-width: 0;
  padding: 0 0.75rem;

  color: var(--text);
  background: var(--surface-light);

  border: 1px solid var(--border);
  border-radius: 5px;

  font-size: 0.8rem;
  font-weight: 600;
  line-height: 2.05rem;
}

.app-toolbar #version {
  min-width: 10.5rem;
  padding-right: 2rem;
}

.app-toolbar #example-program {
  max-width: 17rem;
  padding-right: 2rem;
}

#example-search {
  width: 9rem;
  height: 2.15rem;
  padding: 0 0.65rem;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
  font-size: 0.78rem;
}

.example-details {
  margin: -0.45rem 0 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-toolbar #number-format {
  min-width: 8.5rem;
  padding-right: 2rem;
}


/* ================================================================== */
/* THEME BUTTON                                                       */
/* ================================================================== */

#theme-toggle {
  margin-left: auto;

  min-width: 90px;

  color: var(--text);
  background: var(--surface-light);

  border: 1px solid var(--border);
  border-radius: 5px;

  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.1s,
    border-color 0.1s,
    transform 0.05s;
}

#theme-toggle:hover {
  background: var(--surface);
  border-color: var(--accent);
}

#theme-toggle:active {
  transform: translateY(1px);
}


/* ================================================================== */
/* HELP DIALOG                                                        */
/* ================================================================== */

#help-dialog {
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(44rem, calc(100vh - 2rem));
  padding: 0;
  overflow: auto;

  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.4);
}

#help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.help-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;

  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.help-dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

#close-help {
  min-width: 2rem;
  padding: 0.15rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
}

.help-dialog-content {
  display: grid;
  gap: 1rem;

  padding: 1.25rem;
}

.help-dialog-content section {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.help-dialog-content section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.help-dialog-content h3,
.help-dialog-content p {
  margin: 0;
}

.help-dialog-content h3 {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.help-dialog-content p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}


/* ================================================================== */
/* SOURCE                                                             */
/* ================================================================== */

.source-panel {
  margin-bottom: 1rem;
}

.source-editor {
  position: relative;
}

.source-line-numbers {
  position: absolute;
  z-index: 1;
  top: 1px;
  bottom: 1px;
  left: 1px;

  width: 3.5rem;

  overflow: hidden;
  padding: 1rem 0.65rem;

  color: var(--muted);
  background: var(--surface);
  border-right: 1px solid var(--border);

  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: right;
  user-select: none;
  pointer-events: none;
}

.source-line-number {
  display: block;
  height: 1.6em;
}

.source-line-number.is-active {
  color: var(--accent);
  font-weight: 700;
}

.source-line-number.is-macro-active {
  color: var(--green);
  font-weight: 700;
}

.source-line-number.is-breakpoint {
  color: var(--red);
  font-weight: 700;
}

.source-line-number.is-active.is-breakpoint {
  color: var(--yellow);
}

.source-line-number.breakpoint-target {
  cursor: pointer;
  pointer-events: auto;
}

.source-line-number.breakpoint-target:hover {
  color: var(--accent);
  font-weight: 700;
}

textarea {
  display: block;

  width: 100%;
  min-height: 220px;

  padding: 1rem;

  color: var(--code-text);
  background: var(--code-bg);

  border: 1px solid var(--border);
  border-radius: 8px;

  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;

  resize: vertical;
  outline: none;

  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.source-editor textarea {
  padding-left: 4.5rem;
}

textarea:focus {
  border-color: var(--accent);

  box-shadow:
    0 0 0 2px rgba(122, 162, 247, 0.12);
}

body.light textarea:focus {
  box-shadow:
    0 0 0 2px rgba(49, 95, 186, 0.12);
}


/* ================================================================== */
/* MACHINE CONTROLS                                                   */
/* ================================================================== */

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  margin: 0.75rem 0 1rem;

  flex-wrap: wrap;
}

button {
  padding: 0.45rem 0.9rem;

  color: var(--text);
  background: var(--surface-light);

  border: 1px solid var(--border);
  border-radius: 5px;

  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.1s,
    border-color 0.1s,
    transform 0.05s;
}

button:hover {
  background: var(--surface);
  border-color: var(--accent);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  padding: 0.05rem 0.28rem;
  color: var(--muted);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.7em;
}

.compact-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.compact-control input {
  width: 6.6rem;
  padding: 0.38rem 0.48rem;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.breakpoints-control input {
  width: 9rem;
}

/* ================================================================== */
/* LOAD PROGRAM BUTTON                                                */
/* ================================================================== */

#load-program {
  color: white;

  background: #31548f;
  border-color: #426ba9;
}

#load-program:hover {
  background: #3b63a5;
}

body.light #load-program {
  background: #315fba;
  border-color: #315fba;
}

body.light #load-program:hover {
  background: #244d9d;
  border-color: #244d9d;
}


/* ================================================================== */
/* UNDO BUTTON                                                        */
/* ================================================================== */

#undo {
  color: var(--yellow);
}


/* ================================================================== */
/* FILE IMPORTS                                                        */
/* ================================================================== */

.import-actions {
  display: flex;
  gap: 0.4rem;
}

.import-menu {
  position: relative;
}

.import-menu summary {
  cursor: pointer;
  list-style: none;
}

.import-menu summary::-webkit-details-marker {
  display: none;
}

.import-menu summary::after {
  margin-left: 0.4rem;

  content: "▾";
  font-size: 0.65rem;
}

.import-menu summary:hover,
.import-menu[open] summary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--accent);
}

.import-menu[open] summary::after {
  content: "▴";
}

.import-popover {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.45rem);
  right: auto;
  left: 0;

  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem 0.75rem;

  width: min(340px, calc(100vw - 2rem));
  padding: 0.8rem;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.import-title {
  grid-column: 1 / -1;

  color: var(--text);

  font-size: 0.8rem;
  font-weight: 650;
}

.import-popover > button,
.import-buttons {
  grid-column: 1 / -1;
}

.import-buttons {
  display: flex;
  gap: 0.5rem;
}

#regfile-import,
#program-import {
  position: absolute;

  width: 1px;
  height: 1px;
  overflow: hidden;

  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-button {
  display: inline-flex;
  align-items: center;

  padding: 0.45rem 0.9rem;

  color: var(--text);
  background: var(--surface-light);

  border: 1px solid var(--border);
  border-radius: 5px;

  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.1s,
    border-color 0.1s,
    transform 0.05s;
}

.file-button:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.file-button:active {
  transform: translateY(1px);
}

.selected-file-name,
.regfile-name {
  min-width: 0;

  overflow: hidden;

  color: var(--muted);

  font-family: var(--mono);
  font-size: 0.75rem;

  text-overflow: ellipsis;
  white-space: nowrap;
}

#import-register-file {
  color: var(--text);
}

#reset-register-file {
  color: var(--yellow);
}


/* ================================================================== */
/* MACHINE STATE                                                      */
/* ================================================================== */

.machine-state {
  display: flex;
  align-items: center;
  gap: 0.6rem;

  margin-bottom: 1rem;
  padding: 0.7rem 1rem;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 8px;
}

.state-label {
  color: var(--muted);

  font-size: 0.8rem;
  font-weight: 600;

  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.source-position {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.watch-panel {
  display: grid;
  grid-template-columns: auto minmax(12rem, 20rem) minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem 1rem;
  margin: -0.35rem 0 1rem;
  padding: 0.65rem 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.watch-panel h2 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.watch-panel p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.watch-panel input,
.watch-panel output {
  min-width: 0;
  padding: 0.4rem 0.55rem;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.watch-panel output {
  overflow: auto;
  white-space: nowrap;
}

#state {
  padding: 0.2rem 0.55rem;

  color: var(--green);
  background: rgba(158, 206, 106, 0.1);

  border-radius: 4px;

  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
}

body.light #state {
  background: rgba(63, 125, 32, 0.1);
}


/* ================================================================== */
/* MACHINE PANELS                                                     */
/* ================================================================== */

.machine {
  display: grid;

  grid-template-columns:
    minmax(0, 2fr)
    minmax(0, 3fr);

  gap: 1rem;
}

.machine.secondary-visible {
  grid-template-columns:
    minmax(0, 3fr)
    minmax(0, 2fr);
}

.machine.secondary-visible .registers-panel {
  grid-column: 1 / -1;
}

.enclaves-panel {
  grid-column: 1 / -1;
}

.enclave-table-scroll {
  overflow-x: auto;
  color: var(--code-text);
  background: var(--code-bg);
}

.enclaves-panel table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.3;
}

.enclaves-panel th,
.enclaves-panel td {
  padding: 0.42rem 0.75rem;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.enclaves-panel th {
  color: var(--muted);
  background: var(--surface);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.enclaves-panel tbody tr:last-child td {
  border-bottom: 0;
}

.enclave-id {
  width: 1%;
}

.enclave-empty td {
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

#enclave-counter {
  color: var(--code-text);
  font-family: var(--mono);
  font-weight: 600;
}

.panel {
  min-width: 0;
  overflow: hidden;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0.7rem 1rem;

  background: var(--surface-light);

  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;

  font-size: 0.8rem;
  font-weight: 650;

  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-header span {
  color: var(--muted);

  font-size: 0.7rem;
}


/* ================================================================== */
/* GENERIC PRE                                                        */
/* ================================================================== */

.panel pre {
  margin: 0;
  padding: 0.75rem;

  min-height: 300px;
  max-height: 500px;

  overflow: auto;

  color: var(--code-text);
  background: var(--code-bg);

  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.35;

  tab-size: 2;
}


/* ================================================================== */
/* MEMORY                                                             */
/* ================================================================== */

.memory-focus {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.memory-focus label {
  color: var(--muted);
  font-size: 0.7rem;
}

.memory-focus input {
  width: 7.5rem;
  padding: 0.35rem 0.5rem;

  color: var(--code-text);
  background: var(--code-bg);

  border: 1px solid var(--border);
  border-radius: 5px;

  font-family: var(--mono);
  font-size: 0.75rem;
}

.memory-focus input:focus {
  border-color: var(--accent);
  outline: none;
}

.memory-focus button {
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
}

.secondary-memory-panel {
  min-width: 0;
}

.secondary-memory-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.secondary-memory-controls label {
  color: var(--muted);
  font-size: 0.7rem;
}

.secondary-memory-controls select,
.secondary-memory-controls button {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  font-size: 0.72rem;
}

#memory,
#secondary-memory {
  margin: 0;
  padding: 0 0.6rem;

  height: var(--machine-content-height);
  min-height: 0;
  max-height: none;

  overflow-x: auto;
  overflow-y: auto;

  color: var(--code-text);
  background: var(--code-bg);

  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1;

  white-space: pre;

  outline: none;
  cursor: ns-resize;
}

#memory:focus,
#secondary-memory:focus {
  box-shadow:
    inset 0 0 0 2px rgba(122, 162, 247, 0.15);
}

body.light #memory:focus,
body.light #secondary-memory:focus {
  box-shadow:
    inset 0 0 0 2px rgba(49, 95, 186, 0.15);
}

#secondary-memory {
  height: var(--machine-content-height);
}

.memory-row {
  color: var(--code-text);
  white-space: pre;
  cursor: context-menu;
}

.memory-breakpoint-toggle {
  display: inline-block;
  width: 1ch;
  color: var(--muted);
  cursor: pointer;
}

.memory-breakpoint-toggle:hover,
.memory-breakpoint .memory-breakpoint-toggle {
  color: var(--red);
}

.inline-edit {
  float: right;
  margin: 1px 0 0 0.6rem;
  padding: 0.05rem 0.35rem;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.68rem;
  opacity: 0;
}

.memory-row:hover .inline-edit,
.memory-row:focus-within .inline-edit,
.register:hover .inline-edit,
.register:focus-within .inline-edit {
  opacity: 1;
}

.inline-edit:hover,
.inline-edit:focus-visible {
  color: var(--text);
  background: var(--surface-light);
  border-color: var(--accent);
  opacity: 1;
}

.memory-address {
  color: var(--muted);
}

.watch-target {
  cursor: pointer;
}

.watch-target:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.memory-word {
  color: var(--text);
}

.memory-instruction {
  color: var(--green);
}

.memory-unmapped {
  color: #5f6673;
}

body.light .memory-unmapped {
  color: #9aa1ac;
}

.memory-pc-range {
  background: rgba(122, 162, 247, 0.07);
}

.memory-pc {
  background: rgba(122, 162, 247, 0.14);
}

body.light .memory-pc-range {
  background: rgba(49, 95, 186, 0.06);
}

body.light .memory-pc {
  background: rgba(49, 95, 186, 0.12);
}

.memory-selected-range {
  background: rgba(224, 175, 104, 0.08);
}

.memory-focused-address {
  background: rgba(158, 206, 106, 0.18);
}

.memory-changed {
  animation: changed-flash 1.2s ease-out;
  box-shadow: inset 3px 0 0 var(--green);
}

body.light .memory-focused-address {
  background: rgba(63, 125, 32, 0.15);
}

.memory-selected-address {
  background: rgba(224, 175, 104, 0.18);

  box-shadow:
    inset 3px 0 0 var(--yellow);
}

body.light .memory-selected-range {
  background: rgba(165, 107, 0, 0.07);
}

body.light .memory-selected-address {
  background: rgba(165, 107, 0, 0.14);
}

.memory-pc-boundary {
  color: var(--accent);
  font-weight: 700;
}

.memory-boundary {
  color: var(--yellow);
  font-weight: 700;
}


/* ================================================================== */
/* REGISTERS                                                          */
/* ================================================================== */

#registers {
  height: var(--machine-content-height);

  overflow-y: auto;
  overflow-x: auto;

  padding: 0.25rem 0.4rem;

  color: var(--code-text);
  background: var(--code-bg);

  font-family: var(--mono);
  font-size: 1.05rem;

  white-space: nowrap;
}

.machine.secondary-visible #registers {
  display: block;
  column-count: 3;
  column-fill: balance;
  column-gap: 0.8rem;

  height: auto;
  max-height: clamp(300px, 40vh, 440px);
}

.machine.secondary-visible .register {
  break-inside: avoid;
}

.register {
  display: block;

  width: max-content;
  min-width: 100%;

  margin: 0;
  padding: 2px 8px;

  border-radius: 4px;

  white-space: pre;

  color: var(--code-text);

  cursor: context-menu;

  transition:
    background 0.1s,
    color 0.1s;
}

.register .inline-edit {
  float: none;
  margin-left: 0.6rem;
}

.register-name {
  display: inline-block;

  min-width: 4rem;

  color: #a9b1c1;

  font-weight: 600;
}

body.light .register-name {
  color: #596170;
}

.register-value {
  color: #d8dee9;
}

body.light .register-value {
  color: #343a44;
}


/* ================================================================== */
/* CAPABILITY REGISTERS                                                */
/* ================================================================== */

.register-capability {
  color: #8ab4f8;
}

body.light .register-capability {
  color: #315fba;
}

.register-capability .register-name {
  color: #89b4ff;
}

body.light .register-capability .register-name {
  color: #315fba;
}

.register-capability:hover {
  background: rgba(80, 140, 220, 0.12);
}

body.light .register-capability:hover {
  background: rgba(49, 95, 186, 0.08);
}

.register-selected {
  color: #ffffff;

  background: rgba(122, 162, 247, 0.18);

  box-shadow:
    inset 3px 0 0 var(--accent);
}

body.light .register-selected {
  color: #173d82;
  background: rgba(49, 95, 186, 0.13);
}

.register-selected .register-name {
  color: #ffffff;
}

body.light .register-selected .register-name {
  color: #173d82;
}

.register-selected .register-value {
  color: #ffffff;
}

.register-changed {
  animation: changed-flash 1.2s ease-out;
  box-shadow: inset 3px 0 0 var(--green);
}

@keyframes changed-flash {
  from { background: rgba(158, 206, 106, 0.26); }
  to { background: transparent; }
}

body.light .register-selected .register-value {
  color: #173d82;
}


/* ================================================================== */
/* OUTPUT / ERRORS                                                    */
/* ================================================================== */

[hidden] {
  display: none !important;
}

.error-report {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;

  margin: 0 0 1rem;
  padding: 0.75rem;

  color: var(--text);
  background: rgba(247, 118, 142, 0.09);

  border: 1px solid rgba(247, 118, 142, 0.45);
  border-radius: 8px;
}

body.light .error-report {
  background: rgba(196, 61, 85, 0.07);
  border-color: rgba(196, 61, 85, 0.4);
}

.error-marker {
  display: grid;
  flex: 0 0 1.5rem;
  place-items: center;

  width: 1.5rem;
  height: 1.5rem;

  color: var(--bg);
  background: var(--red);

  border-radius: 50%;

  font-size: 0.85rem;
  font-weight: 800;
}

.error-content {
  flex: 1;
  min-width: 0;
}

#error-title {
  display: block;

  color: var(--red);

  font-size: 0.85rem;
}

#output {
  margin: 0.25rem 0 0;

  color: var(--text);

  font: inherit;
  font-size: 0.8rem;
  line-height: 1.45;

  white-space: pre-wrap;
}

.dismiss-error {
  flex: 0 0 auto;

  margin: -0.25rem -0.25rem 0 0;
  padding: 0;

  width: 1.75rem;
  height: 1.75rem;

  color: var(--muted);
  background: transparent;

  border-color: transparent;

  font-size: 1.1rem;
  line-height: 1;
}

.dismiss-error:hover {
  color: var(--text);
  background: rgba(247, 118, 142, 0.1);
  border-color: rgba(247, 118, 142, 0.35);
}


/* ================================================================== */
/* SCROLLBARS                                                         */
/* ================================================================== */

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}


/* ================================================================== */
/* RESPONSIVE                                                         */
/* ================================================================== */

@media (max-width: 900px) {

  body {
    padding: 1rem;
  }

  .machine {
    grid-template-columns: 1fr;
  }

  .machine.secondary-visible {
    grid-template-columns: 1fr;
  }

  .machine.secondary-visible .registers-panel {
    grid-column: auto;
  }

  .machine.secondary-visible #registers {
    display: block;
    column-count: 1;
    height: var(--machine-content-height);
    max-height: 400px;
  }

  .panel pre {
    max-height: 400px;
  }
}


@media (max-width: 500px) {

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .architecture-picker {
    width: 100%;
    padding-left: 0;
  }

  .architecture-picker #version {
    flex: 1;
  }

  .toolbar-separator {
    display: none;
  }

  #theme-toggle {
    margin-left: 0;
  }

  .import-actions {
    width: 100%;
  }

  .import-menu {
    position: static;
  }

  .import-popover {
    right: 1rem;
    left: 1rem;

    width: auto;
  }

  .controls {
    flex-wrap: wrap;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
  }

  .memory-focus,
  .secondary-memory-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .regfile-name {
    max-width: 180px;
  }

  .watch-panel {
    grid-template-columns: 1fr;
  }
}
