/* Drafta app — graphite + signal-orange design system */
@font-face { font-family: 'Geist'; src: url('../../assets/fonts/geist-latin-wght-normal.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('../../assets/fonts/geist-mono-latin-wght-normal.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #0e1013;
  --bg-2: #13161a;
  --panel: #171a1f;
  --panel-2: #1d2127;
  --panel-3: #242930;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #eceef1;
  --text-2: #b4bac3;
  --muted: #858e9b;
  --faint: #5c6470;
  --accent: #ff6a2b;
  --accent-2: #ff8a54;
  --accent-ink: #1a0b03;
  --accent-soft: rgba(255, 106, 43, 0.14);
  --accent-line: rgba(255, 106, 43, 0.35);
  --blue: #4da3ff;
  --mint: #2be3a0;
  --amber: #f5b83d;
  --red: #f05252;
  --glass: rgba(20, 23, 28, 0.78);
  --shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --font: 'Geist', 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
[data-theme='light'] {
  --bg: #f4f5f7;
  --bg-2: #eceef1;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --panel-3: #eceef2;
  --line: rgba(15, 18, 24, 0.08);
  --line-2: rgba(15, 18, 24, 0.14);
  --text: #14171c;
  --text-2: #3c434d;
  --muted: #6b7380;
  --faint: #9aa1ab;
  --accent-soft: rgba(255, 106, 43, 0.12);
  --glass: rgba(255, 255, 255, 0.82);
  --shadow: 0 10px 30px -10px rgba(16, 24, 40, 0.18), 0 2px 6px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 60px -16px rgba(16, 24, 40, 0.3);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { overflow: hidden; user-select: none; -webkit-user-select: none; }
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea { user-select: text; -webkit-user-select: text; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent-2); text-decoration: none; }
svg { flex: none; }
.ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 18px; height: 18px; }
.ico.xs { width: 15px; height: 15px; }
.ico.lg { width: 28px; height: 28px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
.hide { display: none !important; }
.grow { flex: 1; min-width: 0; }
.mono { font-family: var(--mono); font-feature-settings: 'tnum'; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- boot */
.boot { position: fixed; inset: 0; display: grid; place-content: center; gap: 22px; justify-items: center; background: var(--bg); z-index: 99; transition: opacity .35s var(--ease); }
.boot-mark { width: 64px; height: 64px; filter: drop-shadow(0 12px 30px rgba(255, 106, 43, .35)); }
.boot-bar { width: 120px; height: 3px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 3px; animation: boot 1.1s var(--ease) infinite; }
@keyframes boot { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
.boot.out { opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-weight: 560; letter-spacing: -.005em; transition: background .15s, transform .1s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--panel-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 8px 22px -10px rgba(255, 106, 43, .8); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--red); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center; color: var(--text-2); transition: background .15s, color .15s; position: relative; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:active { transform: scale(.95); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.icon-btn[disabled] { opacity: .35; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }
.chip:active { transform: scale(.97); }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 650; letter-spacing: .02em; background: var(--accent-soft); color: var(--accent-2); text-transform: uppercase; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.input, select.input, textarea.input { width: 100%; height: 44px; padding: 0 13px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 110px; padding: 11px 13px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { height: 34px; border-radius: 9px; font-size: 13.5px; padding: 0 10px; }
.switch { position: relative; width: 42px; height: 25px; border-radius: 99px; background: var(--panel-3); border: 1px solid var(--line-2); transition: background .2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); transition: transform .2s var(--ease); }
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { transform: translateX(17px); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { white-space: nowrap; height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13.5px; font-weight: 560; color: var(--muted); }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }

/* ---------------------------------------------------------------- home */
.home { flex: 1; display: flex; min-height: 0; }
.home-nav { display: none; }
.home-main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: calc(var(--safe-t) + 8px) 0 calc(var(--safe-b) + 86px); -webkit-overflow-scrolling: touch; }
.home-inner { max-width: 1180px; margin: 0 auto; padding: 0 18px; }
.appbar { display: flex; align-items: center; gap: 10px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.03em; }
.brand svg { width: 34px; height: 34px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #ff8a54, #ff5a1f); color: #fff; font-weight: 700; font-size: 14px; }
.hello { margin: 10px 0 18px; }
.hello h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.035em; font-weight: 700; }
.hello p { margin: 6px 0 0; color: var(--muted); }
.notice { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-lg); background: linear-gradient(135deg, rgba(255, 106, 43, .16), rgba(255, 106, 43, .04)); border: 1px solid var(--accent-line); margin-bottom: 18px; }
.notice.warning { background: linear-gradient(135deg, rgba(245, 184, 61, .16), rgba(245, 184, 61, .04)); border-color: rgba(245, 184, 61, .35); }
.notice.info { background: linear-gradient(135deg, rgba(77, 163, 255, .16), rgba(77, 163, 255, .04)); border-color: rgba(77, 163, 255, .35); }
.notice b { display: block; font-size: 14.5px; }
.notice p { margin: 2px 0 0; font-size: 13.5px; color: var(--text-2); }
.notice .x { position: absolute; top: 8px; right: 8px; }
.starts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-bottom: 26px; }
.start { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-height: 148px; padding: 18px; border-radius: var(--r-xl); text-align: left; border: 1px solid var(--line); background: var(--panel); transition: transform .15s var(--ease), border-color .2s; }
.start:active { transform: scale(.985); }
.start b { font-size: 17px; letter-spacing: -.02em; }
.start span { font-size: 13px; color: var(--muted); }
.start .ic { position: absolute; top: 16px; left: 16px; width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--panel-3); }
.start.new { background: radial-gradient(120% 140% at 100% 0%, #ff8a54 0%, #ff6a2b 38%, #e8501a 100%); border: 0; color: #fff; box-shadow: 0 18px 40px -18px rgba(255, 106, 43, .9); }
.start.new span { color: rgba(255, 255, 255, .82); }
.start.new .ic { background: rgba(255, 255, 255, .2); }
.start.new::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .13) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .13) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(135deg, transparent 20%, #000 90%); -webkit-mask-image: linear-gradient(135deg, transparent 20%, #000 90%); }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 12px; }
.sec-h h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; font-weight: 650; }
.sec-h button, .sec-h a { font-size: 13.5px; color: var(--accent-2); font-weight: 560; }
.section { margin-bottom: 28px; }
.hscroll { display: grid; grid-auto-flow: column; grid-auto-columns: 168px; gap: 12px; overflow-x: auto; padding-bottom: 6px; margin: 0 -18px; padding-left: 18px; padding-right: 18px; scroll-snap-type: x proximity; scroll-padding: 0 18px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; }
.tpl { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.thumb { position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-lg); background: #121418; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; }
[data-theme='light'] .thumb { background: #fff; }
.thumb img, .thumb svg.art { width: 100%; height: 100%; object-fit: contain; }
.thumb .tag { position: absolute; left: 8px; top: 8px; }
.tpl b { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.tpl span { font-size: 12.5px; color: var(--muted); margin-top: -6px; }
.grid-files { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.file { position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.file .meta { display: flex; align-items: flex-start; gap: 6px; }
.file .meta b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .meta small { display: block; font-size: 12px; color: var(--muted); }
.file .more { margin: -6px -8px 0 0; width: 34px; height: 34px; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 34px 18px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r-lg); color: var(--muted); }
.empty b { color: var(--text); font-size: 15.5px; }
.list { display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.list > .li { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 14px; border-top: 1px solid var(--line); text-align: left; width: 100%; }
.list > .li:first-child { border-top: 0; }
.list > .li:active { background: var(--panel-2); }
.li .lic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--panel-3); color: var(--text-2); flex: none; }
.li b { display: block; font-weight: 580; font-size: 14.5px; }
.li small { display: block; color: var(--muted); font-size: 12.5px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; padding: 6px 6px calc(var(--safe-b) + 6px); background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 560; color: var(--muted); border-radius: 12px; }
.tabbar button.on { color: var(--accent); }
.tabbar .fab { flex: none; width: 52px; height: 52px; margin-top: -18px; border-radius: 17px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 26px -10px rgba(255, 106, 43, .9); }
.search { position: relative; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 40px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); }
.plan { padding: 18px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel); }
.plan.hl { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 60%), var(--panel); }
.plan h3 { margin: 0; font-size: 17px; }
.plan .price { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin: 6px 0 10px; }
.plan ul { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 7px; font-size: 13.5px; color: var(--text-2); }
.plan li::before { content: '✓'; color: var(--mint); font-weight: 700; margin-right: 8px; }
.article { font-size: 15px; line-height: 1.65; color: var(--text-2); }
.article h1, .article h2, .article h3 { color: var(--text); letter-spacing: -.02em; line-height: 1.25; }
.article img { max-width: 100%; border-radius: var(--r); }
.article code, .kbd { font-family: var(--mono); font-size: 12.5px; padding: 2px 6px; border-radius: 6px; background: var(--panel-3); color: var(--text); }

@media (min-width: 900px) {
  .home-nav { display: flex; flex-direction: column; gap: 4px; width: 236px; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--bg-2); }
  .home-nav .brand { padding: 4px 8px 18px; }
  .home-nav button.nav { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 11px; color: var(--text-2); font-weight: 560; }
  .home-nav button.nav.on { background: var(--panel-3); color: var(--text); }
  .home-nav button.nav.on .ico { color: var(--accent); }
  .home-nav .btn.primary { margin-bottom: 14px; }
  .tabbar { display: none; }
  .home-main { padding-bottom: 40px; }
  .appbar .brand { visibility: hidden; }
  .grid-files { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .starts { grid-template-columns: 1.3fr 1fr 1fr; }
  .hscroll { grid-auto-columns: 200px; }
  .hello h1 { font-size: 34px; }
}

/* ---------------------------------------------------------------- editor */
.editor { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; display: block; }
.stage canvas.over { cursor: none; }
.topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 12; display: flex; align-items: center; gap: 4px; padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 8px) 8px calc(var(--safe-l) + 8px); pointer-events: none; }
.topbar > * { pointer-events: auto; }
.pill { display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 15px; background: var(--glass); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border: 1px solid var(--line); box-shadow: var(--shadow); }
.docname { display: flex; flex-direction: column; justify-content: center; min-width: 0; max-width: 42vw; padding: 0 8px 0 4px; height: 40px; text-align: left; border-radius: 10px; }
.docname b { font-size: 14.5px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.docname small { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.docname small i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); display: inline-block; }
.docname small i.dirty { background: var(--amber); }
.layerbtn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 11px 0 9px; border-radius: 11px; font-size: 13.5px; font-weight: 560; color: var(--text-2); max-width: 150px; }
.layerbtn .sw { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); flex: none; }
.layerbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 759px) {
  .docname { max-width: calc(100vw - 236px); }
  .layerbtn { padding: 0 10px; }
  .layerbtn span { display: none; }
  .topbar .icon-btn { width: 38px; }
}

.palette { position: absolute; left: calc(var(--safe-l) + 8px); top: 72px; bottom: 112px; z-index: 11; display: none; flex-direction: column; gap: 4px; padding: 6px; width: 56px; overflow-y: auto; scrollbar-width: none; }
.palette::-webkit-scrollbar { display: none; }
.palette .gl { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; color: var(--faint); text-transform: uppercase; text-align: center; padding: 8px 0 3px; }
.tool { position: relative; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); transition: background .12s, color .12s; }
.tool:hover { background: var(--panel-3); color: var(--text); }
.tool.on { background: var(--accent); color: #fff; box-shadow: 0 6px 16px -6px rgba(255, 106, 43, .9); }
.tool:active { transform: scale(.94); }
.tip { position: fixed; z-index: 90; padding: 6px 10px; border-radius: 9px; background: #0a0b0d; color: #fff; font-size: 12.5px; font-weight: 550; pointer-events: none; box-shadow: var(--shadow); white-space: nowrap; }
.tip kbd { font-family: var(--mono); font-size: 11px; color: #ffb38a; margin-left: 6px; }

.bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 12; display: flex; flex-direction: column; gap: 8px; padding: 0 calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px); pointer-events: none; }
.bottom > * { pointer-events: auto; }
.prompt { display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 6px 6px 6px 14px; border-radius: 16px; }
.prompt .ptxt { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.prompt .ptxt b { font-size: 14px; font-weight: 600; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt .ptxt small { font-size: 11.5px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt .kws { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
.prompt .kws::-webkit-scrollbar { display: none; }
.prompt .cmdin { flex: 1; min-width: 60px; height: 40px; border: 0; outline: 0; background: transparent; font-family: var(--mono); font-size: 14px; color: var(--text); }
.prompt .cmdin::placeholder { color: var(--faint); font-family: var(--font); }
.prompt .okbtn { height: 40px; padding: 0 14px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 650; display: inline-flex; align-items: center; gap: 6px; }
.prompt .okbtn:active { transform: scale(.96); }
.dock, .dock.pill { display: flex; flex-direction: column; align-items: stretch; border-radius: 18px; overflow: hidden; }
.dock > * { min-width: 0; }
.dock .tabs { display: flex; gap: 2px; padding: 5px 5px 0; overflow-x: auto; scrollbar-width: none; }
.dock .tabs::-webkit-scrollbar { display: none; }
.dock .tabs button { height: 30px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; font-weight: 620; color: var(--muted); letter-spacing: .01em; white-space: nowrap; }
.dock .tabs button.on { color: var(--text); background: var(--panel-3); }
.dock .tools { display: flex; gap: 2px; padding: 6px 5px 6px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.dock .tools::-webkit-scrollbar { display: none; }
.dock .tools .tool { flex: none; width: 62px; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10.5px; font-weight: 560; scroll-snap-align: start; }
.dock .tools .tool span { max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: flex; align-items: center; gap: 6px; padding: 0 2px; overflow-x: auto; scrollbar-width: none; }
.status::-webkit-scrollbar { display: none; }
.status .coords { flex: none; font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; padding: 0 8px; }
.status .chip { height: 28px; font-size: 11.5px; font-weight: 650; letter-spacing: .03em; padding: 0 10px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.status .chip.on { background: var(--accent-soft); }
.selbar { align-self: center; display: flex; gap: 2px; padding: 4px; border-radius: 15px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.selbar::-webkit-scrollbar { display: none; }
.selbar > * { flex: none; }
.selbar .tool { width: 52px; height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; font-weight: 560; }
.selbar .count { display: grid; place-items: center; padding: 0 10px; font-size: 12px; font-weight: 650; color: var(--accent-2); }
.dyn { position: fixed; z-index: 30; pointer-events: none; display: flex; gap: 4px; align-items: center; transform: translate(18px, 18px); }
.dyn span { padding: 3px 7px; border-radius: 7px; background: rgba(10, 11, 13, .88); color: #fff; font: 600 12px/1.3 var(--mono); border: 1px solid rgba(255, 255, 255, .08); white-space: nowrap; }
.dyn span.p { font-family: var(--font); font-weight: 560; color: #ffcfb8; }
.snaptag { position: fixed; z-index: 30; pointer-events: none; padding: 2px 7px; border-radius: 6px; background: var(--mint); color: #052016; font-size: 11px; font-weight: 700; transform: translate(14px, -26px); }

.result { position: absolute; top: calc(var(--safe-t) + 64px); left: 50%; transform: translateX(-50%); z-index: 14; min-width: 240px; max-width: min(420px, calc(100vw - 24px)); padding: 14px 16px; border-radius: var(--r-lg); }
.result h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.result .v { font: 700 24px/1.2 var(--mono); letter-spacing: -.02em; margin: 4px 0 8px; }

@media (max-width: 759px) {
  /* phones: commands come from the toolbar or the command list, values from the keypad */
  .prompt .cmdin { display: none; }
  .prompt .ptxt b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
@media (min-width: 760px) {
  .palette { display: flex; }
  .dock { display: none; }
  .bottom { left: 72px; align-items: stretch; }
  .prompt { max-width: 760px; width: 100%; align-self: center; }
  .status { justify-content: center; }
}

/* ---------------------------------------------------------------- sheets & dialogs */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(5, 6, 8, .55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); opacity: 0; transition: opacity .25s var(--ease); }
.scrim.in { opacity: 1; }
.sheet { position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 88vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: 0; box-shadow: var(--shadow-lg); transform: translateY(100%); transition: transform .32s var(--ease); padding-bottom: var(--safe-b); }
.sheet.in { transform: none; }
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 8px auto 2px; flex: none; }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 18px; flex: none; }
.sheet-h h3 { margin: 0; flex: 1; font-size: 17px; letter-spacing: -.02em; }
.sheet-b { overflow-y: auto; padding: 4px 18px 18px; -webkit-overflow-scrolling: touch; }
.sheet-f { display: flex; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex: none; }
.sheet-f .btn { flex: 1; }
@media (min-width: 760px) {
  .sheet { left: auto; right: 12px; top: 12px; bottom: 12px; width: 380px; max-height: none; border-radius: 20px; border-bottom: 1px solid var(--line); transform: translateX(110%); }
  .sheet.center { left: 50%; right: auto; top: 50%; bottom: auto; width: min(520px, calc(100vw - 32px)); max-height: 84vh; transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .25s var(--ease), opacity .2s; }
  .sheet.center.in { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
  .sheet.in { transform: none; }
  .sheet.wide { width: 460px; }
}
.toast-wrap { position: fixed; z-index: 95; left: 50%; top: calc(var(--safe-t) + 70px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 14px; border-radius: 12px; background: #0a0b0d; color: #fff; font-size: 13.5px; font-weight: 520; box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, .08); animation: tin .25s var(--ease); display: flex; gap: 8px; align-items: center; }
.toast.error { background: #2a0f0f; border-color: rgba(240, 82, 82, .4); }
.toast.ok { background: #072218; border-color: rgba(43, 227, 160, .35); }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }
.menu { position: fixed; z-index: 70; min-width: 220px; padding: 6px; border-radius: 15px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); animation: tin .16s var(--ease); max-height: 80vh; overflow-y: auto; }
.menu button { display: flex; align-items: center; gap: 11px; width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; font-size: 14px; font-weight: 520; text-align: left; color: var(--text-2); }
.menu button:hover { background: var(--panel-3); color: var(--text); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .mh { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.menu kbd { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }

/* layers */
.layer { display: flex; align-items: center; gap: 4px; padding: 6px 4px 6px 8px; border-radius: 13px; border: 1px solid transparent; }
.layer.cur { background: var(--accent-soft); border-color: var(--accent-line); }
.layer .sw { width: 26px; height: 26px; border-radius: 8px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.layer .nm { flex: 1; min-width: 0; text-align: left; padding: 4px 6px; }
.layer .nm b { display: block; font-weight: 580; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer .nm small { display: block; font-size: 11.5px; color: var(--muted); }
.layer .icon-btn { width: 34px; height: 34px; }
.layer .icon-btn.off { color: var(--faint); }

/* properties */
.props { display: flex; flex-direction: column; gap: 4px; }
.pgroup { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 14px 0 4px; }
.prow { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 10px; min-height: 40px; }
.prow > label { font-size: 13px; color: var(--muted); }
.prow .ro { font-family: var(--mono); font-size: 13px; color: var(--text-2); padding: 0 10px; }
.colorbtn { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); font-size: 13.5px; width: 100%; text-align: left; }
.colorbtn i { width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); flex: none; }
.aci { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.aci button { aspect-ratio: 1; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.aci button.on { outline: 2px solid #fff; outline-offset: 1px; z-index: 1; }
.aci9 { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; margin-bottom: 12px; }
.aci9 button { aspect-ratio: 1; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.aci9 button.on { outline: 2px solid var(--accent); outline-offset: 2px; }

/* keypad */
.keypad .disp { display: flex; gap: 8px; margin-bottom: 12px; }
.keypad .disp label { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-radius: 13px; background: var(--bg-2); border: 1px solid var(--line-2); text-align: left; }
.keypad .disp label.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.keypad .disp label span { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.keypad .disp label b { font: 600 22px/1.2 var(--mono); min-height: 27px; letter-spacing: -.01em; }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keys button { height: 54px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); font: 600 20px var(--mono); }
.keys button:active { background: var(--panel-3); transform: scale(.97); }
.keys button.fn { font-family: var(--font); font-size: 14px; font-weight: 620; color: var(--text-2); }
.keys button.go { background: var(--accent); border-color: transparent; color: #fff; font-family: var(--font); font-size: 16px; }

/* pattern / block pickers */
.pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.pickgrid button { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; font-size: 12px; font-weight: 560; color: var(--text-2); }
.pickgrid button canvas, .pickgrid button .pv { width: 100%; aspect-ratio: 1; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.pickgrid button.on canvas, .pickgrid button.on .pv { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.history { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--text-2); }
.history div.cmd { color: var(--accent-2); }
.history div.result { color: var(--mint); }

.loader { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { position: fixed; inset: 0; z-index: 80; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(8, 9, 11, .7); backdrop-filter: blur(4px); color: #fff; font-weight: 560; }
.progress .bar { width: 220px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
