:root {
  --bg: #efe7d8;
  --panel: rgba(255, 250, 242, 0.94);
  --panel-strong: rgba(255, 247, 236, 0.98);
  --ink: #211d16;
  --muted: #736858;
  --accent: #ef7f45;
  --accent-dark: #cb632c;
  --line: rgba(33, 29, 22, 0.12);
  --shadow: 0 24px 64px rgba(93, 63, 34, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "IBM Plex Mono", "Fira Code", monospace;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(239, 127, 69, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(85, 150, 121, 0.12), transparent 18%),
    var(--bg);
}

.app-root {
  width: 100%;
  height: 100%;
}

.workspace-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

.workspace-frame {
  position: relative;
  width: 100%;
  height: 100%;
}

.workspace-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workspace-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-decoration: none;
  overflow: hidden;
  cursor: pointer;
}

.workspace-link-button img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
}

.workspace-build-button {
  background: var(--accent);
  border-color: transparent;
  color: white;
}

.workspace-build-icon {
  font-family: "Material Symbols Rounded";
  width: 28px;
  height: 28px;
  font-size: 28px;
  line-height: 1;
  font-weight: normal;
  font-style: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1;
}

.ghost-button,
.accent-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  text-transform: lowercase;
  cursor: pointer;
}

.ghost-button {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.accent-button {
  background: var(--accent);
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow);
}

#blocklyDiv {
  position: absolute;
  inset: 0;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(92, 70, 46, 0.28);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: absolute;
  inset: 15%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-actions {
  padding: 18px 22px;
}

.modal-body {
  min-height: 0;
  padding: 22px;
}

.preview-layout {
  display: grid;
  grid-template-columns: minmax(280px, 34%) minmax(0, 1fr);
  gap: 16px;
  min-height: 100%;
}

.preview-layout.hidden,
.build-layout.hidden {
  display: none;
}

.code-panel,
.manifest-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
  padding: 16px;
}

.code-panel h3,
.manifest-panel h3,
.build-layout h3 {
  margin: 0;
}

#code-preview,
#manifest-preview {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: 12px 0 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
}

.build-layout {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  min-height: 100%;
}

.build-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}

.build-progress-value {
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1.4;
  text-align: right;
}

.build-progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(33, 29, 22, 0.1);
}

.build-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f2bb54);
  transition: width 180ms ease;
}

.build-latest-line {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.build-latest-line.error {
  color: #8b2f1c;
}

.build-ad-placeholder {
  width: 100%;
  min-height: 0;
  border: 1px dashed rgba(33, 29, 22, 0.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(239, 127, 69, 0.06), rgba(255, 253, 248, 0.92));
}

.hidden {
  display: none !important;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.modal-actions > button {
  width: 220px;
  height: 42px;
}

.blocklyToolboxDiv,
.blocklyFlyout {
  background: rgba(255, 247, 236, 0.96) !important;
  border-right: 1px solid rgba(33, 29, 22, 0.08) !important;
}

.blocklyMainBackground {
  fill: #f7f1e7 !important;
  stroke: rgba(33, 29, 22, 0.08) !important;
}

.blocklyTreeLabel {
  color: var(--ink) !important;
}

.blocklyScrollbarHandle {
  fill: rgba(33, 29, 22, 0.22) !important;
}

.blocklySelected > .blocklyPath {
  stroke: var(--accent-dark) !important;
}

@media (max-width: 1080px) {
  .modal-dialog {
    inset: 8%;
  }

  .preview-layout {
    grid-template-columns: 1fr;
  }

  .build-ad-placeholder {
    width: 100%;
  }

  .workspace-controls {
    top: 10px;
    right: 10px;
    flex-wrap: wrap;
  }
}
