:root {
  --color-bg: #f7f9fc;
  --color-canvas: #e9ecef;
  --color-dropzone-fill: #dbdee1;
  --color-info-fill: #f0f1f1;
  --color-panel: #ffffff;
  --color-sections: #f0f2f5;
  --color-primary: #2e7d32;
  --color-danger: #c62828;
  --color-primary-hover: #2e7d00;
  --color-danger-hover: #c62800;
  --color-section-debug-experimental: #c6f8e7;
  --color-debug-btn: #fcb270;
  --color-debug-text: #212121;
  --color-tab-symbol: #1976d2;
  --color-return-symbol: #6a1b9a;
  --color-version-text: #616161;
  --color-toolbox-item: #eef2f7;
  --color-border-black: #736b6b;
  --color-internal-text-btn: #fff;
  --color-border-light: #ccc;
  --color-black: #212121;
  --color-grey: #616161;
  --color-block-text: #212121;
  --color-instruction-text: #212121;
  --color-garbage-background: #ffecec;
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.58);
  --radius: 6px;
  --side-w: 300px;
  --font: 'Roboto', sans-serif;
  --header-height: 45px;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.page-header {
  height: auto;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border-light);
  padding: 5px;
  display: flex;
  flex-direction: column; /* stack title + version vertically */
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.page-header .title {
  font-size: 24px;
  font-weight: bold;
}

.page-header .version {
  font-size: 12px;
  color: var(--color-version-text);
  margin-top: 4px;
}

.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.panel {
  width: var(--side-w);
  background: var(--color-panel);
  padding: 10px;
  box-shadow: var(--shadow-soft);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.toolbox { border-right: 1px solid var(--color-border-black); }
.garbage { border-left: 1px solid var(--color-border-black); }

.section {
  background: var(--color-sections);
  padding: 10px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section h3 {
  font-size: 15px;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 3px solid #dde;
  text-align: center;
}

.toolbox-item {
  background: var(--color-toolbox-item);
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border-black);
  text-align: center;
  cursor: grab;
  user-select: none;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 1px 3px rgba(0,0,0,0.58);
}

/* Toolbox-specific coloring */
.toolbox-item.text { color: var(--color-block-text); }
.toolbox-item.tab { color: var(--color-tab-symbol); }
.toolbox-item.return { color: var(--color-return-symbol); }

/* Canvas-specific coloring */
.block.text { color: var(--color-block-text); }
.block.tab { color: var(--color-tab-symbol); }
.block.return { color: var(--color-return-symbol); }

.btn {
  padding: 10px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  color: var(--color-internal-text-btn);
  box-shadow: var(--shadow-soft);
}

.btn-primary { background: var(--color-primary); box-shadow: var(--shadow-soft); }
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-soft); }
.btn-danger { background: var(--color-danger); box-shadow: var(--shadow-soft); }
.btn-danger:hover { background: var(--color-danger-hover); box-shadow: var(--shadow-soft); }
.btn-blue { background: var(--color-tab-symbol); box-shadow: var(--shadow-soft); }
.btn-purple { background: var(--color-return-symbol); box-shadow: var(--shadow-soft); }

select, .btn, .checkbox-container {
  width: 100%;
}

.checkbox-container {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 14px;
  gap: 6px;
}

.canvas-header {
  font-weight: bold;
  font-size: 16px;
  padding: 6px 0;
  text-align: center;
  width: 100%;
  border-bottom: 1px solid #ccc;
}

.canvas-info-group {
  text-align: center;
  margin-top: 9px;
  margin-bottom: 9px;
  padding: 6px 0;
  width: 90%;
  font-size: 12px;
  line-height: 1.4;
  color: var(--color-shadow-soft);
  background: var(--color-info-fill);
  box-shadow: var(--shadow-soft);
}
.canvas-info {
  margin: 2px 0;
}

.canvas-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.canvas {
  flex: 1;
  background: var(--color-canvas);
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-left: 1px solid var(--color-border-black);
  border-right: 1px solid var(--color-border-black);
}

.block {
  width: 90%;
  background: var(--color-panel);
  padding: 10px;
  border: 0.5px solid var(--color-black);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  min-height: 10px;
  font-weight: bold;
  cursor: grab;
  user-select: none;
}

.iterations {
  font-size: 0.7em;
  vertical-align: super;
  margin-left: 4px;
}

.dropzone {
  width: 90%;
  height: 16px;
  min-height: 12px;
  border: 1px dashed var(--color-black);
  border-radius: 50px;
  position: relative;
  background-color: var(--color-dropzone-fill);
  transition: background 0.2s ease-in-out;
}

.dropzone::before {
  content: "Drop here";
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  color: var(--color-grey);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dropzone.drag-hover {
  background-color: rgba(0, 0, 0, 0.2);
}

.dropzone.drag-hover::before {
  opacity: 1;
}

.qr-preview {
  background: var(--color-panel);
  border: 1px solid var(--color-black);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.qr-preview:empty::before {
  content: 'Click "Build QR" to Create Your QR';
  color: var(--color-grey);
  font-size: 14px;
  text-align: center;
  white-space: pre-wrap;
}

.qr-preview canvas {
  width: 75px;
  height: 75px;
  box-shadow: var(--shadow-soft);
}

.panel.right {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.right-footer {
  margin-top: auto;
  padding: 10px;
  text-align: center;
  font-size: 14px;
}

.garbage-drop {
  height: 100px;
  border: 2px dashed var(--color-danger);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  background: var(--color-garbage-background);
  display: flex;
  align-items: center;
  padding: 1px;
  justify-content: center;
  color: var(--color-danger);
  font-weight: bold;
  font-size: 20px;
}

.btn-debug {
  background: var(--color-debug-btn);
  box-shadow: var(--shadow-soft);
  color: var(--color-debug-text);
  font-size: 12px;
  }

.form-grid {
  display: grid;
  grid-template-columns: 140px 1fr;  /* same fixed label width + fluid input */
  column-gap: 20px;
  row-gap: 8px;
  width: 90%;
  margin: 16px auto;
}

.form-grid label {
  text-align: right;
  align-self: center;  /* vertically center in its grid cell */
  font-weight: bold;
}

.form-grid input {
  width: 100%;         /* fill that second column */
  font-size: 14px;
  padding: 4px 8px;
  box-sizing: border-box;
}

#jsonModal {
  display: none;
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 20px 24px;
  width: 500px;
  max-width: 90%;
  border-radius: 8px;
  border: 1px solid #ccc;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  font-family: 'Roboto', sans-serif;
}

#jsonModal h3 {
  margin-top: 0;
  font-size: 18px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 6px;
}

#jsonInput {
  width: 100%;
  font-family: monospace;
  font-size: 13px;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #bbb;
  box-sizing: border-box;
  resize: vertical;
}

.json-modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}


.spacer { height: 10px; }
.spacer-small { height: 4px; }
.spacer-bigger-small { height: 6px; }
.spacer-extra-small { height: 1px; }


.btnsettings {
  position: absolute;
  top: 0;
  right: 0;
  transform: translateY(50%);
  background: transparent;
  border: none;
  padding: 2px;
  margin: 0;
  font-size: 2.0em;
  cursor: pointer;
}

.btnsettings-primary { background: var(--color-primary); box-shadow: var(--shadow-soft); }
