/* Theory of Constraints dice game — tool-specific styles (MacPlus shared.css for chrome) */
.toc-tool {
  --toc-acc: #c8501e;
  --toc-bn: #9b1c1c;
  --toc-ok: #2f8f5b;
  --toc-blue: #1a4d8c;
  --toc-match: #c98a2b;
  --toc-head: #e04a2f;
  --toc-badge-bn: #9b1c1c;
  --toc-badge-fast: #1a4d8c;
}

.toc-page .header-back-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 6px 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.toc-page .header-back-link:hover {
  border-color: var(--text-secondary);
}

.toc-page .page-intro--compact {
  margin-bottom: 1rem;
}

.page-intro .lead {
  color: var(--text-secondary);
  max-width: 780px;
}

:root[data-theme='dark'] .toc-tool {
  --toc-acc: #f08a4b;
  --toc-bn: #ff8787;
  --toc-ok: #4cc38a;
  --toc-blue: #74c0fc;
  --toc-match: #e0a64a;
  --toc-head: #ff7a5c;
  --toc-badge-bn: #9b1c1c;
  --toc-badge-fast: #1a4d8c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .toc-tool {
    --toc-acc: #f08a4b;
    --toc-bn: #ff8787;
    --toc-ok: #4cc38a;
    --toc-blue: #74c0fc;
    --toc-match: #e0a64a;
    --toc-head: #ff7a5c;
    --toc-badge-bn: #9b1c1c;
    --toc-badge-fast: #1a4d8c;
  }
}

.toc-tool .card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0 0 16px;
}

.toc-tool .presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toc-tool button,
.toc-tool select {
  font: inherit;
  color: inherit;
}

.toc-tool button {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  min-height: 40px;
}

.toc-tool button:hover {
  border-color: var(--text-secondary);
}

.toc-tool button.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.toc-tool button.on {
  outline: 2px solid var(--toc-acc);
  outline-offset: 1px;
}

.toc-tool .grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.toc-tool .grid > .card {
  margin: 0 0 16px;
}

@media (max-width: 900px) {
  .toc-tool .grid {
    grid-template-columns: 1fr;
  }
}

.toc-tool .line {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 4px 2px 8px;
}

.toc-tool .node {
  flex: 0 0 auto;
  width: 92px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 6px;
  text-align: center;
  background: var(--bg);
  position: relative;
}

.toc-tool .node.src,
.toc-tool .node.out {
  width: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.toc-tool .node .nm {
  font-size: 13px;
  font-weight: 600;
}

.toc-tool .node .dn {
  font-size: 11px;
  color: var(--text-secondary);
}

.toc-tool .node.bn {
  border-color: var(--toc-bn);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--toc-bn) 35%, transparent);
}

.toc-tool .node.fast {
  border-color: var(--toc-blue);
}

.toc-tool .badge {
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 6px;
  color: #fff;
  margin-top: 4px;
}

.toc-tool .badge.b {
  background: var(--toc-badge-bn);
}

.toc-tool .badge.f {
  background: var(--toc-badge-fast);
}

.toc-tool .die {
  width: 38px;
  height: 38px;
  margin: 6px auto 4px;
  border-radius: 8px;
  border: 2px solid var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  background: var(--bg-elevated);
}

.toc-tool .die.idle {
  opacity: 0.35;
}

.toc-tool .mv {
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 18px;
}

.toc-tool .mv b {
  color: var(--text);
}

.toc-tool .mv .ls {
  color: var(--toc-bn);
}

.toc-tool .q {
  flex: 1 0 56px;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 4px;
}

.toc-tool .q .num {
  font-weight: 700;
  font-size: 18px;
}

.toc-tool .q .num.big {
  color: var(--toc-bn);
}

.toc-tool .pile {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: center;
  gap: 2px;
  width: 56px;
  max-height: 92px;
  overflow: hidden;
}

.toc-tool .m {
  width: 3px;
  height: 16px;
  background: var(--toc-match);
  border-radius: 1px;
  position: relative;
}

.toc-tool .m::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--toc-head);
}

.toc-tool .q .arrow {
  color: var(--text-secondary);
  font-size: 12px;
}

.toc-tool .big-out {
  font-size: 26px;
  font-weight: 700;
}

@media (max-width: 640px) {
  .toc-tool .line {
    flex-direction: column;
    overflow: visible;
  }

  .toc-tool .node,
  .toc-tool .node.src,
  .toc-tool .node.out {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 46px 1fr;
    align-items: center;
    text-align: left;
    gap: 8px;
    padding: 8px 10px;
  }

  .toc-tool .node.src,
  .toc-tool .node.out {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
  }

  .toc-tool .node .die {
    margin: 0;
  }

  .toc-tool .node .mv {
    text-align: right;
  }

  .toc-tool .q {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    min-height: 30px;
    padding: 4px 0;
  }

  .toc-tool #ctlMain {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--bg-elevated);
    padding: 8px 0;
    margin: 4px -4px 0;
    border-top: 1px solid var(--border);
  }

  .toc-tool #ctlMain button {
    flex: 1 1 auto;
    padding: 8px 6px;
  }

  .toc-tool .pile {
    width: auto;
    max-width: 220px;
    max-height: 40px;
    flex-wrap: wrap;
  }

  .toc-tool .q .arrow {
    transform: rotate(90deg);
  }
}

.toc-tool .ctl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.toc-tool .metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 640px) {
  .toc-tool .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.toc-tool .met {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.toc-tool .met .k {
  font-size: 12px;
  color: var(--text-secondary);
}

.toc-tool .met .v {
  font-size: 20px;
  font-weight: 700;
}

.toc-tool .met .v small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.toc-tool .set label {
  display: block;
  font-size: 14px;
  margin: 10px 0 4px;
}

.toc-tool .set select,
.toc-tool .set input[type='range'] {
  width: 100%;
}

.toc-tool .set input[type='range'] {
  height: 24px;
  min-height: 24px;
}

.toc-tool .set select {
  padding: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
}

.toc-tool .chk {
  display: flex !important;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
}

.toc-tool .chk input {
  margin-top: 2px;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.toc-tool .hints {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-tool .hints li {
  border-left: 3px solid var(--toc-acc);
  padding: 6px 10px;
  margin: 0 0 8px;
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 15px;
}

.toc-tool .charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 760px) {
  .toc-tool .charts {
    grid-template-columns: 1fr;
  }
}

.toc-tool canvas {
  width: 100%;
  height: 220px;
  display: block;
}

.toc-tool .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.toc-tool .legend .leg-swatch {
  display: inline-block;
  width: 14px;
  height: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

.toc-tool .legend .leg-swatch--out {
  background: var(--toc-ok);
}

.toc-tool .legend .leg-swatch--exp {
  background: var(--text-secondary);
}

.toc-tool .legend .leg-swatch--lim {
  background: var(--toc-bn);
}

.toc-tool .cmp-scroll {
  overflow-x: auto;
  margin-top: 10px;
}

.toc-tool tr.cmp-row-mine {
  font-weight: 600;
}

.toc-tool table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.toc-tool th,
.toc-tool td {
  text-align: left;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.toc-tool td.n {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.toc-tool .bar {
  height: 8px;
  background: var(--toc-ok);
  border-radius: 4px;
  margin-top: 4px;
}

.toc-tool .bar.w {
  background: var(--toc-match);
}

.toc-tool .note {
  color: var(--text-secondary);
  font-size: 14px;
}

.toc-guide {
  margin-bottom: 16px;
}

.toc-guide summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 4px 0;
}

.toc-guide[open] summary {
  margin-bottom: 12px;
}

.toc-guide ol {
  padding-left: 1.25rem;
}

.scenario-cards {
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  .scenario-cards {
    grid-template-columns: 1fr 1fr;
  }
}

.scenario-cards article {
  margin: 0;
}

.scenario-cards h3 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.toc-faq {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-faq li {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.toc-faq h3 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.toc-faq p {
  margin: 0;
  color: var(--text-secondary);
}

.toc-content-nav {
  margin-top: 24px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.toc-content-nav a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 24px;
  min-width: 24px;
  display: inline-flex;
  align-items: center;
}

.toc-page .site-footer a {
  min-height: 24px;
  min-width: 24px;
  display: inline-flex;
  align-items: center;
  padding: 4px 2px;
}
