:root {
  color-scheme: dark;
  --bg: #071015;
  --panel: #102029;
  --panel-2: #0b1920;
  --line: #29434f;
  --text: #eef8f7;
  --muted: #8ea5ad;
  --mint: #52e3b6;
  --cyan: #58c9e9;
  --amber: #ffc66d;
  --red: #ff6678;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; min-width: 320px; color: var(--text); font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif; background: radial-gradient(circle at 8% 0%, rgba(82, 227, 182, .11), transparent 28rem), var(--bg); }
button, select, input { font: inherit; }
button, select, .nav-button { min-height: 40px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #172c36; font-weight: 800; }
button { cursor: pointer; }
button:hover:not(:disabled), .nav-button:hover { border-color: #56808f; background: #203b47; }
button:disabled { opacity: .42; cursor: not-allowed; }
button.primary { border-color: rgba(82, 227, 182, .6); background: linear-gradient(135deg, #187b68, #145a70); }
button.danger { border-color: rgba(255, 102, 120, .62); background: #552833; }
button.small { min-height: 31px; padding: 5px 9px; font-size: 11px; }
select { cursor: pointer; }
.nav-button { display: inline-flex; align-items: center; text-decoration: none; }

.block-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 22px clamp(15px, 3vw, 42px) 18px; border-bottom: 1px solid rgba(58, 84, 96, .55); background: rgba(7, 16, 21, .88); }
.eyebrow { margin: 0 0 6px; color: var(--mint); font-size: 11px; font-weight: 900; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.04em; }
.block-topbar p:last-child { margin: 7px 0 0; color: var(--muted); }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.badge { display: inline-flex; align-items: center; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #0c1a21; font-size: 12px; font-weight: 800; }
.badge.good { color: var(--mint); border-color: rgba(82, 227, 182, .45); }
.badge.bad { color: #ff9ba7; border-color: rgba(255, 102, 120, .45); }

main { max-width: 1760px; margin: 0 auto; padding: 16px clamp(10px, 2vw, 28px) 32px; }
.toolbar-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: rgba(16, 32, 41, .94); }
.toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.toolbar-group > span { margin: 0 4px; color: var(--muted); font-size: 12px; font-weight: 800; }
.examples button { color: #cbeff3; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 13px; height: calc(100vh - 182px); min-height: 650px; margin-top: 13px; }
.workspace-card, .runtime-card { min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
#blocklyDiv { width: 100%; height: 100%; background: #f4f8fa; }
.runtime-card { overflow-y: auto; padding: 15px; }
.runtime-card section + section { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(41, 67, 79, .72); }
.runtime-head, .section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.runtime-head > div { display: grid; gap: 5px; }
.section-label { color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
#runState { font-size: 20px; }
.step-badge { padding: 5px 8px; border-radius: 999px; color: var(--cyan); background: rgba(88, 201, 233, .09); font-size: 11px; font-weight: 900; }
.current-step { margin-top: 10px; padding: 11px; border-radius: 10px; color: #bad0d5; background: var(--panel-2); font-size: 12px; line-height: 1.5; }
.result-output { min-height: 94px; max-height: 240px; overflow: auto; margin-top: 9px; padding: 12px; border: 1px solid rgba(88, 201, 233, .25); border-radius: 11px; background: #07151b; white-space: pre-wrap; line-height: 1.55; }
.muted { color: var(--muted); }

.camera-box { position: relative; aspect-ratio: 16/9; overflow: hidden; margin-top: 9px; border: 1px solid var(--line); border-radius: 11px; background: #03090c; }
.camera-box video, .camera-box img { width: 100%; height: 100%; object-fit: contain; display: none; }
#cameraEmpty { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; color: #6f8992; text-align: center; font-size: 12px; }
.body-connect-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 9px; }
.body-connect-section p { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
#runLog { min-height: 120px; max-height: 230px; overflow: auto; margin: 9px 0 0; padding: 10px; border-radius: 10px; color: #a9c9ca; background: #03090c; font: 11px/1.5 "Cascadia Mono", Consolas, monospace; white-space: pre-wrap; }
#toast { position: fixed; right: 18px; bottom: 18px; max-width: min(430px, calc(100vw - 36px)); padding: 12px 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: #142933; box-shadow: 0 16px 45px rgba(0,0,0,.35); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; z-index: 100; }
#toast.show { transform: translateY(0); opacity: 1; }
#toast.bad { border-color: var(--red); background: #4c2530; }

.blocklyToolboxDiv { border-right: 1px solid #2e4753; }
.blocklyTreeRow { height: 38px; padding: 7px 10px !important; }
.blocklyTreeLabel { font-family: Inter, Pretendard, sans-serif; font-size: 14px; }

@media (max-width: 1050px) {
  .editor-layout { grid-template-columns: minmax(0, 1fr) 310px; }
  .toolbar-card { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 760px) {
  .block-topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .editor-layout { display: flex; height: auto; min-height: 0; flex-direction: column; }
  .workspace-card { height: 620px; }
  .runtime-card { max-height: none; }
  .toolbar-group { width: 100%; }
  .toolbar-group button { flex: 1 1 140px; }
}
