:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #d9e0ea;
  --line-strong: #b9c4d3;
  --ink: #18212f;
  --muted: #65758b;
  --accent: #0f9fbd;
  --accent-strong: #087d94;
  --accent-soft: #dff7fb;
  --danger: #c73e5b;
  --danger-soft: #ffe9ee;
  --focus: #f59e0b;
  --shadow: 0 12px 28px rgba(24, 33, 47, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.command {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
label.command:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  height: 100vh;
  min-height: 560px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(24, 33, 47, 0.03);
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: max-content;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #0f9fbd, #41a66b);
  border-radius: 8px;
  font-weight: 900;
}

.command-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.command,
.mini-button,
.action-grid button,
.wide-button,
.emoji-grid button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 100ms ease;
}

.command {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  font-weight: 700;
  white-space: nowrap;
}

.command svg,
.mini-button svg,
.tool-button svg,
.drawing-menu svg,
.action-grid svg,
.wide-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex: 0 0 auto;
}

.command:hover,
.mini-button:hover,
.action-grid button:hover,
.wide-button:hover,
.tool-button:hover,
.emoji-grid button:hover {
  background: #f0fbfd;
  border-color: #93dbea;
}

.command:active,
.mini-button:active,
.action-grid button:active,
.wide-button:active,
.tool-button:active,
.emoji-grid button:active {
  transform: translateY(1px);
}

.command-strong {
  border-color: #74c7d7;
  background: var(--accent-soft);
  color: #075a6d;
}

.icon-only {
  width: 38px;
  padding: 0;
}

.divider {
  width: 1px;
  height: 30px;
  background: var(--line);
  margin: 0 2px;
}

.hidden-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(250px, 280px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "canvas canvas"
    "tools props";
}

.toolbox {
  grid-area: tools;
  display: flex;
  flex-direction: row;
  align-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: #eef3f8;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.tool-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: #233143;
  border-radius: 8px;
  cursor: pointer;
}

.tool-button.is-active {
  background: #dff7fb;
  border-color: var(--accent);
  color: #056174;
  box-shadow: inset 0 0 0 1px rgba(15, 159, 189, 0.18);
}

.tool-separator {
  width: 1px;
  height: 42px;
  background: var(--line-strong);
  margin: 0 3px;
}

.drawing-menu {
  flex: 1 1 100%;
  min-width: 190px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #233143;
}

.drawing-menu:focus-within,
.drawing-menu:hover {
  border-color: #93dbea;
  background: #f0fbfd;
}

.drawing-menu select {
  min-width: 0;
  flex: 1 1 auto;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 760;
  cursor: pointer;
}

.canvas-area {
  grid-area: canvas;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(45deg, #e8eef5 25%, transparent 25%),
    linear-gradient(-45deg, #e8eef5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8eef5 75%),
    linear-gradient(-45deg, transparent 75%, #e8eef5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.canvas-toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 2;
}

.zoom-group,
.canvas-size,
.pdf-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mini-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.canvas-size input {
  width: 84px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
  background: var(--surface);
}

#zoomRange {
  width: 170px;
}

output {
  min-width: 46px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.stage-wrap {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 28px;
  position: relative;
}

.stage {
  position: relative;
  width: 1280px;
  height: 800px;
  background: #ffffff;
  box-shadow: var(--shadow);
  transform-origin: 0 0;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

#overlayCanvas {
  cursor: crosshair;
  touch-action: none;
}

.text-editor {
  position: absolute;
  z-index: 4;
  min-width: 150px;
  min-height: 42px;
  padding: 4px 6px;
  resize: both;
  border: 1px dashed var(--accent);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(24, 33, 47, 0.16);
}

.statusbar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.statusbar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legal-links {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 750;
}

.legal-links a {
  color: #3f5f72;
  text-decoration: none;
  white-space: nowrap;
}

.legal-links a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.properties {
  grid-area: props;
  min-height: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(190px, 1fr);
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px;
  background: #f9fbfd;
  border-top: 1px solid var(--line);
}

.panel {
  min-width: 190px;
  padding: 0;
  border-bottom: 0;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #405066;
}

.color-picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.color-picks label,
.select-row {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.color-picks input {
  width: 100%;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(7, minmax(24px, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.swatch {
  aspect-ratio: 1;
  min-height: 28px;
  border: 1px solid rgba(24, 33, 47, 0.18);
  border-radius: 7px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.swatch.is-primary {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--accent);
}

.rgb-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.rgb-row label {
  min-width: 0;
  min-height: 34px;
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #405066;
  font-size: 0.78rem;
  font-weight: 800;
}

.rgb-row input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
  text-align: right;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 8px;
}

.emoji-grid button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.emoji-grid button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 159, 189, 0.18);
}

.range-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  color: var(--muted);
  font-size: 0.9rem;
}

.range-row input {
  min-width: 0;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.toggle-grid label {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #344257;
}

.select-row {
  margin-bottom: 10px;
}

.select-row select,
.pdf-controls select {
  min-height: 34px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 8px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-grid button,
.wide-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 9px;
  font-weight: 700;
}

.action-grid button span,
.wide-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-grid button.danger,
.wide-button.danger {
  color: var(--danger);
  border-color: #f0b7c3;
  background: var(--danger-soft);
}

.pdf-controls {
  margin-bottom: 10px;
}

.pdf-controls select {
  flex: 1 1 auto;
}

.wide-button {
  width: 100%;
  background: #f6fff8;
  border-color: #b9dfc3;
  color: #206738;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  max-width: min(460px, calc(100vw - 28px));
  padding: 11px 14px;
  background: #172033;
  color: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "canvas"
      "tools"
      "props";
  }

  .toolbox {
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: visible;
    border-right: 0;
  }

  .properties {
    grid-auto-columns: minmax(190px, 1fr);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    min-height: 760px;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(520px, 1fr) auto auto;
  }

  .tool-separator {
    width: 1px;
    height: 30px;
  }

  .canvas-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .zoom-group,
  .canvas-size {
    width: 100%;
    justify-content: space-between;
  }

  #zoomRange {
    width: min(180px, 42vw);
  }

  .stage-wrap {
    padding: 16px;
  }

  .properties {
    grid-auto-columns: minmax(210px, 1fr);
  }

  .statusbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .legal-links {
    justify-content: flex-start;
    margin-left: 0;
  }
}

/* Open Design draft: colorful creative workstation for ages 7-10. */
:root {
  --bg: #fff7fd;
  --surface: #ffffff;
  --line: #e7d8f1;
  --line-strong: #cab7da;
  --ink: #241833;
  --muted: #6b5f7a;
  --accent: #ff5fa2;
  --accent-strong: #d9367e;
  --accent-soft: #fff0f8;
  --violet: #7c5cff;
  --cyan: #1db9e8;
  --lime: #68cf72;
  --yellow: #ffd85f;
  --danger: #d83f68;
  --danger-soft: #fff0f4;
  --focus: #ffd85f;
}

body {
  background:
    linear-gradient(90deg, rgba(124, 92, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(29, 185, 232, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #fff7fd 0%, #f4fbff 52%, #fffbea 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

.topbar {
  border-bottom: 2px solid rgba(36, 24, 51, 0.13);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-size: 1.02rem;
}

.brand-mark {
  color: var(--ink);
  background:
    linear-gradient(135deg, var(--yellow) 0 48%, var(--accent) 49% 100%);
  box-shadow: 3px 3px 0 rgba(36, 24, 51, 0.2);
}

.command,
.mini-button,
.action-grid button,
.wide-button,
.emoji-grid button,
.tool-button,
.drawing-menu,
.select-row,
.range-row,
.color-picks label,
.rgb-row label,
.pdf-controls {
  border-width: 2px;
  border-color: rgba(36, 24, 51, 0.12);
  border-radius: 8px;
}

.command {
  box-shadow: 2px 2px 0 rgba(36, 24, 51, 0.1);
}

.command-strong {
  border-color: var(--violet);
  background: #f2efff;
  color: #543db5;
}

.workspace {
  background:
    linear-gradient(135deg, rgba(255, 95, 162, 0.09), transparent 34%),
    linear-gradient(315deg, rgba(104, 207, 114, 0.12), transparent 34%);
}

.toolbox {
  background: rgba(255, 244, 251, 0.94);
}

.tool-button {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 2px 2px 0 rgba(36, 24, 51, 0.12);
}

.tool-button.is-active {
  color: #6e2450;
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 162, 0.18), 2px 2px 0 rgba(36, 24, 51, 0.16);
}

.canvas-area {
  background:
    linear-gradient(90deg, rgba(36, 24, 51, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 24, 51, 0.05) 1px, transparent 1px),
    #fbf7ff;
  background-size: 26px 26px;
}

.stage {
  border: 2px solid rgba(36, 24, 51, 0.2);
  box-shadow: 0 18px 38px rgba(36, 24, 51, 0.16), 8px 8px 0 rgba(255, 216, 95, 0.9);
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  z-index: 4;
  width: 76px;
  height: 20px;
  background: rgba(255, 216, 95, 0.72);
  border: 2px solid rgba(36, 24, 51, 0.12);
  border-radius: 4px;
  pointer-events: none;
}

.stage::before {
  left: 18px;
  top: -12px;
  transform: rotate(-5deg);
}

.stage::after {
  right: 18px;
  top: -12px;
  transform: rotate(5deg);
}

.properties {
  background: rgba(255, 255, 255, 0.82);
}

.panel h2 {
  color: #6f3c83;
}

.swatch {
  border-width: 2px;
  border-radius: 8px;
}

.swatch.is-active {
  border-color: var(--accent);
}

.wide-button {
  background: #edffe9;
  border-color: var(--lime);
  color: #246833;
}

.properties {
  grid-auto-flow: row;
  grid-auto-columns: initial;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow-x: hidden;
  overflow-y: auto;
}

.panel {
  min-width: 0;
}

@media (max-width: 1280px) {
  .properties {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 292px;
  }

  .emoji-grid {
    grid-template-columns: repeat(6, minmax(30px, 1fr));
  }
}

@media (max-width: 760px) {
  .properties {
    grid-template-columns: 1fr;
    max-height: none;
  }
}

/* Open Design v2 polish: clearer workstation hierarchy. */
.topbar {
  min-height: 62px;
}

.brand {
  padding-right: 4px;
}

.command-bar {
  padding: 4px;
  border: 2px solid rgba(36, 24, 51, 0.08);
  border-radius: 8px;
  background: rgba(255, 247, 253, 0.72);
}

.command,
.mini-button {
  min-height: 40px;
}

.command:hover,
.mini-button:hover,
.tool-button:hover,
.action-grid button:hover,
.wide-button:hover,
.emoji-grid button:hover {
  background: #fff0f8;
  border-color: var(--accent);
}

.canvas-toolbar {
  min-height: 58px;
  border-bottom: 2px solid rgba(36, 24, 51, 0.08);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(10px);
}

.zoom-group,
.canvas-size {
  padding: 5px;
  border: 2px solid rgba(36, 24, 51, 0.08);
  border-radius: 8px;
  background: #ffffff;
}

.canvas-size input {
  font-weight: 850;
}

.stage-wrap {
  background:
    linear-gradient(90deg, rgba(255, 95, 162, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(124, 92, 255, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
}

.statusbar {
  border-top: 2px solid rgba(36, 24, 51, 0.08);
  background: rgba(255, 255, 255, 0.88);
}

.toolbox {
  gap: 9px;
  border-top: 2px solid rgba(36, 24, 51, 0.1);
}

.tool-button {
  width: 46px;
  height: 46px;
}

.tool-button.is-active {
  transform: translateY(-2px);
}

.drawing-menu {
  min-height: 46px;
  background: #ffffff;
}

.properties {
  gap: 12px;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(255, 216, 95, 0.1) 1px, transparent 1px),
    rgba(255, 255, 255, 0.78);
  background-size: 28px 28px;
}

.panel {
  padding: 12px;
  border: 2px solid rgba(36, 24, 51, 0.1);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 3px 3px 0 rgba(36, 24, 51, 0.1);
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel h2::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.panel:nth-child(2) h2::before {
  background: var(--violet);
}

.panel:nth-child(3) h2::before {
  background: var(--yellow);
}

.panel:nth-child(4) h2::before {
  background: var(--lime);
}

.panel:nth-child(5) h2::before {
  background: var(--cyan);
}

.swatch,
.emoji-grid button,
.action-grid button,
.wide-button {
  box-shadow: 2px 2px 0 rgba(36, 24, 51, 0.08);
}

.range-row input {
  accent-color: var(--violet);
}

@media (max-width: 1280px) {
  .properties {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 332px;
  }
}

@media (max-width: 760px) {
  .properties {
    grid-template-columns: 1fr;
    max-height: none;
    overflow-x: hidden;
  }

  .emoji-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .emoji-grid button {
    width: auto;
    min-width: 0;
  }
}
