:root {
  font-family: Inter, Arial, sans-serif;
  color: #19283d;
  background: #eef1f5;
  font-synthesis: none;
  font-size: 13px;
  --blue: #0964f5;
  --line: #dce3ed;
  --muted: #607088;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
label.file-button {
  touch-action: manipulation;
}
button,
.file-button {
  border: 1px solid #d2dce9;
  background: #fff;
  border-radius: 5px;
  color: #23344f;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 36px;
}
button:hover {
  background: #eaf1ff;
  border-color: #83aef9;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}
button.outline {
  color: var(--blue);
  border-color: #90b6fc;
  background: #eff5ff;
}
.full {
  width: 100%;
}
:focus-visible {
  outline: 3px solid #ffb52c;
  outline-offset: 3px;
}
a {
  color: var(--blue);
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h2 {
  font-size: 13px;
  letter-spacing: -0.2px;
}
h3 {
  font-size: 12px;
  margin: 18px 0 10px;
}
small {
  font-size: 10px;
}
.blue {
  color: #1684ff;
}
#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 218px;
  background: #081726;
  color: #e3eaf5;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  display: flex;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: #fff;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -1px;
}
.brand small {
  display: block;
  font-size: 7px;
  color: #aabbd0;
  letter-spacing: 1px;
  font-weight: 400;
  margin-top: 5px;
}
.workspace-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #93a5bb;
  display: flex;
  justify-content: space-between;
  margin: 37px 10px 17px;
}
.workspace-label span {
  color: #9dbfe9;
  letter-spacing: 0;
}
nav {
  display: grid;
  gap: 6px;
}
nav button {
  color: #cfdaea;
  background: transparent;
  border-color: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 11px;
  font-size: 16px;
}
nav button span {
  font-size: 12px;
}
nav button small {
  margin-left: auto;
  font-size: 9px;
  color: #91b6f8;
}
nav button:hover {
  background: #142a43;
}
nav .selected {
  background: #142c48;
  color: #74acff;
  border: 1px solid #24476c;
}
.nav-separator {
  height: 1px;
  background: #203045;
  margin: 10px 6px;
}
.local-card {
  margin-top: auto;
  border: 1px solid #24374d;
  background: #102135;
  padding: 14px 10px;
  border-radius: 7px;
  font-size: 11px;
}
.local-card small {
  display: block;
  color: #9eb0c8;
  line-height: 1.7;
  margin: 9px 0 16px;
}
.version {
  font-size: 8px;
  letter-spacing: 0.8px;
  color: #93aed1;
}
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34b78a;
  margin-right: 5px;
}
.app {
  margin-left: 218px;
}
header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  min-height: 94px;
  display: flex;
  align-items: center;
  padding: 18px 24px;
  gap: 15px;
}
.eyebrow {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.3px;
  color: #7e8da1;
  margin-bottom: 7px;
}
.eyebrow span {
  margin: 0 10px;
  color: #c1cad8;
}
h1 {
  font-size: 21px;
  letter-spacing: -0.7px;
}
header p {
  font-size: 11px;
  color: var(--muted);
  margin-top: 7px;
}
header p span {
  margin: 0 5px;
  color: #92a1b3;
}
.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11px;
}
#saved {
  font-size: 10px;
  color: var(--muted);
  margin-right: 7px;
}
#menu {
  display: none;
}
main {
  padding: 0 18px;
}
.steps {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 12px;
  min-height: 90px;
  color: #42536c;
}
.steps > span {
  display: grid;
  grid-template-columns: 31px 1fr;
  column-gap: 10px;
  font-size: 11px;
  font-weight: 600;
}
.steps b {
  grid-row: span 2;
  display: grid;
  place-items: center;
  background: #dce3ec;
  color: #60728e;
  border-radius: 50%;
  width: 30px;
  height: 30px;
}
.steps small {
  font-size: 9px;
  font-weight: 400;
  margin-top: 4px;
  color: #77859a;
}
.steps .active b {
  background: var(--blue);
  color: #fff;
}
.steps i {
  color: #b7c6da;
  font-size: 23px;
  font-style: normal;
}
.safety {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 10px;
  background: #fff9ed;
  border: 1px solid #efdfbc;
  border-radius: 5px;
  padding: 10px 12px;
  margin-bottom: 14px;
  color: #735522;
}
.safety strong {
  white-space: nowrap;
}
.safety a {
  white-space: nowrap;
  margin-left: auto;
  color: #795a20;
}
.work-grid {
  display: grid;
  grid-template-columns: 238px minmax(330px, 1fr) 300px;
  gap: 12px;
  align-items: stretch;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-bottom: 1px solid #e9edf3;
}
.tag {
  font-size: 8px;
  letter-spacing: 0.4px;
  color: #61748e;
  background: #f0f3f8;
  padding: 5px;
  border-radius: 4px;
  white-space: nowrap;
}
.amber {
  color: #8c5b0e;
  background: #fff2da;
}
.panel-content {
  padding: 14px 12px;
}
label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #3b4c63;
  margin-bottom: 12px;
}
input:not([type="range"]),
select,
textarea {
  display: block;
  width: 100%;
  background: #f8fafc;
  border: 1px solid #d9e2ee;
  border-radius: 4px;
  padding: 9px;
  color: #21334b;
  margin-top: 7px;
  min-width: 0;
}
input[type="range"] {
  accent-color: var(--blue);
  min-width: 40px;
}
.part-diagram {
  margin: 14px 0;
  background: #f4f7fb;
  border: 1px solid #e4eaf3;
  border-radius: 5px;
  text-align: center;
  padding: 3px 12px 10px;
}
.part-diagram svg {
  height: 113px;
  width: 100%;
}
.part-diagram span {
  font-size: 8px;
  color: #8191a7;
  letter-spacing: 1px;
}
.numeric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  margin-bottom: 8px;
}
.numeric span {
  display: flex;
  gap: 6px;
  align-items: center;
  color: #7d8da3;
}
.numeric input {
  width: 75px;
  margin: 0;
  padding: 7px;
  font-size: 11px;
}
.hint {
  font-size: 10px;
  line-height: 1.65;
  color: #64748a;
}
.origin {
  display: flex;
  gap: 10px;
  border-top: 1px solid #e7ecf3;
  padding-top: 14px;
  margin: 18px 0;
  color: #4d6688;
}
.origin > span {
  font-size: 24px;
  color: var(--blue);
}
.origin strong {
  font-size: 10px;
}
.origin small {
  display: block;
  line-height: 1.6;
  margin-top: 5px;
}
.viewer-panel {
  display: flex;
  flex-direction: column;
  background: #192431;
  border: 1px solid #253445;
  border-radius: 7px;
  min-width: 0;
  overflow: hidden;
}
.viewer-top {
  display: flex;
  justify-content: space-between;
  padding: 9px;
  background: #202d3d;
  align-items: center;
  gap: 8px;
}
.viewer-tabs {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.viewer-tabs button {
  font-size: 10px;
  background: transparent;
  border-color: transparent;
  color: #b9c8da;
  padding: 7px 9px;
  min-height: 31px;
}
.viewer-tabs .active {
  background: #116af2;
  color: white;
}
.viewer-chip {
  font-size: 8px;
  white-space: nowrap;
  color: #a7bacf;
}
#viewport {
  position: relative;
  min-height: 430px;
  flex: 1;
  overflow: hidden;
  cursor: grab;
}
#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
.view-tools {
  position: absolute;
  top: 13px;
  left: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.view-tools button {
  background: #142233e8;
  border-color: #3a4b62;
  color: #d9e6f7;
  font-size: 9px;
  padding: 7px;
  min-width: 33px;
  min-height: 31px;
}
.viewer-label {
  position: absolute;
  right: 14px;
  top: 17px;
  color: #9bacbf;
  font-size: 8px;
  letter-spacing: 1px;
  z-index: 2;
}
.viewer-label span {
  color: #87baff;
  margin-left: 9px;
}
.legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 2;
  background: #142130da;
  padding: 10px;
  border: 1px solid #34455a;
  border-radius: 5px;
  display: grid;
  gap: 7px;
  color: #d8e3f0;
  font-size: 9px;
}
.legend span:before {
  content: "";
  display: inline-block;
  width: 17px;
  height: 3px;
  margin: 0 7px 2px 0;
  background: #ff6c69;
}
.legend .cut:before {
  background: #2884ff;
}
.legend .tool:before {
  background: #f4cb66;
}
.playback {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 9px;
  border-top: 1px solid #344254;
  background: #192635;
  color: #c9d5e4;
  font-size: 9px;
}
.playback button {
  background: transparent;
  border-color: transparent;
  color: #e0e8f5;
  min-height: 32px;
  padding: 6px;
}
.playback input {
  flex: 1;
  width: 50px;
}
.playback label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #c9d5e4;
  font-size: 9px;
  margin: 0;
}
.playback select {
  width: 46px;
  margin: 0;
  background: #233448;
  color: white;
  border-color: #415169;
  padding: 6px;
}
#position {
  min-width: 49px;
  text-align: center;
}
.code-panel {
  display: flex;
  flex-direction: column;
}
.code-caption {
  font-size: 9px;
  color: #6b7b90;
  padding: 11px;
}
.code-panel textarea {
  resize: vertical;
  flex: 1;
  min-height: 310px;
  background: #101b27;
  color: #dce7f5;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.8;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 14px;
  white-space: pre;
  tab-size: 2;
}
#current-block {
  background: #eaf2ff;
  border-top: 1px solid #c5d9fb;
  padding: 10px;
  font-size: 10px;
  min-height: 34px;
  font-family: monospace;
}
.code-actions {
  padding: 12px;
  display: grid;
  gap: 9px;
}
.file-button {
  text-align: center;
  font-size: 11px;
}
.file-button input {
  max-width: 100%;
  font-size: 9px;
}
.code-note {
  padding: 0 12px 13px;
}
.segment-list {
  max-height: 265px;
  overflow: auto;
  padding: 6px;
}
.segment-list button {
  display: flex;
  text-align: left;
  width: 100%;
  gap: 9px;
  font-size: 10px;
  border-color: transparent;
  border-bottom-color: #edf1f6;
  border-radius: 3px;
  padding: 8px;
  align-items: center;
}
.segment-list button.active {
  background: #eaf2ff;
  border-color: #7cacfc;
  color: #0752c7;
}
.segment-list button small {
  font-family: monospace;
  font-size: 9px;
  color: #65758b;
}
.segment-list b {
  min-width: 21px;
  font-size: 9px;
}
.button-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.button-row button {
  font-size: 10px;
}
.metric {
  margin-top: 16px;
  background: #f1f5fa;
  padding: 16px;
  border-radius: 5px;
  display: grid;
  gap: 8px;
}
.metric small {
  color: #65758b;
}
.metric strong {
  font-size: 21px;
  letter-spacing: -0.7px;
}
.metric span {
  font-size: 9px;
  color: #677b95;
}
.warning {
  padding: 11px;
  background: #fff5e2;
  border: 1px solid #f2dfb8;
  border-radius: 5px;
  color: #805a16;
  font-size: 10px;
  line-height: 1.65;
  margin-top: 12px;
}
.warning p {
  margin-top: 4px;
}
.issue {
  font-size: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f5;
  line-height: 1.5;
}
.issue.error {
  color: #b73232;
}
.issue.pass {
  color: #187454;
}
footer {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #78889d;
  padding: 17px 0 20px;
}
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 20px;
  border: 1px solid #6081b1;
  background: #10243b;
  color: #fff;
  z-index: 80;
  border-radius: 7px;
  max-width: 90vw;
  font-size: 12px;
}
dialog {
  border: 1px solid #cdd8e7;
  box-shadow: 0 20px 80px #07162b55;
  border-radius: 10px;
  max-width: 600px;
  width: calc(100% - 32px);
  padding: 28px;
  color: #20344e;
}
dialog::backdrop {
  background: #07132370;
}
dialog h2 {
  font-size: 22px;
  margin-bottom: 14px;
}
dialog p {
  line-height: 1.7;
  margin: 12px 0;
  font-size: 12px;
}
dialog .close {
  float: right;
  padding: 5px;
  min-width: 32px;
}
dialog textarea {
  height: 160px;
}
.skip {
  position: fixed;
  top: -100px;
  z-index: 100;
  background: white;
  padding: 15px;
}
.skip:focus {
  top: 0;
}
.content-page {
  max-width: 1000px;
  margin: 32px auto;
}
.content-page h2 {
  font-size: 25px;
  margin-bottom: 12px;
}
.content-page p {
  line-height: 1.7;
  margin: 14px 0;
}
.content-page .panel {
  padding: 22px;
  margin: 18px 0;
}
.project-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.project-row strong {
  flex: 1;
}
.tour-highlight {
  outline: 4px solid #ffbe45 !important;
  outline-offset: 3px;
  position: relative;
  z-index: 21;
}
#webgl-error {
  position: relative;
  z-index: 4;
  background: #fff4da;
  padding: 20px;
  margin: 80px 15px 15px;
  font-size: 12px;
  line-height: 1.8;
}
.print-only {
  display: none;
}
@media (min-width: 1600px) {
  .work-grid {
    grid-template-columns: 260px minmax(440px, 1fr) 330px;
  }
  #viewport {
    min-height: 510px;
  }
}
@media (max-width: 1250px) {
  #sidebar {
    width: 185px;
    padding: 20px 10px;
  }
  .brand {
    font-size: 20px;
  }
  .brand img {
    width: 34px;
  }
  .brand small {
    font-size: 6px;
  }
  .app {
    margin-left: 185px;
  }
  .work-grid {
    grid-template-columns: 215px minmax(300px, 1fr);
  }
  .code-panel {
    grid-column: 1/-1;
    display: grid;
    grid-template-columns: 215px 1fr 200px;
  }
  .code-panel .panel-head {
    grid-column: 1/-1;
  }
  .code-panel textarea {
    grid-column: 2;
    grid-row: 2/6;
    min-height: 210px;
    max-height: 290px;
  }
  .code-caption {
    grid-column: 1;
  }
  .code-actions {
    grid-column: 3;
    grid-row: 2/5;
  }
  #current-block {
    grid-column: 1;
  }
  .code-note {
    grid-column: 1;
  }
  .operations {
    grid-column: 1;
  }
  .checks {
    grid-column: 1/-1;
  }
  .header-actions {
    max-width: 400px;
  }
  #saved {
    width: 100%;
    text-align: right;
  }
  .safety {
    flex-wrap: wrap;
  }
  .safety a {
    margin-left: 0;
  }
  .viewer-chip {
    display: none;
  }
}
@media (max-width: 850px) {
  #sidebar {
    width: 218px;
    transform: translateX(-100%);
    transition: transform 0.15s;
  }
  body.nav-open #sidebar {
    transform: translateX(0);
  }
  .app {
    margin-left: 0;
  }
  header {
    padding: 16px;
    flex-wrap: wrap;
  }
  #menu {
    display: block;
  }
  .project-heading {
    flex: 1;
  }
  .header-actions {
    max-width: 100%;
    width: 100%;
    margin: 0;
  }
  #saved {
    width: auto;
    margin-right: auto;
  }
  .steps {
    gap: 5px;
  }
  .steps i {
    display: none;
  }
  .steps > span {
    font-size: 10px;
    column-gap: 6px;
  }
  .steps small {
    font-size: 8px;
  }
  .safety {
    font-size: 10px;
  }
  main {
    padding: 0 12px;
  }
}
@media (max-width: 600px) {
  h1 {
    font-size: 19px;
  }
  .eyebrow {
    font-size: 7px;
  }
  .header-actions button {
    font-size: 10px;
    padding: 8px;
  }
  #saved {
    width: 100%;
    text-align: left;
  }
  .steps {
    min-height: 76px;
    gap: 8px;
    justify-content: space-between;
  }
  .steps > span {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 9px;
    gap: 6px;
  }
  .steps small {
    display: none;
  }
  .steps b {
    width: 25px;
    height: 25px;
  }
  .safety {
    padding: 10px;
    gap: 7px;
  }
  .work-grid {
    grid-template-columns: 1fr;
  }
  .part-panel {
    grid-row: 2;
  }
  .viewer-panel {
    grid-row: 1;
    min-height: 440px;
  }
  #viewport {
    min-height: 355px;
  }
  .viewer-tabs button {
    font-size: 9px;
    padding: 7px;
  }
  .part-diagram {
    display: none;
  }
  .part-panel .panel-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .part-panel h3,
  .origin,
  .part-panel .hint,
  .part-panel .full {
    grid-column: 1/-1;
  }
  .part-panel label {
    margin: 0;
  }
  .part-panel .numeric {
    display: block;
  }
  .numeric span {
    margin-top: 7px;
  }
  .numeric input {
    width: 100%;
  }
  .code-panel {
    display: flex;
    grid-column: auto;
  }
  .code-panel textarea {
    min-height: 280px;
    max-height: 400px;
  }
  .operations,
  .checks {
    grid-column: auto;
  }
  .simulation {
    grid-row: auto;
  }
  .playback {
    gap: 3px;
    padding: 7px;
  }
  .playback label {
    font-size: 0;
  }
  .playback button {
    padding: 7px;
  }
  .playback select {
    font-size: 10px;
  }
  footer {
    gap: 10px;
    line-height: 1.6;
  }
  footer > span {
    max-width: 55%;
  }
  .project-row {
    flex-wrap: wrap;
  }
  .project-row strong {
    min-width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
@media print {
  body > * {
    display: none !important;
  }
  body > .print-only {
    display: block !important;
    color: #000;
    font-size: 12px;
    padding: 25px;
  }
  .print-only h1 {
    font-size: 24px;
  }
  .print-only p {
    line-height: 1.7;
    margin: 12px 0;
  }
  .print-only pre {
    white-space: pre-wrap;
    font-size: 9px;
  }
}
@media (min-width: 1251px) {
  .steps {
    min-height: 72px;
  }
  .part-panel,
  .viewer-panel,
  .code-panel {
    height: 568px;
  }
  .part-panel .panel-content {
    overflow: auto;
  }
  .part-panel .panel-content {
    padding: 11px 12px;
  }
  .part-panel .part-diagram {
    margin: 9px 0;
  }
  .part-panel .part-diagram svg {
    height: 82px;
  }
  .part-panel .part-diagram span {
    font-size: 7px;
  }
  .part-panel h3 {
    margin: 12px 0 8px;
  }
  .part-panel .origin {
    margin: 12px 0;
    padding-top: 10px;
  }
  .part-panel label {
    margin-bottom: 8px;
  }
  .part-panel input:not([type="range"]),
  .part-panel select {
    padding: 7px;
  }
  .code-panel textarea {
    min-height: 200px;
  }
  .operations .segment-list {
    max-height: 252px;
  }
}
#preview-stale {
  position: absolute;
  bottom: 100px;
  left: 60px;
  right: 15px;
  z-index: 5;
  background: #fff1cb;
  color: #68450c;
  border: 1px solid #c49438;
  border-radius: 5px;
  padding: 12px;
  font-size: 11px;
  line-height: 1.5;
}
/* Contrast corrections for compact technical annotations. */
.eyebrow,
.steps small,
.part-diagram span,
footer,
.code-caption {
  color: #56677f;
}
.tag {
  color: #52647e;
}
.metric span,
.segment-list button small {
  color: #52647b;
}
.viewer-label {
  color: #bdcadd;
}
.viewer-chip {
  color: #c2d0df;
}
.numeric span {
  color: #56677f;
}
.local-card small {
  color: #b0c2d9;
}
.eyebrow span,
header p span,
.steps i {
  color: #5c6e86;
}
.steps b {
  color: #435674;
}
.steps .active b {
  color: #fff;
}
@media (max-width: 850px) {
  #sidebar {
    visibility: hidden;
  }
  .nav-open #sidebar {
    visibility: visible;
  }
}
.metric small {
  color: #52647b;
}
/* All configuration fields participate in document flow: no hidden lower controls. */
.work-grid {
  align-items: start;
}
.part-panel {
  height: auto !important;
  overflow: visible;
}
.part-panel .panel-content {
  overflow: visible !important;
  max-height: none !important;
}
.preparation-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.preparation-fields h3 {
  grid-column: 1/-1;
}
.preparation-fields textarea {
  min-height: 110px;
  resize: vertical;
}
.preparation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}
.preparation-progress {
  padding: 16px;
  background: #eaf2ff;
  border: 1px solid #9ebff4;
  border-radius: 6px;
  line-height: 1.8;
  color: #284d83;
}
@media (max-width: 600px) {
  .preparation-fields {
    grid-template-columns: 1fr;
  }
  .preparation-actions button {
    width: 100%;
  }
}
.project-heading {
  min-width: 0;
  overflow-wrap: anywhere;
}
.project-row strong,
.content-page p {
  overflow-wrap: anywhere;
}

/* Keep every navigation entry reachable in short and zoomed viewports. */
#sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
}
#sidebar > * {
  flex-shrink: 0;
}
#nav-close {
  display: none;
}
@media (max-width: 850px) {
  #nav-close {
    display: block;
    align-self: flex-end;
    margin-bottom: 12px;
    color: #fff;
    background: #18324f;
    border-color: #6f89a8;
  }
}

/* Long project references must wrap inside confirmations and notices. */
dialog {
  overflow-wrap: anywhere;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
dialog button {
  max-width: 100%;
  white-space: normal;
}
#toast {
  overflow-wrap: anywhere;
}

#toast {
  width: max-content;
  max-width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  pointer-events: none;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 0;
}
.workflow-actions button {
  flex: 1 1 170px;
}
.viewer-top {
  flex-wrap: wrap;
  gap: 8px;
}
#expand-viewer {
  color: #e5efff;
  background: #233b57;
  border-color: #607b9c;
  white-space: normal;
}
body.viewer-expanded {
  overflow: hidden;
}
.viewer-expanded #viewer-panel {
  position: fixed;
  inset: 0;
  z-index: 110;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  border-radius: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.viewer-expanded #viewport {
  flex: 1;
  min-height: 0;
  height: auto;
}
.viewer-expanded .viewer-top,
.viewer-expanded .playback {
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .workflow-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .workflow-actions button {
    min-width: 0;
    padding: 10px 6px;
    font-size: 12px;
  }
  .viewer-expanded .viewer-tabs {
    flex-wrap: wrap;
  }
  .viewer-expanded .viewer-top {
    padding: 8px;
  }
}

.plan-preview {
  display: block;
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  margin: 16px auto;
  border: 1px solid var(--line);
}
.plan-confirm {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.6;
  margin: 16px 0;
}
.plan-confirm input {
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  margin: 2px 0;
}

.viewer-expanded #toast {
  z-index: 130;
}

#cutting-parameters {
  margin: 14px 0;
  line-height: 1.6;
}
#cutting-parameters summary {
  cursor: pointer;
  color: #284d83;
  font-weight: 600;
}
#cutting-parameters[open] summary {
  margin-bottom: 12px;
}
@media (min-width: 1251px) {
  .part-panel {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
  .viewer-panel {
    grid-column: 2;
    grid-row: 1;
  }
  .code-panel {
    grid-column: 3;
    grid-row: 1;
  }
  .simulation {
    grid-column: 2;
    grid-row: 2;
  }
  .checks {
    grid-column: 3;
    grid-row: 2;
  }
  .operations {
    grid-column: 1;
    grid-row: 3;
  }
}
@media (max-width: 600px) {
  .part-panel #cutting-parameters {
    grid-column: 1 / -1;
  }
}

#machining-start {
  min-height: 38px;
  font-weight: 600;
}
#machining-status {
  position: absolute;
  bottom: 12px;
  right: 12px;
  max-width: calc(100% - 24px);
  background: #ffffffed;
  color: #20344e;
  border: 1px solid #b7c6d8;
  border-radius: 5px;
  padding: 9px 12px;
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
  z-index: 3;
}
#viewport[data-mode="machining"] .legend {
  display: none;
}
#viewport .viewer-label {
  color: #3e536c;
}
#viewport .viewer-label span {
  color: #1b5b9f;
}
@media (max-width: 600px) {
  #machining-start {
    font-size: 12px;
    flex: 1 1 auto;
  }
  #machining-status {
    font-size: 10px;
    padding: 6px 8px;
  }
}

.viewer-tabs {
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

#viewport {
  background: #e9eef4;
}

.beta-intro {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid #cbdcf5;
  border-radius: 12px;
  background: #f4f8ff;
  color: #22354c;
}
.beta-intro h2 {
  font-size: 1.2rem;
  margin: 12px 0;
}
.beta-intro p {
  max-width: 95ch;
  line-height: 1.65;
  margin: 10px 0;
}
.beta-actions {
  flex-wrap: wrap;
  gap: 8px;
}
.legal-link {
  display: block;
  color: #455d7b;
  font-size: 12px;
  padding: 12px;
}
.feedback-form {
  display: grid;
  gap: 16px;
  max-width: 720px;
}
.feedback-form textarea {
  min-height: 160px;
}
.feedback-form a {
  overflow-wrap: anywhere;
}
.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
@media (max-width: 600px) {
  .beta-intro {
    padding: 14px;
  }
  .beta-actions > button {
    width: 100%;
    white-space: normal;
  }
}
/* Public beta notices meet the same text-contrast checks as the workspace. */
#sidebar .legal-link { color: #bccde1; }
.beta-intro .hint { color: #42566f; }
