:root {
  --bg: #eef1f5; --panel: #ffffff; --ink: #1d2430; --muted: #64707f; --line: #d7dde5;
  --accent: #1f6feb; --accent-ink: #ffffff; --ok: #16a34a; --err: #dc2626; --chip: #f3f5f8;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; flex-direction: column; }
button, select, input { font: inherit; }
button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 5px 11px; border-radius: 7px; cursor: pointer; }
button:hover:not(:disabled) { border-color: #aab4c2; background: var(--chip); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { background: #1a5fd0; }
select { border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; background: var(--panel); color: var(--ink); }

header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; margin-right: 8px; white-space: nowrap; }
.logo { color: var(--accent); }
.field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.field output { min-width: 30px; color: var(--ink); }
.spacer { flex: 1; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 1.1fr) minmax(400px, 1fr); }
#blocks { position: relative; border-right: 1px solid var(--line); }
#blockly { position: absolute; inset: 0; }
#right { display: flex; flex-direction: column; min-height: 0; }
#view { position: relative; flex: 1.35; min-height: 260px; overflow: hidden; }
#view canvas { display: block; }
#goal { position: absolute; top: 10px; left: 10px; right: 10px; max-width: 520px; background: rgba(255,255,255,.88); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; pointer-events: none; }
#goal b { color: var(--accent); }
#hud { position: absolute; left: 10px; bottom: 10px; background: rgba(20,26,36,.82); color: #e6edf5; border-radius: 8px; padding: 7px 10px; font: 12px/1.5 ui-monospace, Consolas, monospace; pointer-events: none; white-space: pre; }
#hud .st-ok { color: #4ade80; } #hud .st-run { color: #60a5fa; } #hud .st-err { color: #f87171; }
#banner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--ok); color: #fff; font-size: 22px; font-weight: 700; padding: 14px 26px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); pointer-events: none; }
#clickinfo { position: absolute; right: 10px; bottom: 10px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12px; }
#clickinfo code { font-size: 13px; }

#panel { flex: 1; min-height: 200px; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
#logbadge { background: var(--err); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.tab { display: none; flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.tab.active { display: block; }
.hint { color: var(--muted); font-size: 12px; }
h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.jogrow { display: flex; gap: 18px; flex-wrap: wrap; }
.jgrid { display: grid; grid-template-columns: auto 38px 38px; gap: 4px; align-items: center; }
.jgrid span { font-weight: 600; font-family: ui-monospace, Consolas, monospace; padding-right: 4px; }
.jgrid button { padding: 3px 0; }
.jogbox.side { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.teach { margin-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.teach span { color: var(--muted); }

#points { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
#points td, #points th { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; font-family: ui-monospace, Consolas, monospace; }
#points th { color: var(--muted); font-weight: 600; font-family: inherit; }
#points td:first-child, #points th:first-child { text-align: left; font-weight: 700; }
#points td button { padding: 1px 7px; font-size: 12px; font-family: system-ui, sans-serif; }

.pybar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pybar .hint { flex: 1; }
#python { margin: 0; background: #0f1620; color: #d6e2ef; border-radius: 8px; padding: 10px 12px; font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre; overflow: auto; }
#log { font: 12px/1.5 ui-monospace, Consolas, monospace; }
#log div { padding: 2px 0; border-bottom: 1px dashed #edf0f4; }
#log .err { color: var(--err); } #log .ok { color: var(--ok); } #log .print { color: #7c3aed; }
#log time { color: #9aa5b3; margin-right: 8px; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  #blocks { border-right: none; border-bottom: 1px solid var(--line); }
  #view { min-height: 340px; }
  header { padding: 8px 16px; }
}
@media (max-width: 900px) {
  html, body { height: auto; }
  main { display: block; }
  #blocks { height: 60vh; }
  #view { height: 55vh; flex: none; }
  #panel { min-height: 320px; }
}
a.linkbtn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 5px 11px; border-radius: 7px; text-decoration: none; white-space: nowrap; }
a.linkbtn:hover { border-color: #aab4c2; background: var(--chip); }
