/* Byte Design Lab: on top of kids.css and studio.css (shared top bar and dialogs) */
.d-app { grid-template-rows: auto 1fr; }
.d-main { display: grid; grid-template-columns: 200px minmax(0, 1fr) 340px; min-height: 0; }
.d-parts { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: #ffe58a; border-right: 4px solid var(--edge); overflow-y: auto; }
.d-parts h4 { margin: 6px 2px 2px; font: 700 11px var(--f-pixel); letter-spacing: .08em; color: #7a5a00; }
#d-parts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.d-part { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 3px solid var(--edge); border-radius: 12px; background: #fff; box-shadow: 0 3px 0 var(--drop); font: 900 12px var(--f-body); }
.d-part .pi { font-size: 20px; line-height: 1.1; font-weight: 900; }
.d-part:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop); }
.d-part:disabled { opacity: .5; }
#d-screens { display: flex; flex-direction: column; gap: 6px; }
.d-scr { display: flex; align-items: center; gap: 8px; padding: 5px; border: 3px solid var(--edge); border-radius: 12px; background: #fff; box-shadow: 0 3px 0 var(--drop); font: 900 13px var(--f-body); text-align: left; }
.d-scr.on { background: #fff7d6; outline: 3px solid #f59e0b; outline-offset: 1px; }
.d-scr .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini { position: relative; display: block; flex: none; width: 50px; height: 90px; border: 2px solid var(--edge); border-radius: 6px; overflow: hidden; }
.mini i { position: absolute; display: block; border-radius: 1px; }
.d-add { justify-content: center; background: #e9fbe9; border-style: dashed; } .d-add b { font-size: 20px; }
.d-add:disabled { opacity: .5; }

.d-canvas { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 12px 20px; background: #eef3fb radial-gradient(#d6deeb 1.4px, transparent 1.5px) 0 0 / 22px 22px; overflow: auto; border-right: 4px solid var(--edge); }
.d-brief { display: flex; align-items: center; gap: 10px; width: min(560px, 100%); padding: 8px 10px; border: 3px solid var(--edge); border-radius: 14px; background: #fff; box-shadow: 0 3px 0 var(--drop); }
.d-brief[hidden] { display: none; }
.d-brief .bi { font-size: 28px; } .d-brief .bt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.d-brief .bt b { font-size: 16px; } .d-brief .bt b em { font-style: normal; color: #f59e0b; } .d-brief .bt span { font-weight: 700; font-size: 13px; color: #4b5160; }
.d-phonewrap { position: relative; width: 100%; display: flex; justify-content: center; }
.d-phone { --k: 1; position: relative; box-sizing: content-box; width: 360px; height: 640px; padding: 30px 12px 6px; border: 4px solid var(--edge); border-radius: 44px; background: #1b1d24; box-shadow: 0 8px 0 rgba(0, 0, 0, .25); transform: scale(var(--k)); transform-origin: top center; flex: none; }
.d-notch { position: absolute; top: 9px; left: 50%; width: 90px; height: 12px; margin-left: -45px; border-radius: 6px; background: #2d313c; }
.d-screen { position: relative; width: 360px; height: 640px; overflow: hidden; border-radius: 4px 4px 32px 32px; background: #fff; touch-action: none; }
.d-phone.grid .d-screen::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(47, 127, 232, .12) 1px, transparent 1px) 0 0 / 8px 8px, linear-gradient(90deg, rgba(47, 127, 232, .12) 1px, transparent 1px) 0 0 / 8px 8px; }
.d-it { position: absolute; box-sizing: border-box; display: flex; align-items: center; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; line-height: 1.2; }
.d-it:focus { outline: none; }
.d-it.sel { outline: 2px solid #2f7fe8; outline-offset: 2px; z-index: 50; }
.d-it.warn::before { content: ''; position: absolute; inset: -4px; border: 2px dashed #ff2d87; border-radius: 6px; pointer-events: none; }
.d-it:focus-visible { outline: 3px solid #2f7fe8; outline-offset: 3px; }
.d-text { align-items: flex-start; font-weight: 800; word-break: break-word; }
.d-text .tx { width: 100%; }
.d-button, .d-chip { justify-content: center; font-weight: 900; text-align: center; padding: 0 10px; }
.d-button .tx, .d-chip .tx, .d-input .tx { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-input { padding: 0 14px; border: 2px solid #9ca3af; border-radius: 10px; font: 700 16px var(--f-body); }
.d-input .caret { width: 2px; height: 22px; margin-left: 2px; background: #2f7fe8; opacity: 0; }
.d-card { border: 0; }
.d-pic img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.d-icon svg { display: block; pointer-events: none; }
.d-toggle { padding: 3px; }
.d-toggle .knob { width: calc(var(--h, 26px)); aspect-ratio: 1; height: 100%; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: margin .15s; }
.d-toggle.on .knob { margin-left: auto; }
.d-handle { position: absolute; right: -9px; bottom: -9px; width: 16px; height: 16px; border: 3px solid #fff; border-radius: 4px; background: #2f7fe8; box-shadow: 0 0 0 2px #1b1d24; cursor: nwse-resize; touch-action: none; }
.d-guide { position: absolute; z-index: 60; pointer-events: none; background: #ff2d87; }
.d-guide.v { top: 0; bottom: 0; width: 1px; } .d-guide.h { left: 0; right: 0; height: 1px; }
.d-under { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.d-play { height: 48px; padding: 0 20px; border: 3px solid var(--edge); border-radius: 14px; background: #22c55e; color: #fff; box-shadow: 0 4px 0 var(--drop); font: 900 18px var(--f-body); }
.d-play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--drop); }
.d-grid { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; }
.d-grid input { width: 20px; height: 20px; accent-color: #2f7fe8; }
.d-tipline { flex-basis: 100%; text-align: center; font-weight: 800; font-size: 14px; color: #4b5160; }
.d-tipline.warn { color: #b45309; }
.d-code { position: static; width: min(560px, 100%); max-height: 360px; margin-top: 4px; white-space: pre; }

.d-side { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: #fffdf6; }
.d-props, .d-coach { padding: 12px 14px; }
.d-props { border-bottom: 4px solid var(--edge); }
.d-props h3, .d-coach h3 { margin: 0 0 8px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.d-xy { margin-left: auto; font: 700 12px var(--f-code); color: #6b7280; }
.d-field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-weight: 900; font-size: 13px; }
.d-field input, .d-field select { height: 42px; padding: 0 10px; border: 3px solid var(--edge); border-radius: 10px; font: 800 16px var(--f-body); background: #fff; color: var(--ink); }
.d-field input:focus, .d-field select:focus { outline: 3px solid var(--gold); }
.d-seg, .d-sw { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0 0 10px; }
.d-seg .lab, .d-sw .lab { flex-basis: 100%; font-weight: 900; font-size: 13px; }
.d-seg button { min-width: 44px; height: 36px; padding: 0 10px; border: 3px solid var(--edge); border-radius: 10px; background: #fff; font: 900 13px var(--f-body); }
.d-seg button.on { background: var(--gold); }
.d-sw .sw { width: 30px; height: 30px; padding: 0; border: 2px solid var(--edge); border-radius: 8px; }
.d-sw .sw.on { outline: 3px solid #2f7fe8; outline-offset: 2px; }
.d-sw .sw:focus-visible, .d-seg button:focus-visible { outline: 3px solid #2f7fe8; outline-offset: 2px; }
.d-icons, .d-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; margin: 0 0 10px; }
.d-icons button, .d-pics button { height: 40px; padding: 7px; border: 2px solid var(--edge); border-radius: 8px; background: #fff; }
.d-pics button { padding: 3px; } .d-pics img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.d-icons button.on, .d-pics button.on { background: var(--gold); }
.d-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.d-hint { margin: 6px 0 0; color: #5b6170; font-weight: 700; font-size: 13px; }
.d-score { margin: 0 0 8px; padding: 8px 10px; border-radius: 10px; background: #fff1f6; color: #9d174d; font-weight: 900; }
.d-score.ok { background: #e9fbe9; color: #166534; }
.d-rules { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; font-weight: 800; font-size: 13px; }
.d-rules li { display: flex; align-items: center; gap: 5px; } .d-rules li span { width: 20px; text-align: center; }
.d-rules li i { font-style: normal; color: #16a34a; } .d-rules li b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: #ff2d87; color: #fff; font-size: 12px; }
.d-rules li.bad { color: #9d174d; }
.d-issue { display: flex; flex-direction: column; gap: 2px; width: 100%; margin: 0 0 6px; padding: 8px 10px; border: 2px solid #f9a8c9; border-radius: 10px; background: #fff; text-align: left; font: 700 13px var(--f-body); color: #4b5160; }
.d-issue b { color: #1b1d24; font-size: 14px; }
.d-issue:hover { background: #fff7fb; }
.d-unit { margin: 10px 2px 2px; font: 700 12px var(--f-pixel); letter-spacing: .06em; color: #7a5a00; }
.d-filemini { width: 50px; height: 90px; }

/* prototype */
.d-proto { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: rgba(15, 23, 42, .78); }
.d-proto[hidden] { display: none; }
.d-protobox { position: relative; display: flex; flex-direction: column; align-items: center; }
.d-protobox p { margin: 0; color: #fff; font-weight: 800; }
.d-protobox .s-x { top: -6px; right: -54px; }
.d-phone.big { transform: scale(var(--k)); transform-origin: top center; margin-bottom: calc((var(--k) - 1) * 684px + 10px); }
.d-proto .d-it { cursor: default; }
.d-proto .d-it.lnk { cursor: pointer; } .d-proto .d-it.lnk:active { filter: brightness(.9); transform: translateY(1px); }
.d-proto .d-toggle { cursor: pointer; }

@media (max-width: 1180px) { .d-main { grid-template-columns: 170px minmax(0, 1fr) 300px; } }
@media (max-width: 980px) {
  .d-app { height: auto; min-height: 100dvh; }
  .d-main { grid-template-columns: 1fr; }
  .d-parts { border-right: 0; border-bottom: 4px solid var(--edge); }
  #d-parts { grid-template-columns: repeat(5, 1fr); } #d-screens { flex-direction: row; overflow-x: auto; }
  .d-scr { flex: none; }
  .d-canvas { border-right: 0; border-bottom: 4px solid var(--edge); }
  .d-side { overflow: visible; }
}
@media (max-width: 520px) { #d-parts { grid-template-columns: repeat(4, 1fr); } .d-protobox .s-x { right: 0; top: -52px; } }

.d-app .k-tool { color: var(--ink); }
.d-app #d-code[aria-pressed="false"] { background: #fff; opacity: 1; font: 900 15px var(--f-code); }
.d-app #d-code[aria-pressed="true"] { background: var(--gold); font: 900 15px var(--f-code); }

.d-handle.in-x { right: 2px; } .d-handle.in-y { bottom: 2px; }
/* the phone holder must never be squeezed by the column (short windows) */
.d-phonewrap, .d-brief, .d-under, .d-code { flex: none; }
/* the close button for ▶ Try it sits in the window's corner, clear of the (enlarged) phone */
.d-proto .d-protobox .s-x { position: fixed; top: 16px; right: 16px; z-index: 2; width: 48px; height: 48px; font-size: 22px; }

/* scroll areas: a still frame (grip, resize handle) around a layer that scrolls */
.d-scroll { display: block; }
.d-scv { position: absolute; inset: 0; overflow: hidden; scrollbar-width: thin; }
.d-scroll.v .d-scv { overflow-y: auto; touch-action: pan-y; }
.d-scroll.h .d-scv { overflow-x: auto; touch-action: pan-x; }
.d-sc { position: relative; }
.d-scroll.sel { outline-style: dashed; }
.d-grip { position: absolute; left: -14px; top: -14px; z-index: 3; display: none; place-items: center; width: 26px; height: 26px; border: 2px solid #fff; border-radius: 8px; background: #2f7fe8; color: #fff; font: 900 15px var(--f-body); box-shadow: 0 0 0 2px #1b1d24; cursor: move; touch-action: none; }
.d-scroll.sel > .d-grip { display: grid; }
.d-proto .d-scv { scroll-behavior: smooth; }
.d-proto .d-scv:focus-visible { outline: 3px solid #2f7fe8; outline-offset: -3px; }

/* a switch with an event shows a little ⚡ while designing */
.d-toggle { position: relative; }
.d-ev { position: absolute; right: -10px; top: -12px; font-size: 14px; line-height: 1; filter: drop-shadow(0 1px 0 #fff); pointer-events: none; }
.d-proto .d-ev { display: none; }
.d-proto .d-toggle:focus-visible { outline: 3px solid #2f7fe8; outline-offset: 3px; }

/* pictures: groups in the picker; logos drawn smooth, pixel art crisp */
.d-picgroup { display: block; margin: 4px 0 3px; font: 700 11px var(--f-pixel); letter-spacing: .06em; color: #7a5a00; }
.d-pics.wide { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
.d-pics img.smooth, .d-pic img.smooth { image-rendering: auto; }

/* long screens scroll inside the phone (while designing and in ▶ Try it) */
.d-screen { overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; touch-action: pan-y; overscroll-behavior: contain; }
.d-spacer { position: absolute; left: 0; width: 1px; height: 1px; pointer-events: none; }
.d-more { flex-basis: 100%; text-align: center; font-weight: 900; font-size: 14px; color: #1d3557; }
.d-more[hidden] { display: none; }
.d-proto .d-screen { scroll-behavior: smooth; }
