/* Palette and metrics follow scratch-gui (menu bar, sprite selector, tabs). */
:root {
  --looks: #9966ff;
  --menu: #855cd6;
  --menu-dark: #774dcb;
  --blue: #4c97ff;
  --blue-light: #e9f1fc;
  --text: #575e75;
  --ui-white: #ffffff;
  --ui-pane: #e5f0ff;
  --ui-secondary: #f9f9f9;
  --border: hsla(0, 0%, 0%, 0.15);
  --red: #ff6680;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ui-pane); overflow: hidden; }
body { display: flex; flex-direction: column; font-size: 0.75rem; }

.menu-bar {
  display: flex; align-items: center; height: 3rem; padding: 0 0.5rem; flex-shrink: 0;
  background: var(--menu); color: var(--ui-white); font-weight: bold; font-size: 0.75rem;
}
.logo { font-size: 1rem; padding: 0 0.75rem; white-space: nowrap; }
.brace { background: var(--ui-white); color: var(--menu); border-radius: 0.25rem; padding: 0 0.3rem; margin-right: 0.25rem; }
.divider { width: 1px; height: 2rem; background: hsla(0, 0%, 100%, 0.25); margin: 0 0.5rem; }
.spacer { flex: 1; }
.menu-item {
  display: flex; align-items: center; gap: 0.35rem; height: 100%; padding: 0 0.75rem;
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer; white-space: nowrap;
}
.menu-item:hover { background: hsla(0, 0%, 0%, 0.15); }
.menu-item:disabled { opacity: 0.5; cursor: default; }
.status { padding: 0 0.75rem; font-weight: normal; opacity: 0.9; }
body.embedded .standalone-only, body:not(.embedded) .embedded-only { display: none; }

main { flex: 1; display: flex; min-height: 0; padding: 0.5rem; gap: 0.5rem; }

.sprite-pane {
  width: 13rem; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--ui-secondary); border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden;
}
.pane-header {
  display: flex; align-items: center; justify-content: space-between; height: 2.75rem; padding: 0 0.75rem;
  background: var(--ui-white); border-bottom: 1px solid var(--border); font-weight: bold; font-size: 0.875rem;
}
.add {
  width: 2rem; height: 2rem; border-radius: 50%; border: 0; background: var(--looks); color: #fff;
  font-size: 1.25rem; line-height: 1; cursor: pointer; box-shadow: 0 0 0 4px hsla(260, 100%, 70%, 0.25);
}
.add:hover { background: var(--menu); }
.tiles { flex: 1; overflow-y: auto; padding: 0.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; align-content: start; }
.tile {
  position: relative; height: 5.5rem; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 0.35rem; background: var(--ui-white); border: 2px solid var(--border); border-radius: 0.5rem; cursor: pointer; user-select: none;
}
.tile:hover { border-color: var(--blue); }
.tile.selected { border-color: var(--blue); box-shadow: 0 0 0 4px hsla(215, 100%, 65%, 0.35); background: var(--blue-light); }
.tile.drop { border-style: dashed; border-color: var(--looks); }
.tile.nocode { opacity: 0.6; }
.tile img { max-width: 3rem; max-height: 3rem; flex: 1; object-fit: contain; }
.tile .name { width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.7rem; }
.tile.selected .name { color: #fff; background: var(--blue); border-radius: 0 0 0.25rem 0.25rem; margin: 0 -0.35rem -0.35rem; padding: 0.15rem 0; width: calc(100% + 0.7rem); }
.badge {
  position: absolute; top: -0.4rem; left: -0.4rem; min-width: 1.25rem; height: 1.25rem; border-radius: 0.625rem; padding: 0 0.3rem;
  background: var(--looks); color: #fff; font-size: 0.65rem; line-height: 1.25rem; text-align: center; font-weight: bold;
}
.delete {
  position: absolute; top: -0.5rem; right: -0.5rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 0;
  background: var(--looks); color: #fff; cursor: pointer; display: none; font-size: 0.75rem;
}
.tile.selected .delete { display: block; }
.hint { margin: 0; padding: 0.5rem 0.75rem; font-size: 0.65rem; border-top: 1px solid var(--border); }

.code-pane {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--ui-white); border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden;
}
.tabs { display: flex; height: 2.75rem; background: var(--ui-pane); border-bottom: 1px solid var(--border); padding: 0.5rem 0.5rem 0; gap: 0.25rem; flex-shrink: 0; overflow-x: auto; }
.tab {
  display: flex; align-items: center; padding: 0 1rem; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 1rem 1rem 0 0; background: hsla(215, 100%, 65%, 0.15); color: var(--text); cursor: pointer; font-weight: bold; white-space: nowrap;
}
.tab.active { background: var(--ui-white); color: var(--blue); margin-bottom: -1px; }
.monaco { flex: 1; min-height: 0; }
.problems { max-height: 9rem; overflow-y: auto; border-top: 1px solid var(--border); background: var(--ui-secondary); }
.problems:empty { display: none; }
.problem { padding: 0.35rem 0.75rem; cursor: pointer; font-family: Menlo, Consolas, monospace; font-size: 0.7rem; border-bottom: 1px solid var(--border); }
.problem:hover { background: var(--blue-light); }
.problem b { color: #d6334b; }
.problem.warn b { color: #cf8b17; }
.ok { color: #0b8e69; }
.err { color: #ffd6dd; }
