:root {
  --parchment: #f6f1e8;
  --paper: rgba(255, 250, 243, 0.82);
  --ink: #24170e;
  --smoke: #655446;
  --copper: #ba6a2f;
  --copper-deep: #914d1a;
  --olive: #69724f;
  --border: rgba(54, 36, 22, 0.12);
  --shadow: 0 24px 70px rgba(55, 39, 24, 0.08);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(186, 106, 47, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(105, 114, 79, 0.12), transparent 26%),
    linear-gradient(180deg, #f8f4ed 0%, #f0e7da 100%);
}

code, pre, .chips span {
  font-family: "IBM Plex Mono", monospace;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 250, 243, 0.96), rgba(251, 242, 228, 0.88));
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}

.topbar p {
  font-size: 0.82rem;
  color: var(--smoke);
  margin-top: 2px;
}

.topbar-left {
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.inline-field span {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--smoke);
}

.inline-field input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  border: 1px solid rgba(54, 36, 22, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 251, 245, 0.92);
}

/* ---- builder ---- */
.builder {
  display: grid;
  grid-template-columns: 1fr 420px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.builder-workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.builder-output {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--paper);
}

/* ---- bar ---- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bar span {
  font-size: 0.88rem;
  font-weight: 600;
}

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

.pill {
  padding: 6px 14px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid rgba(145, 77, 26, 0.18);
  border-radius: 999px;
  color: var(--copper-deep);
  background: rgba(255, 248, 239, 0.9);
  cursor: pointer;
  transition: transform 100ms ease, background 100ms ease;
}

.pill:hover {
  transform: translateY(-1px);
  background: rgba(247, 231, 211, 0.95);
}

.pill-accent {
  background: rgba(145, 77, 26, 0.12);
  border-color: rgba(145, 77, 26, 0.3);
  font-weight: 600;
}

/* ---- blockly ---- */
#blocklyDiv {
  flex: 1;
  min-height: 0;
}

.blocklyToolboxDiv, .blocklyFlyout {
  font-family: "Space Grotesk", sans-serif;
}

.blocklyMainBackground {
  stroke: transparent;
}

/* ---- output ---- */
.output-meta {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.meta-item small {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--copper-deep);
  margin-bottom: 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips span {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(105, 114, 79, 0.1);
  color: var(--olive);
  font-size: 0.78rem;
}

.code-box {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 16px 18px;
  background: #1e1915;
  color: #f8f3eb;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
}

/* ---- responsive ---- */
@media (max-width: 960px) {
  .builder {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .builder-output {
    border-left: none;
    border-top: 1px solid var(--border);
  }

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

  .topbar-right {
    flex-direction: column;
  }
}
