:root {
  --frame: #6a1b9a;
  --frame-dark: #263238;
  --panel: #fff176;
  --panel-soft: #f0fff0;
  --accent: #ff7a00;
  --selected: #ff00c8;
  --workspace-bg-1: #e8f5ff;
  --workspace-bg-2: #fff6de;
  --text: #1b1f2a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-width: 980px;
  overflow: hidden;
  color: var(--text);
  font-family: "Comic Sans MS", "Trebuchet MS", Arial, sans-serif;
  background: #101820;
}

button,
select,
input {
  font-family: inherit;
}

button {
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 800;
  color: #252233;
  background: linear-gradient(180deg, #ffffff, #ffe3a3);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.75);
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.7);
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100vw;
  height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 8px 12px 8px 18px;
  background: linear-gradient(90deg, #6a1b9a, #8e24aa 40%, #d81b60);
  border-bottom: 4px solid rgba(255, 255, 255, 0.16);
}

.title {
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}

.mode-switcher {
  display: flex;
  gap: 10px;
}

.mode-button {
  min-width: 150px;
  padding: 13px 18px;
  font-size: 20px;
}

.mode-button.active {
  outline: 4px solid #00e5ff;
  background: linear-gradient(180deg, #fffd99, #ffb74d);
}

.main-area {
  display: grid;
  grid-template-columns: 1fr 390px;
  min-height: 0;
  background: #fff;
}

.main-area.panel-hidden {
  grid-template-columns: 1fr 0;
}

.workspace-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.9), transparent 18%),
    radial-gradient(circle at 85% 20%, rgba(255, 244, 160, 0.95), transparent 16%),
    linear-gradient(135deg, var(--workspace-bg-1), var(--workspace-bg-2));
}

.workspace {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.design-panel {
  min-width: 390px;
  height: 100%;
  overflow: auto;
  background: var(--panel);
  border-left: 4px solid var(--frame);
  transform: translateX(0);
  transition: transform 0.32s ease, opacity 0.32s ease;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.16);
}

.main-area.panel-hidden .design-panel {
  transform: translateX(420px);
  opacity: 0;
  pointer-events: none;
}

.panel-actions {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  gap: 9px;
  padding: 16px 18px 12px;
  background: var(--panel);
  border-bottom: 3px solid var(--accent);
}

.panel-actions button {
  width: 100%;
  padding: 13px 14px;
  font-size: 20px;
  text-align: left;
}

.property-panel {
  min-height: calc(100% - 260px);
  padding: 16px 18px 26px;
  background: var(--panel-soft);
}

.property-panel h2,
.property-panel h3 {
  margin: 0 0 12px;
  color: #4a148c;
  text-align: center;
}

.property-section {
  margin: 14px 0;
  padding: 14px;
  border: 3px dashed rgba(106, 27, 154, 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.65);
}

.property-label {
  display: block;
  margin: 8px 0 7px;
  font-size: 17px;
  font-weight: 800;
  color: #3a2255;
}

.segmented,
.shape-grid,
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button,
.shape-grid button {
  padding: 9px 11px;
  font-size: 16px;
  background: #fff;
}

.segmented button.selected,
.shape-grid button.selected {
  outline: 4px solid #00bcd4;
  background: #fff59d;
}

.shape-option {
  width: calc(50% - 4px);
  min-height: 72px;
}

.shape-option svg {
  display: block;
  width: 48px;
  height: 38px;
  margin: 0 auto 3px;
}

.color-swatch {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 3px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.color-swatch.selected {
  outline: 4px solid #00bcd4;
  outline-offset: 2px;
}

.hint {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.35;
  color: #455a64;
}

.element {
  position: absolute;
  z-index: 20;
}

.button-element {
  width: 130px;
  height: 90px;
}

.button-element svg {
  position: absolute;
  inset: 0;
  width: 130px;
  height: 90px;
  filter: drop-shadow(0 7px 0 rgba(0, 0, 0, 0.18));
}

.button-element .button-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.4);
}

.display-element {
  min-width: 200px;
  height: 130px;
  padding: 12px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-width: 5px;
  border-style: solid;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.16);
}

.display-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 6px;
  width: 100%;
  line-height: 1.05;
}

.placeholder {
  font-size: 40px;
  font-weight: 700;
}

.token {
  display: inline-block;
  margin: 0 2px;
  font-weight: 800;
  transform-origin: center;
}

.selected-element {
  filter: drop-shadow(0 0 16px var(--selected)) drop-shadow(8px 10px 0 rgba(255, 0, 200, 0.3));
}

.mode-debug .button-element svg,
.mode-debug .display-element {
  opacity: 0.88;
}

.mode-design .element {
  cursor: grab;
}

.mode-design .element:active {
  cursor: grabbing;
}

.mode-release .button-element {
  cursor: pointer;
}

.mode-release .button-element:hover {
  transform: translateY(-2px) scale(1.02);
}

.bug {
  position: absolute;
  display: grid;
  place-items: center;
  line-height: 1;
  user-select: none;
  transform-origin: center;
  z-index: 30;
}

.mode-debug .bug {
  cursor: crosshair;
  filter: drop-shadow(0 0 16px red) drop-shadow(0 0 24px rgba(255, 255, 255, 0.75));
}

.mode-design .bug.hidden-bug,
.mode-release .bug.hidden-bug {
  opacity: 0.35;
}

.mode-design .bug:not(.hidden-bug),
.mode-release .bug:not(.hidden-bug) {
  opacity: 0.75;
}

.magnifier {
  position: absolute;
  width: 190px;
  height: 190px;
  border: 6px solid #00e5ff;
  border-radius: 50%;
  overflow: hidden;
  display: none;
  pointer-events: none;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 26px rgba(255, 255, 255, 0.9), 0 12px 32px rgba(0, 0, 0, 0.25);
}

.magnifier.visible {
  display: block;
}

.magnifier-content {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

@keyframes wiggle {
  from { transform: rotate(-10deg); }
  to { transform: rotate(10deg); }
}

@keyframes blink {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

@keyframes jump {
  from { transform: translateY(-5px); }
  to { transform: translateY(5px); }
}

@keyframes rotate-token {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.effect-wiggle { animation: wiggle 140ms infinite alternate; }
.effect-blink { animation: blink 180ms infinite alternate; }
.effect-jump { animation: jump 120ms infinite alternate; }
.effect-rotate { animation: rotate-token 700ms infinite linear; }
.effect-wrong-color { color: deeppink !important; }

.statusbar {
  padding: 10px 15px;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  background: var(--frame-dark);
  border-top: 4px solid rgba(255, 255, 255, 0.12);
}

.small-note {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 235, 59, 0.45);
  font-size: 15px;
  line-height: 1.35;
}
