* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #151515;
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

button, label {
  font: inherit;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  background: #2f7df6;
  color: white;
  font-weight: 700;
}

button.secondary {
  background: #444;
}

button.danger {
  background: #d64545;
}

button:disabled {
  background: #555;
  color: #999;
}

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100%;
}

#topBar {
  min-height: 54px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  background: rgba(0,0,0,0.78);
  z-index: 2;
}

#leftPanel {
  justify-self: start;
}

#centerTitle {
  justify-self: center;
  font-weight: 800;
  opacity: .95;
}

#rightPanel {
  justify-self: end;
  text-align: right;
  font-weight: 800;
}

#rightPanel.warn {
  color: #ff5b5b;
}

.checkLabel {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: rgba(255,255,255,.08);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 800;
}

#stageWrap {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(45deg, #222 25%, transparent 25%),
    linear-gradient(-45deg, #222 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #222 75%),
    linear-gradient(-45deg, transparent 75%, #222 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0px;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#bottomBar {
  min-height: 66px;
  padding: 10px 10px calc(env(safe-area-inset-bottom) + 10px);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  background: rgba(0,0,0,0.78);
  z-index: 2;
}

#newWorkBtn {
  margin-right: auto;
  flex-shrink: 0;
}

#bottomBar .stack {
  width: 100%;
  display: grid;
  gap: 10px;
}

#bottomBar .copyGrid {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0,0,0,.62);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modalBox {
  width: min(420px, 100%);
  background: #242424;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 12px 36px rgba(0,0,0,.4);
}

#modalText {
  white-space: pre-line;
  line-height: 1.7;
  font-weight: 700;
}

.modalActions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#bottomBar .copyGrid button {
  padding-top: 9px;
  padding-bottom: 9px;
}
