:root {
  --bg: #f5f6f7;
  --ink: #2b2f33;
  --border: #d6dbdf;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, #ffffff 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

.shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(14, 16, 19, 0.93), rgba(27, 30, 35, 0.95));
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 180ms ease;
}

.loading-overlay.hidden {
  opacity: 0;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f5f6f7;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.viewport-shell {
  flex: 1;
  min-height: 0;
  padding: 0;
}

.viewport-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  border: none;
  border-radius: 0;
  background: #111;
}

.display {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  transform-origin: top left;
}

.display canvas {
  display: block;
}

.toolbar {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 8px;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.toolbar-spacer {
  min-width: 1px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--ink);
}

.soft-input {
  position: fixed;
  left: 2px;
  top: 2px;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  border: 0;
  padding: 0;
  pointer-events: auto;
}

@media (max-width: 520px) {
  .toolbar {
    grid-template-columns: auto auto auto 1fr;
  }
}
