@font-face {
  font-family: Fraunces;
  src: url('assets/fonts/fraunces-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #222;
  background: #fff;
  --border: #d8d8d8;
  --surface: #f5f5f5;
  --code: #222;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  color: #e6e6e6;
  background: #1e1e1e;
  --border: #444;
  --surface: #252525;
  --code: #e6e6e6;
}

* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; cursor: pointer; }
.app { height: 100dvh; min-height: 450px; display: flex; flex-direction: column; }
.topbar { height: 54px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--border); }
h1 { margin: 0; font: 700 21px Fraunces, Georgia, serif; white-space: nowrap; }
.actions { display: flex; gap: 8px; }
.actions button { border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: inherit; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.actions .run-button { background: #267345; border-color: #267345; color: #fff; font-weight: 600; }
.actions button:hover { filter: brightness(.92); }
.editor { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 34%); min-height: 0; }
.editor[data-python="expanded"] { grid-template-columns: minmax(0, 1fr) minmax(280px, 55%); }
.editor[data-python="hidden"] { grid-template-columns: minmax(0, 1fr); }
.workspace-pane, .code-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.code-pane { border-left: 1px solid var(--border); }
.code-pane[hidden] { display: none; }
.pane-title { height: 34px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--surface); font-size: 12px; font-weight: 600; }
.pane-title span { color: #888; font-weight: 400; }
.pane-title button { padding: 3px 7px; border: 1px solid var(--border); border-radius: 3px; background: transparent; color: inherit; font-size: 11px; }
#blockly-div { flex: 1; min-height: 0; }
.code-pane pre, .output-pane pre { margin: 0; padding: 12px; overflow: auto; flex: 1; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--code); white-space: pre; }
.hljs-keyword, .hljs-literal { color: #8544a6; }
.hljs-built_in, .hljs-title.function_ { color: #17699a; }
.hljs-string { color: #207348; }
.hljs-number { color: #ac5721; }
.hljs-comment { color: #75808a; font-style: italic; }
:root[data-theme="dark"] .hljs-keyword, :root[data-theme="dark"] .hljs-literal { color: #caa8ef; }
:root[data-theme="dark"] .hljs-built_in, :root[data-theme="dark"] .hljs-title.function_ { color: #88c8ee; }
:root[data-theme="dark"] .hljs-string { color: #a9d89a; }
:root[data-theme="dark"] .hljs-number { color: #efb680; }
:root[data-theme="dark"] .hljs-comment { color: #92a1ae; }
.output-pane { height: 155px; flex: none; display: flex; flex-direction: column; border-top: 1px solid var(--border); min-height: 0; }
.output-pane pre { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .topbar { height: auto; min-height: 54px; flex-wrap: wrap; padding: 8px; }
  .actions { flex-wrap: wrap; }
  .editor { grid-template-columns: 1fr; grid-template-rows: minmax(240px, 1fr) 180px; }
  .editor[data-python="expanded"] { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 1fr) minmax(230px, 45%); }
  .editor[data-python="hidden"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .code-pane { border-left: 0; border-top: 1px solid var(--border); }
  .output-pane { height: 120px; }
}
@media (max-width: 420px) {
  .topbar { padding: 0 8px; }
  h1 { font-size: 16px; }
  .actions { gap: 3px; }
  .actions button { padding: 6px; font-size: 11px; }
}
