/* ─── MODALS ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 30px;
  min-width: 280px;
  max-width: 380px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--overlay-ring);
  transform: translateY(-8px);
  transition: transform .2s;
}

.overlay.show .modal {
  transform: translateY(0);
}

.modal-title {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.modal-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.modal-lbl {
  font-family: var(--sans);
  font-size: .67rem;
  color: var(--text2);
  min-width: 130px;
}

.modal-section-lbl {
  font-family: var(--sans);
  font-size: .65rem;
  color: var(--text3);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 12px 0 6px;
  border-top: 1px solid var(--border2);
  margin: 10px 0 8px;
}

.confirm-msg {
  font-size: .83rem;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 22px;
  font-family: var(--mono);
}

.modal-foot {
  display: flex;
  gap: 7px;
  margin-top: 14px;
  justify-content: flex-end;
}

.btn-p {
  padding: 6px 16px;
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: .7rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}

.btn-p:hover {
  filter: brightness(1.15);
}

.btn-g {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text2);
  font-family: var(--mono);
  font-size: .7rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}

.btn-g:hover {
  background: var(--surface);
  color: var(--text);
}

/* ─── TABS ─── */
.modal.settings-modal-wide {
  max-width: 600px;
  width: 90vw;
  display: flex;
  flex-direction: column;
}

.modal-tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 20px;
  overflow-x: auto;
}

.modal-tab {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text2);
  cursor: pointer;
  padding: 8px 4px;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.modal-tab:hover {
  color: var(--text);
}

.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

/* ─── ABOUT MODAL ─── */
.about-logo-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border2);
}

.about-logo-header .logo-author {
  opacity: 1;
  position: static;
  margin-top: 0;
  font-size: 0.6rem;
  pointer-events: none;
}

.about-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 4px;
}

.about-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.about-row:last-child {
  border-bottom: none;
}

.about-lbl {
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--text3);
  min-width: 90px;
  flex-shrink: 0;
  letter-spacing: .04em;
}

.about-val {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--text);
}

.about-val em {
  color: var(--accent);
  font-style: normal;
}

.about-badge {
  font-size: .65rem;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: .04em;
}

.about-link {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: opacity var(--transition-fast);
}

.about-link:hover {
  opacity: 0.75;
}

.about-link svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  flex-shrink: 0;
}

/* ─── CTX MENU ─── */
.ctx {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 4px;
  z-index: 800;
  box-shadow: var(--shadow-md);
  min-width: 240px;
  display: none;
}

.ctx[data-mode="state"] .ctx-edge,
.ctx[data-mode="edge"] .ctx-state {
  display: none;
}

.ctx-i {
  padding: 6px 12px;
  font-size: .78rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ctx-i:hover {
  background: var(--surface3);
}

.ctx-i.danger {
  color: var(--red);
}

.ctx-i.danger:hover {
  background: var(--red-soft);
}

/* ─── STATUS ─── */
.status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .07em;
  padding: 4px 13px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  color: var(--text2);
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
  white-space: nowrap;
  z-index: 10;
}

.status.show {
  opacity: 1;
}

/* ── Parse tree ── */
.parse-tree-svg {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  display: block;
  margin: 8px 0;
}

.pt-node-nt {
  fill: rgba(79, 195, 247, .15);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.pt-node-t {
  fill: rgba(255, 213, 79, .12);
  stroke: var(--gold);
  stroke-width: 1.5;
}

.pt-text {
  font-family: var(--mono);
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--text);
}

.pt-edge {
  stroke: var(--border2);
  stroke-width: 1;
}

/* ── Computation tree ── */
.ct-node {
  font-family: var(--mono);
  font-size: .68rem;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--surface);
  display: inline-block;
}

.ct-node.accept {
  border-color: rgba(255, 213, 79, .5);
  color: var(--gold);
  background: rgba(255, 213, 79, .08);
}

.ct-node.reject {
  border-color: rgba(255, 107, 107, .3);
  color: var(--red);
  background: rgba(255, 107, 107, .05);
}

/* ── Help modal ── */
.help-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: .72rem;
  margin-top: 8px;
}

.help-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
}

.help-table td:first-child {
  color: var(--accent);
  font-weight: 600;
  width: 120px;
}

.help-section {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 12px 0 4px;
}

/* ── CFL pump visualization ── */
.pump-char.u-part {
  background: rgba(79, 195, 247, .12);
  border-color: rgba(79, 195, 247, .3);
  color: var(--accent);
}

.pump-char.v-part {
  background: rgba(206, 147, 216, .15);
  border-color: rgba(206, 147, 216, .3);
  color: var(--purple);
}

.pump-char.x-part2 {
  background: rgba(105, 240, 174, .1);
  border-color: rgba(105, 240, 174, .3);
  color: var(--green);
}

.pump-char.y-part2 {
  background: rgba(255, 213, 79, .12);
  border-color: rgba(255, 213, 79, .3);
  color: var(--gold);
}

.pump-char.z-part2 {
  background: rgba(255, 107, 107, .08);
  border-color: rgba(255, 107, 107, .25);
  color: var(--red);
}

/* ── Decision result cards ── */
.dec-card-empty {
  border-color: rgba(255, 107, 107, .3) !important;
}

.dec-card-nonempty {
  border-color: rgba(105, 240, 174, .3) !important;
}

.dec-card-finite {
  border-color: rgba(105, 240, 174, .3) !important;
}

.dec-card-infinite {
  border-color: rgba(255, 183, 77, .3) !important;
}

.dec-card-universal {
  border-color: rgba(105, 240, 174, .3) !important;
}

.dec-card-notuniversal {
  border-color: rgba(255, 107, 107, .3) !important;
}

/* ── M2 workspace indicator ── */
.m2-status {
  font-family: var(--mono);
  font-size: .65rem;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  display: inline-block;
  color: var(--text2);
}

.m2-status.saved {
  border-color: rgba(105, 240, 174, .35);
  color: var(--green);
}

/* ── Decidability table ── */
.dec-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: .7rem;
}

.dec-table th {
  background: var(--surface2);
  color: var(--text2);
  padding: 7px 10px;
  border: 1px solid var(--border2);
  font-weight: 600;
}

.dec-table td {
  padding: 7px 10px;
  border: 1px solid var(--border);
  text-align: center;
}

.dec-table td.yes {
  color: var(--green);
}

.dec-table td.semi {
  color: var(--orange);
}

.dec-table td.no {
  color: var(--red);
}

/* ── Workspace B save button ── */
.ws-save-btn {
  width: 100%;
  padding: 5px 10px;
  background: rgba(105, 240, 174, .08);
  border: 1px solid rgba(105, 240, 174, .25);
  color: var(--green);
  font-family: var(--mono);
  font-size: .65rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 4px;
}

.ws-save-btn:hover {
  background: rgba(105, 240, 174, .15);
}

/* ─── FOCUS RING ─── */
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
