main {
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.3s, opacity 0.3s;
}

body > canvas {
  transition: filter 0.35s ease, opacity 0.35s ease;
}

body.structure-viewing > canvas {
  filter: blur(4px) saturate(0.82) brightness(1.05);
  opacity: 0.66;
}

body.structure-viewing::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.08) 30%, rgba(255, 255, 255, 0) 56%),
    rgba(255, 255, 255, 0.18);
}

body.structure-viewing::after {
  content: "";
  position: fixed;
  left: 50%;
  top: 69%;
  z-index: 1;
  width: min(420px, 52vw);
  height: min(96px, 12vw);
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(38, 50, 56, 0.36), rgba(38, 50, 56, 0.12) 48%, rgba(38, 50, 56, 0) 74%);
  filter: blur(16px);
  transform: translate(-50%, -50%);
  animation: structureShadowFloat 4.8s ease-in-out infinite;
}

nav {
  position: absolute;
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 2;
}

nav.right {
  right: 10px;
}

nav.right label,
nav.right #erase,
nav.right #settle {
  grid-template-columns: 44px;
  justify-content: center;
  width: 64px;
  padding: 0 8px;
}

nav.left {
  left: 10px;
  align-items: flex-start;
}

nav.left .menu-toggle {
  display: none;
}

nav.left label,
nav.left #calc {
  grid-template-columns: 44px;
  justify-content: center;
  width: 64px;
  padding: 0 8px;
}

nav.left label > span,
nav.left #calc > span {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

nav.left .tool-icon {
  grid-column: 1;
}

nav label,
#calc,
#erase,
#settle {
  position: relative;
  display: grid;
  align-items: center;
  grid-template-columns: 92px 44px;
  column-gap: 8px;
  height: 56px;
  width: 148px;
  font: inherit;
  border: 0;
  padding: 0 8px;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  box-sizing: border-box;
  user-select: none;
  transition: background 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
}

nav input:checked + label {
  background: rgba(251, 192, 45, 0.1);
}

nav input:checked + label::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 4px;
  height: 26px;
  border-radius: 999px;
  background: rgba(251, 192, 45, 0.96);
  transform: translateY(-50%);
}

nav.right input:checked + label::before {
  left: 2px;
}

nav.left input:checked + label::before {
  right: 2px;
}

nav label > span,
#erase > span,
#settle > span,
#calc > span {
  width: 92px;
  font-weight: bold;
  text-align: center;
  border-radius: 20px;
  white-space: nowrap;
  transition: color 0.2s ease, opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

nav.right label > span,
nav.right #erase > span,
nav.right #settle > span {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tool-icon,
.atom-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--black);
  border: 2px solid transparent;
  box-sizing: border-box;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

nav.right .tool-icon,
nav.right .atom-icon {
  grid-column: 1;
}

.tool-icon {
  border-color: transparent;
  background: transparent;
  border-radius: 6px;
  padding: 2px;
}

.atom-icon {
  color: var(--white);
  font-size: 1rem;
  font-weight: bold;
  clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0 50%);
}

.atom-h {
  width: 34px;
  height: 34px;
  color: var(--black);
  background: #f7f9fa;
  border-color: #8a969c;
  clip-path: none;
  border-radius: 4px;
}

.atom-c {
  background: #263238;
}

.atom-n {
  background: #3e95ba;
}

.atom-o {
  background: #b52e25;
}

.building:checked + label,
.move-mode label[for="buildOption"] {
  background: rgba(251, 192, 45, 0.1);
}

nav.right input[name="atom"]:checked + label {
  background: rgba(251, 192, 45, 0.12);
}

#leftMenu:not(:checked) + label > span {
  color: rgba(38, 50, 56, 0.62);
  opacity: 0.72;
}

.building:checked + label > span {
  background: transparent;
}

.building:checked + label .atom-icon,
label[for="buildOption"] .tool-icon {
  transform: none;
}

#cutMode:checked + label > span {
  background: transparent;
}

#cutMode:checked + label .tool-icon {
  color: var(--black);
}

body.cut-mode #cutMode + label {
  background: rgba(251, 192, 45, 0.1);
}

body.cut-mode #cutMode + label::before {
  background: rgba(251, 192, 45, 0.96);
}

#cutMode:checked ~ input[name="atom"] + label {
  opacity: 0.38;
  pointer-events: none;
}

#cutMode:checked ~ input[name="atom"] + label > span {
  background: transparent;
}

body.cut-mode nav.right input[name="atom"] + label > span {
  background: transparent;
}

#info + label > .info-open,
#info:checked + label > .info-close,
#leftMenu + label > .menu-open,
#leftMenu:checked + label > .menu-open,
#shareToggle + label > .share-open,
#shareToggle:checked + label > .share-open {
  display: inline-grid;
}

#info + label > .info-close,
#info:checked + label > .info-open,
#leftMenu + label > .menu-close,
#leftMenu:checked + label > .menu-close {
  display: none;
}

#buildOption ~ .building + label,
#buildOption ~ .building,
#buildOption:checked ~ .building + label,
#buildOption:checked ~ .building {
  visibility: visible;
  opacity: 1;
  height: 56px;
  transition: visibility 0.3s, opacity 0.3s, height 0.3s, filter 0.18s ease;
}

#buildOption ~ #erase,
#buildOption:checked ~ #erase {
  position: absolute;
  top: 232px;
  right: 66px;
  visibility: hidden;
  opacity: 0;
  height: 56px;
  pointer-events: none;
  transition: opacity 0.18s ease, filter 0.18s ease, visibility 0s linear 0.18s;
}

#buildOption:checked ~ #cutMode:checked ~ #erase {
  position: absolute;
  top: 232px;
  right: 66px;
  visibility: visible;
  opacity: 1;
  height: 56px;
  pointer-events: auto;
  transition: opacity 0.18s ease, filter 0.18s ease, visibility 0s;
}

#buildOption:checked ~ #cutMode:checked ~ input[name="atom"] + label {
  opacity: 0.38;
}

#buildOption:checked ~ #cutMode:checked ~ input[name="atom"] + label > span {
  background: transparent;
}

body.cut-mode nav.right #buildOption:checked + label,
body.cut-mode nav.right #buildOption:checked ~ input[name="atom"] + label,
body.cut-mode nav.right label[for="buildOption"],
body.cut-mode nav.right #buildOption:checked ~ #settle {
  opacity: 0.24 !important;
  filter: grayscale(0.45) !important;
}

body.cut-mode nav.right #buildOption:checked ~ input[name="atom"] + label {
  background: transparent;
}

body.cut-mode nav.right #buildOption:checked ~ input[name="atom"] + label::before {
  content: none;
}

body.cut-mode nav.right #cutMode + label,
body.cut-mode nav.right #erase {
  opacity: 1;
  filter: none;
}

body.move-mode nav.right input[name="atom"] + label,
body.move-mode nav.right #cutMode + label,
body.move-mode nav.right #settle {
  background: transparent;
  opacity: 0.24 !important;
  filter: grayscale(0.45);
}

body.move-mode nav.right label[for="buildOption"] {
  background: rgba(251, 192, 45, 0.1);
}

body.move-mode nav.right label[for="buildOption"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 4px;
  height: 26px;
  border-radius: 999px;
  background: rgba(251, 192, 45, 0.96);
  transform: translateY(-50%);
}

body.move-mode nav.right input[name="atom"] + label::before,
body.move-mode nav.right #cutMode + label::before {
  content: none;
}

#leftMenu + label,
#info + label {
  position: relative;
  z-index: 3;
}

#leftMenu + label {
  grid-template-columns: 44px 92px;
  width: 148px;
  padding: 0 8px;
}

#info:checked + label > span,
#shareToggle:checked + label > span {
  background: rgba(251, 192, 45, 0.92);
}

#info:checked + label .tool-icon,
#structureToggle:checked + label .tool-icon,
#shareToggle:checked + label .tool-icon {
  background: transparent;
  border-radius: 0;
}

#leftMenu ~ #info + label,
#leftMenu ~ #calc,
#leftMenu ~ #structureToggle + label,
#leftMenu ~ #shareToggle + label {
  visibility: hidden;
  opacity: 0;
  height: 0;
  transition: visibility 0.3s, opacity 0.3s, height 0.3s;
}

#leftMenu:checked ~ #info + label,
#leftMenu:checked ~ #calc,
#leftMenu:checked ~ #structureToggle + label,
#leftMenu:checked ~ #shareToggle + label {
  visibility: visible;
  opacity: 1;
  height: 56px;
}

nav.left #leftMenu ~ #info + label,
nav.left #leftMenu ~ #calc,
nav.left #leftMenu ~ #structureToggle + label,
nav.left #leftMenu ~ #shareToggle + label {
  visibility: visible;
  opacity: 1;
  height: 56px;
}

body.structure-viewing #leftMenu + label,
body.structure-viewing #leftMenu:checked ~ #info + label,
body.structure-viewing #leftMenu:checked ~ #calc,
body.structure-viewing #leftMenu:checked ~ #shareToggle + label {
  opacity: 0.28;
}

body.structure-viewing #leftMenu:checked ~ #structureToggle + label {
  opacity: 1;
}

body.structure-viewing nav.right > label,
body.structure-viewing nav.right > button,
body.structure-viewing nav.left > label,
body.structure-viewing nav.left > button {
  opacity: 0.24 !important;
  filter: grayscale(0.6) !important;
}

body.structure-viewing nav.left > label[for="structureToggle"] {
  opacity: 1 !important;
  filter: none !important;
}

body.structure-viewing nav.right > label::before,
body.structure-viewing nav.left > label:not([for="structureToggle"])::before {
  content: none;
}

#info:checked ~ main {
  visibility: visible;
  opacity: 1;
}

.structure-panel {
  display: none;
  width: min(220px, calc(100vw - 24px));
  margin: 0 0 8px;
  padding: 8px;
  color: var(--black);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(38, 50, 56, 0.16);
  box-sizing: border-box;
}

.structure-action {
  min-height: 40px;
  padding: 7px 10px;
  color: var(--black);
  background: rgba(238, 238, 238, 0.86);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: bold;
  line-height: 1.25;
  cursor: pointer;
}

.structure-action-primary {
  background: rgba(251, 192, 45, 0.9);
}

.structure-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.structure-message {
  min-height: 1.4em;
  margin: 0;
  color: #5c3d00;
  font-size: 0.68rem;
  line-height: 1.4;
}

.structure-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  padding: 0;
  pointer-events: none;
  box-sizing: border-box;
  animation: structureOverlayAppear 0.48s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.structure-overlay[hidden] {
  display: none;
}

.structure-viewer {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: auto;
  animation: structureViewerFloat 4.8s ease-in-out infinite;
}

.structure-viewer canvas {
  position: relative;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  filter: drop-shadow(0 28px 36px rgba(38, 50, 56, 0.28));
}

.structure-viewer-close {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 3;
  display: inline-grid;
  grid-template-columns: 22px auto;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 14px;
  color: var(--black);
  background: rgba(255, 255, 255, 0.92);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(38, 50, 56, 0.18);
  font: inherit;
  font-size: 0.84rem;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.structure-viewer-close-icon {
  width: 22px;
  height: 22px;
}

@keyframes structureOverlayAppear {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes structureViewerFloat {
  0%,
  100% {
    transform: translateY(-14px);
  }
  50% {
    transform: translateY(14px);
  }
}

@keyframes structureShadowFloat {
  0%,
  100% {
    opacity: 0.3;
    transform: translate(-50%, -50%) scale(0.88);
  }
  50% {
    opacity: 0.44;
    transform: translate(-50%, -50%) scale(1.14);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.structure-viewing::after,
  .structure-overlay,
  .structure-viewer {
    animation: none;
  }
}

@media (max-width: 640px) {
  body.structure-viewing nav.right {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
}

.share-action-icon {
  display: block;
  width: 30px;
  height: 30px;
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 50, 56, 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-sizing: border-box;
}

.share-modal[hidden] {
  display: none;
}

.share-modal-card {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  color: var(--black);
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(38, 50, 56, 0.26);
  box-sizing: border-box;
}

.share-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.share-modal-header h2,
.share-intro p,
.share-status {
  margin: 0;
}

.share-modal-header h2 {
  font-size: 1.45rem;
}

.share-modal-close {
  flex: 0 0 auto;
  min-width: 96px;
  min-height: 40px;
  padding: 0 18px;
  color: var(--black);
  background: rgba(251, 192, 45, 0.9);
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

.share-status {
  min-height: 1.45em;
  color: #5c3d00;
  font-size: 0.82rem;
  line-height: 1.45;
}

.share-intro,
.share-result {
  display: grid;
  gap: 14px;
}

.share-intro[hidden],
.share-result[hidden] {
  display: none;
}

.share-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-modal-actions-three {
  grid-template-columns: repeat(3, 1fr);
}

.share-modal-action {
  display: grid;
  grid-template-columns: 30px auto;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  min-width: 0;
  padding: 8px 12px;
  color: var(--black);
  background: rgba(238, 238, 238, 0.86);
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: bold;
  cursor: pointer;
  box-sizing: border-box;
}

.share-modal-action span:only-child {
  grid-column: 1 / -1;
}

.share-modal-action-primary {
  background: rgba(251, 192, 45, 0.9);
}

.share-modal-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.share-qr-code {
  justify-self: center;
  width: min(280px, calc(100vw - 84px));
  padding: 10px;
  background: var(--white);
  border: 1px solid rgba(38, 50, 56, 0.12);
  border-radius: 8px;
  box-sizing: border-box;
}

.share-qr-code svg {
  display: block;
  width: 100%;
  height: auto;
}

.share-url-output {
  display: block;
  width: 100%;
  padding: 10px 12px;
  color: var(--black);
  background: rgba(238, 238, 238, 0.86);
  border-radius: 8px;
  font: 0.78rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

.erase-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 50, 56, 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-sizing: border-box;
}

.erase-confirm-modal[hidden] {
  display: none;
}

.erase-confirm-card {
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  padding: 18px;
  color: var(--black);
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(38, 50, 56, 0.26);
  box-sizing: border-box;
}

.erase-confirm-card h2,
.erase-confirm-card p {
  margin: 0;
}

.erase-confirm-card h2 {
  font-size: 1.3rem;
}

.erase-confirm-card p {
  color: #607d8b;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.55;
}

.erase-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.erase-confirm-action {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--black);
  background: rgba(238, 238, 238, 0.86);
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: bold;
  cursor: pointer;
}

.erase-confirm-action-primary {
  background: rgba(251, 192, 45, 0.9);
}

nav.left main {
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 50, 56, 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.guide-modal-card {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  color: var(--black);
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(38, 50, 56, 0.26);
  box-sizing: border-box;
}

.guide-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.guide-modal-header h2 {
  margin: 0;
}

.guide-modal-header h2 {
  font-size: 1.45rem;
}

.guide-modal-close {
  flex: 0 0 auto;
  min-width: 96px;
  min-height: 40px;
  padding: 0 18px;
  color: var(--black);
  background: rgba(251, 192, 45, 0.9);
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

#guideContent {
  display: grid;
  gap: 14px;
  width: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#guideContent > :first-child {
  margin-top: 0;
}

#guideContent h3,
#guideContent p {
  margin: 0;
}

.guide-hero {
  display: grid;
  gap: 10px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(251, 192, 45, 0.16), rgba(62, 149, 186, 0.06)),
    var(--white);
  border: 1px solid rgba(38, 50, 56, 0.08);
  border-radius: 8px;
}

.guide-kicker {
  width: fit-content;
  padding: 4px 10px;
  color: #5c3d00;
  background: rgba(251, 192, 45, 0.22);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
}

.guide-hero h3 {
  font-size: clamp(1.55rem, 3.6vw, 2.2rem);
  line-height: 1.15;
}

.guide-hero p,
.guide-panel p,
.guide-panel li {
  color: #455a64;
  font-size: 0.9rem;
  line-height: 1.72;
}

.guide-atom-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.guide-atom {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--white);
  font-weight: 900;
  clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0 50%);
}

.guide-atom-h {
  width: 38px;
  height: 38px;
  color: var(--black);
  background: #f7f9fa;
  border: 2px solid #8a969c;
  border-radius: 5px;
  clip-path: none;
}

.guide-atom-c {
  background: #263238;
}

.guide-atom-n {
  background: #3e95ba;
}

.guide-atom-o {
  background: #b52e25;
}

.guide-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--white);
  border: 1px solid rgba(38, 50, 56, 0.08);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(38, 50, 56, 0.04);
}

.guide-panel-yellow {
  background: rgba(251, 192, 45, 0.08);
}

.guide-panel h3 {
  font-size: 1.08rem;
}

.guide-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: start;
  gap: 10px;
}

.guide-step-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--black);
  background: rgba(251, 192, 45, 0.9);
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 900;
}

.guide-atom-grid,
.guide-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.guide-atom-grid article,
.guide-tool-grid article {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 10px;
  width: auto;
  max-width: none;
  min-width: 0;
  max-height: none;
  margin: 0;
  padding: 12px;
  background: rgba(247, 249, 250, 0.72);
  border: 1px solid rgba(38, 50, 56, 0.08);
  border-radius: 8px;
  box-sizing: border-box;
}

.guide-atom-grid article > *,
.guide-tool-grid article > * {
  min-width: 0;
}

.guide-tool-grid article {
  align-items: start;
}

.guide-tool-grid .guide-tool-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.guide-tool-grid strong,
.guide-tool-grid p {
  grid-column: 2;
}

.guide-atom-grid strong,
.guide-tool-grid strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.94rem;
}

.guide-atom-grid small,
.guide-tool-grid p {
  display: block;
  color: #607d8b;
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.guide-tool-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #263238;
  background: rgba(251, 192, 45, 0.14);
  border-radius: 8px;
}

.guide-tool-icon svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.05;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.guide-footer {
  padding: 4px 2px 0;
  color: #78909c;
  text-align: right;
}

.calculation-modal {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 50, 56, 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-sizing: border-box;
}

.calculation-modal[hidden] {
  display: none;
}

.calculation-modal-card {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  color: var(--black);
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(38, 50, 56, 0.26);
  box-sizing: border-box;
}

.calculation-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.calculation-modal-header h2,
.calculation-modal-description {
  margin: 0;
}

.calculation-modal-description {
  max-width: 520px;
  margin-top: 6px;
  color: #607d8b;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.55;
}

.calculation-modal-header h2 {
  font-size: 1.45rem;
}

.calculation-modal-close {
  flex: 0 0 auto;
  min-width: 96px;
  min-height: 40px;
  padding: 0 18px;
  color: var(--black);
  background: rgba(251, 192, 45, 0.9);
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

.calculation-modal-content {
  display: grid;
  gap: 14px;
}

.calculation-section {
  display: grid;
  gap: 8px;
}

.calculation-section h3 {
  margin: 0;
  font-size: 1rem;
}

.calculation-section table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid rgba(38, 50, 56, 0.14);
  border-radius: 8px;
}

.calculation-section tr + tr {
  border-top: 1px solid rgba(38, 50, 56, 0.1);
}

.calculation-section th,
.calculation-section td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.calculation-section th {
  width: 42%;
  background: rgba(251, 192, 45, 0.14);
}

.calculation-section th span,
.calculation-section th small {
  display: block;
}

.calculation-section th span {
  font-weight: bold;
}

.calculation-section th small {
  margin-top: 3px;
  color: #607d8b;
  font-size: 0.74rem;
  line-height: 1.35;
}

.calculation-section td {
  text-align: left;
  vertical-align: middle;
  font-weight: bold;
  overflow-wrap: anywhere;
}

.calculation-code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-all;
}

.calculation-message,
.calculation-note {
  margin: 0;
  padding: 12px 14px;
  line-height: 1.65;
  background: rgba(69, 150, 186, 0.1);
  border-radius: 8px;
}

.calculation-note {
  color: #455a64;
  font-size: 0.86rem;
}

.share-modal-card,
.guide-modal-card,
.erase-confirm-card,
.calculation-modal-card {
  background:
    linear-gradient(135deg, rgba(251, 192, 45, 0.06), rgba(62, 149, 186, 0.025) 42%, rgba(255, 255, 255, 0) 72%),
    var(--white);
  border: 1px solid rgba(38, 50, 56, 0.08);
}

.share-intro > p,
.share-status:not(:empty),
.erase-confirm-card p,
.calculation-modal-description {
  padding: 10px 12px;
  color: #455a64;
  background: rgba(251, 192, 45, 0.08);
  border-radius: 8px;
}

.share-modal-action,
.erase-confirm-action {
  background: rgba(247, 249, 250, 0.78);
  border: 1px solid rgba(38, 50, 56, 0.08);
}

.share-modal-action-primary,
.erase-confirm-action-primary {
  background: rgba(251, 192, 45, 0.9);
  border-color: rgba(251, 192, 45, 0.52);
}

.calculation-section {
  padding: 12px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(38, 50, 56, 0.08);
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(38, 50, 56, 0.04);
}

#calc,
#erase {
  color: var(--black);
  background: transparent;
}

#erase > span {
  color: #8f211b;
}

#erase .tool-icon {
  color: #b52e25;
}

@media (max-width: 560px) {
  nav.right {
    position: fixed;
    top: auto;
    right: auto;
    bottom: 0;
    left: 0;
    width: 390px;
    max-width: 100vw;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-flow: row;
    align-items: end;
    gap: 2px;
    padding: 5px 8px 7px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 10px 28px rgba(38, 50, 56, 0.14);
    box-sizing: border-box;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  nav.right label,
  nav.right #erase,
  nav.right #settle {
    grid-template-columns: 1fr;
    grid-template-rows: 40px;
    justify-items: center;
    width: auto;
    min-width: 0;
    height: 46px;
    padding: 3px 0;
  }

  #buildOption:checked ~ #cutMode:checked ~ #erase {
    position: relative;
    top: auto;
    right: auto;
    height: 46px;
  }

  nav.right input:checked + label::before {
    top: auto;
    bottom: 1px;
    left: 50%;
    width: 24px;
    height: 3px;
    transform: translateX(-50%);
  }

  body.move-mode nav.right label[for="buildOption"]::before {
    top: auto;
    bottom: 1px;
    left: 50%;
    width: 24px;
    height: 3px;
    transform: translateX(-50%);
  }

  nav.right label > span,
  nav.right #erase > span,
  nav.right #settle > span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  nav.right .tool-icon,
  nav.right .atom-icon {
    grid-column: 1;
    grid-row: 1;
    width: 38px;
    height: 38px;
  }

  nav.left {
    top: 8px;
    left: 8px;
  }

  nav.left label,
  nav.left #calc {
    grid-template-columns: 44px;
    width: 60px;
    padding: 0 8px;
  }

  nav.left label > span,
  nav.left #calc > span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  nav.left .tool-icon {
    grid-column: 1;
  }

  nav.left .menu-toggle {
    display: grid;
  }

  nav.left #leftMenu ~ #info + label,
  nav.left #leftMenu ~ #calc,
  nav.left #leftMenu ~ #structureToggle + label,
  nav.left #leftMenu ~ #shareToggle + label {
    visibility: hidden;
    opacity: 0;
    height: 0;
  }

  nav.left #leftMenu:checked ~ #info + label,
  nav.left #leftMenu:checked ~ #calc,
  nav.left #leftMenu:checked ~ #structureToggle + label,
  nav.left #leftMenu:checked ~ #shareToggle + label {
    visibility: visible;
    opacity: 1;
    height: 56px;
  }

  nav.left main {
    align-items: stretch;
    padding: 12px;
  }

  .structure-viewer-close {
    top: 12px;
    min-height: 40px;
    padding: 8px 13px;
  }

  .guide-modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 14px;
  }

  .guide-modal-header {
    align-items: flex-start;
  }

  #guideContent {
    padding: 0;
  }

  .guide-hero,
  .guide-panel {
    padding: 13px;
  }

  .guide-atom-grid,
  .guide-tool-grid {
    grid-template-columns: 1fr;
  }

  .guide-atom-grid article,
  .guide-tool-grid article {
    grid-template-columns: 44px 1fr;
  }

  .share-modal {
    align-items: stretch;
    padding: 12px;
  }

  .share-modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 14px;
  }

  .share-modal-header {
    align-items: flex-start;
  }

  .share-modal-actions,
  .share-modal-actions-three {
    grid-template-columns: 1fr;
  }

  .calculation-modal {
    align-items: stretch;
    padding: 12px;
  }

  .calculation-modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 14px;
  }

  .calculation-modal-header {
    align-items: flex-start;
  }

  .calculation-section table,
  .calculation-section tbody,
  .calculation-section tr,
  .calculation-section th,
  .calculation-section td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .calculation-section td {
    padding-top: 6px;
  }
}
