:root {
  --bg: #fff8ef;
  --panel: #ffffff;
  --panel-soft: #fff3dc;
  --ink: #1f2328;
  --muted: #606975;
  --line: #d8dee4;
  --accent: #f59e0b;
  --accent-strong: #b45309;
  --accent-2: #2563eb;
  --canvas-bg: #fffdf8;
  --shadow: 0 10px 28px rgba(31, 35, 40, 0.10);
}

[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #171b22;
  --panel-soft: #23202a;
  --ink: #e6edf3;
  --muted: #a2acb8;
  --line: #303640;
  --accent: #f59e0b;
  --accent-strong: #fbbf24;
  --accent-2: #60a5fa;
  --canvas-bg: #101318;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

.topbar,
.toolbar,
.starter-panel,
.quick-box-panel,
.help-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.brand small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-top: 2px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
}

button:hover,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

button.active {
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  border-color: var(--accent);
  color: var(--accent-strong);
}

button.active-toggle {
  background: color-mix(in srgb, var(--accent-2) 16%, var(--panel));
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.soft-btn {
  background: var(--panel-soft);
}

.starter-panel {
  justify-content: space-between;
  background: linear-gradient(90deg, var(--panel-soft), var(--panel));
  font-size: 14px;
}


.quick-box-panel {
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.quick-box-copy {
  display: grid;
  gap: 2px;
  min-width: 240px;
  flex: 1 1 320px;
}

.quick-box-copy span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.quick-box-copy code {
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent-strong);
}

#quickBoxInput {
  flex: 1 1 260px;
  min-width: 220px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
}

.help-panel {
  align-items: stretch;
  background: var(--bg);
}

.help-card {
  flex: 1 1 180px;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.help-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.toolbar {
  gap: 8px;
}

.toolbar-separator {
  width: 1px;
  height: 34px;
  background: var(--line);
  margin: 0 4px;
}

.status {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.board-shell {
  position: relative;
  overflow: hidden;
  min-height: 420px;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--canvas-bg);
  cursor: crosshair;
}

.hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(760px, calc(100% - 24px));
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.color-label,
.range-label,
.select-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
}

.color-label input[type="color"] {
  width: 30px;
  height: 30px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.range-label input[type="range"] {
  width: 96px;
}

.select-label select {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 6px 8px;
}

.props-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 260px;
  z-index: 5;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-radius: 18px;
  padding: 14px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.props-title {
  font-weight: 900;
  font-size: 16px;
  margin-bottom: 4px;
}

.props-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.prop-row {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.prop-row input,
.prop-row textarea,
.prop-row select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px;
}

.prop-row input[type="color"] {
  height: 38px;
  padding: 2px;
}

.prop-row input:disabled,
.prop-row textarea:disabled,
.prop-row select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .app {
    height: auto;
    min-height: 100vh;
  }

  .props-panel {
    position: static;
    width: auto;
    margin: 10px;
  }

  .board-shell {
    display: flex;
    flex-direction: column;
    min-height: 580px;
  }

  #board {
    min-height: 440px;
  }

  .hint {
    position: static;
    margin: 10px;
  }

  .toolbar-separator {
    display: none;
  }
}

:fullscreen .board-shell,
:fullscreen canvas {
  width: 100vw;
  height: 100vh;
}

/* Ultra-simple mode: only two creation options are visible. */
.simple-app {
  grid-template-rows: auto auto auto 1fr;
}

.creator-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
}

.creator-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.creator-title {
  font-size: 18px;
  font-weight: 950;
}

.creator-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
}

.creator-card code {
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--accent-strong);
}

.creator-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 18px;
  font-weight: 900;
}

.creator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.creator-actions button:first-child {
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  border-color: var(--accent);
  color: var(--accent-strong);
}

.mini-help {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.mini-help strong {
  color: var(--ink);
}

@media (max-width: 850px) {
  .creator-panel {
    grid-template-columns: 1fr;
  }
}


.edit-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

#editTextInput:disabled,
#editSelectedTextBtn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.inline-text-editor {
  position: absolute;
  z-index: 20;
  border: 2px solid var(--accent-2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  text-align: center;
  font-weight: 900;
  padding: 4px 8px;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.20);
}

[data-theme="dark"] .inline-text-editor {
  background: rgba(23, 27, 34, 0.96);
}
