/* WASecret Sheets. Uses the shared Bloom tokens from ../shared/theme.css. */
html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; height: 100dvh; }
/* Sheets' own line icons (top bar, toolbar, formula bar, grid and charts, tabs, menus, comment pop-ups, gallery and
   the sheet's own panel sections). Not the shared editor frame or the left-rail kit: they draw their own pictures
   (shapes, thumbnails, the drawing layer). :where() keeps the specificity of a plain svg rule. */
:where(#oldTop, #toolbar, #fbar, #stage, .tabs-bar, .menu, .comment-pop, #gallery, .sp) svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.top { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; }
.brand-text b { color: var(--accent); font-weight: 750; }
.name-input { border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; font: 600 15px/1.2 system-ui, sans-serif; color: var(--fg); background: transparent; min-width: 80px; width: 220px; }
.name-input:hover { border-color: var(--line); }
.name-input:focus { outline: none; border-color: var(--accent); background: #fff; }
.save-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.grow { flex: 1; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 50; max-height: 70vh; overflow: auto; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font: inherit; color: var(--fg); cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu-label { font: 700 11px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; }
.recent button small { display: block; color: var(--muted); font-size: 11px; }
.recent .none { color: var(--muted); padding: 6px 10px; font-size: 13px; }

/* Context toolbar: a floating white pill over the grid (inside the editor frame, or on its own). */
.toolbar.pill { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 5px 8px; margin: 8px auto 6px; width: max-content; max-width: calc(100% - 16px); background: #fff; border: 1px solid #e6e8f0; border-radius: 14px; box-shadow: 0 2px 10px rgba(27, 33, 51, .08), 0 1px 2px rgba(27, 33, 51, .06); flex-wrap: wrap; position: relative; z-index: 15; box-sizing: border-box; }
.ads-pill .toolbar.pill { margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; flex-wrap: nowrap; width: auto; max-width: none; justify-content: flex-start; }
.ads-formula .fbar { border-bottom: 0; padding: 3px 8px; }
html.ad-shell-on #oldTop { display: none; }
.tgroup { display: flex; align-items: center; gap: 1px; padding-right: 4px; border-right: 1px solid #e6e8f0; }
.tgroup:last-child { border-right: 0; }
.tb { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 7px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--fg); font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
.tb:hover { background: var(--hover); }
.tb:disabled { opacity: .4; cursor: default; background: none; }
.tb[aria-pressed="true"], .tb.on { background: #efedff; border-color: #cfc9ff; color: var(--accent); }
.tb:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }
.tb.magic { color: var(--accent); }
.tb.act { color: var(--accent); font-weight: 650; font-size: 14px; }
.tb.wide svg.dn { width: 14px; height: 14px; }
.t123 { font: 600 13px/1 system-ui, sans-serif; letter-spacing: .02em; }
.dec { font: 650 13px/1 system-ui, sans-serif; }
.wheel { width: 20px; height: 20px; border-radius: 50%; background: conic-gradient(#ef4444, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444); box-shadow: inset 0 0 0 4px var(--fill, transparent), 0 0 0 1px rgba(0,0,0,.08); }
.tb.color.fillc { padding: 0 6px; }
.font-sel { width: 128px; max-width: 128px; height: 32px; }
.size-box { display: inline-flex; align-items: center; border: 1px solid #e1e4ef; border-radius: 9px; height: 32px; overflow: hidden; }
.size-box .tb.sm { min-width: 26px; height: 30px; padding: 0 4px; border-radius: 0; }
.size-box .tb.sm svg { width: 15px; height: 15px; }
.size-input { width: 34px; border: 0; text-align: center; font: 600 13px/1 system-ui, sans-serif; height: 30px; padding: 0; background: transparent; }
.size-input:focus { outline: 2px solid var(--sel); outline-offset: -2px; }
.menu.float { position: fixed; right: auto; z-index: 90; }
.menu button.on { background: #efedff; color: var(--accent); }
.menu button small { color: var(--muted); font-size: 11px; margin-left: 8px; }
.menu button:disabled { opacity: .45; cursor: default; }
.menu.icons button { display: flex; align-items: center; gap: 10px; }
.tb b, .tb i { font-size: 15px; font-family: Georgia, serif; }
.tb.color { flex-direction: column; gap: 1px; padding: 3px 6px; }
.tb.color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.a-mark { font: 700 14px/1 Georgia, serif; }
.swatch { width: 16px; height: 3px; border-radius: 2px; background: #c0392b; }
#fillSwatch { background: #fde68a; }
.clear-mark { font: 700 13px/1 Georgia, serif; }
.clear-mark s { font-size: 10px; color: #c0392b; }
.tsel { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font: inherit; font-size: 13px; background: #fff; max-width: 170px; }

.fbar { display: flex; align-items: center; gap: 6px; padding: 5px 10px; background: #fff; border-bottom: 1px solid #e6e8f0; box-sizing: border-box; }
.name-box { width: 92px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: 600 13px/1 ui-monospace, Menlo, Consolas, monospace; }
.fx { font: italic 600 15px/1 Georgia, serif; color: #1b2133; padding: 0 6px; }
.formula-input { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 8px; padding: 7px 9px; font: 13px/1.2 ui-monospace, Menlo, Consolas, monospace; background: transparent; }
.formula-input:hover { border-color: #e6e8f0; }
.name-box:focus, .formula-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 76, 240, .12); }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; }
body.shelled .stage { height: 100%; }
body.shelled #oldTop { display: none; }
.work { flex: 1; min-height: 0; display: flex; position: relative; }
.grid { flex: 1; min-width: 0; display: grid; grid-template-columns: 46px 1fr; grid-template-rows: 30px 1fr; background: #fff; position: relative; overflow: hidden; }
.corner { grid-area: 1 / 1; background: #fff; border-right: 1px solid #e3e5ee; border-bottom: 1px solid #e3e5ee; cursor: pointer; position: relative; }
.corner::after { content: ""; position: absolute; left: 50%; top: 50%; width: 11px; height: 11px; margin: -6.5px 0 0 -6.5px; border: 1.5px solid #64748b; border-radius: 50%; }
.colhead, .rowhead { position: relative; overflow: hidden; background: #fff; user-select: none; }
.colhead { grid-area: 1 / 2; border-bottom: 1px solid #d9dcea; }
.rowhead { grid-area: 2 / 1; border-right: 1px solid #d9dcea; }
.hin { position: absolute; left: 0; top: 0; will-change: transform; }
.h { position: absolute; box-sizing: border-box; display: flex; align-items: center; justify-content: center; font: 500 12.5px/1 system-ui, sans-serif; color: #3d4560; border-right: 1px solid #e3e5ee; border-bottom: 1px solid #e3e5ee; cursor: pointer; }
.colhead .h { height: 30px; top: 0; }
.rowhead .h { width: 46px; left: 0; }
.h.on { background: #efecff; color: #4c3fd6; font-weight: 650; }
.h.frz { background: #fff; z-index: 2; box-shadow: 0 2px 0 #cbd5e1; }
.h.frz.on { background: #efecff; }
.h.filtered::after { content: "▾"; margin-left: 4px; color: var(--accent); }
.h.hidden-above { box-shadow: inset 0 2px 0 var(--accent); }
.scroller { grid-area: 2 / 2; overflow: auto; position: relative; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.spacer { position: relative; }
.cells { position: absolute; left: 0; top: 0; }
.spacer { --z: 1; }
.c { position: absolute; box-sizing: border-box; border-right: 1px solid #e8eaf2; border-bottom: 1px solid #e8eaf2; padding: 0 5px; font: 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: calc(13px * var(--z)); white-space: pre; overflow: hidden; display: flex; align-items: flex-end; padding-bottom: calc(4px * var(--z)); color: #1b2133; }
.grid.nogrid .c { border-right-color: transparent; border-bottom-color: transparent; }
.border-opts { display: flex; gap: 6px; align-items: center; padding: 4px 8px; }
.border-opts .bcol input { width: 34px; height: 28px; padding: 0; border: 1px solid #cbd5e1; border-radius: 6px; background: none; }
.menu-check { display: flex; gap: 8px; align-items: center; padding: 8px 10px; font-size: 13.5px; cursor: pointer; }
.c.vt { align-items: flex-start; padding-top: 3px; }
.c.vm { align-items: center; padding-bottom: 0; }
.c.mg { z-index: 1; background: #fff; }
.c.frz { z-index: 2; background-color: #fff; border-bottom-color: #cbd5e1; }
.c.cm::after { content: ""; position: absolute; right: 0; top: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent #f97316 transparent transparent; }
.c.lk > span { color: #1d4ed8; text-decoration: underline; text-underline-offset: 2px; }
.c.dd { padding-right: 18px; }
.c.dd::before { content: "▾"; position: absolute; right: 5px; bottom: calc(5px * var(--z)); font-size: 10px; color: #94a3b8; }
.pill { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; border-radius: 99px; padding: 1px 9px; font-weight: 600; font-size: .92em; line-height: 1.5; color: #1b2133; }
.c.ci { justify-content: center; align-items: center; padding: 2px; gap: 4px; }
.c.ci .cimg { max-width: 100%; max-height: 100%; object-fit: contain; flex: 0 1 auto; min-width: 0; }
.c.ci.cover { padding: 0; }
.c.ci.cover .cimg { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; }
.c.frzc { z-index: 2; background-color: #fff; border-right-color: #cbd5e1; }
.dd-btn { position: absolute; z-index: 9; width: 20px; height: 20px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 11px; line-height: 1; cursor: pointer; padding: 0; color: #334155; box-shadow: 0 1px 3px rgba(27, 33, 51, .12); }
.dd-btn:hover { background: #f5f3ff; border-color: #a5b4fc; }
.date-btn { font-size: 12px; }
.err-chip { position: absolute; z-index: 9; max-width: 340px; background: #fff7ed; border: 1px solid #fdba74; border-radius: 10px; padding: 6px 9px; font: 12.5px/1.4 system-ui, sans-serif; color: #7c2d12; box-shadow: 0 4px 14px rgba(27, 33, 51, .12); }
.err-chip b { color: #c2410c; }
.err-chip button { display: block; margin-top: 5px; border: 1px solid #fb923c; background: #fff; color: #9a3412; border-radius: 99px; padding: 3px 10px; font: 600 12px/1.3 system-ui, sans-serif; cursor: pointer; }
.err-chip button:hover { background: #ffedd5; }
.date-pick { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; z-index: 10; }
.date-pick.show { width: 170px; height: 32px; opacity: 1; pointer-events: auto; border: 1px solid #c7d2fe; border-radius: 8px; padding: 0 8px; background: #fff; box-shadow: 0 4px 14px rgba(27, 33, 51, .15); }
.link-chip { position: absolute; z-index: 9; background: #fff; border: 1px solid #c7d2fe; border-radius: 99px; padding: 3px 10px; font: 600 12px/1.4 system-ui, sans-serif; color: #1d4ed8; text-decoration: none; box-shadow: 0 2px 8px rgba(27, 33, 51, .12); white-space: nowrap; }
.link-chip:hover { background: #eef2ff; }
.qc-btn { flex: none; height: 30px; border: 1px solid #e6e8f0; border-radius: 8px; background: #fff; padding: 0 10px; font: 600 12.5px/1 system-ui, sans-serif; color: #3d4560; cursor: pointer; white-space: nowrap; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.qc-btn:hover { background: var(--hover); }
.menu button b { font-weight: 700; }
.bulk-prev { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.bulk-card { border: 1px solid #e6e8f0; border-radius: 10px; overflow: hidden; background: #f8fafc; }
.bulk-card svg { width: 100%; height: auto; display: block; stroke: none; }
.spacer.painting, .spacer.painting .c { cursor: copy; }
.c > span { min-width: 0; overflow: hidden; flex: 1; }
.c.n > span { text-align: right; }
.c.mid > span { text-align: center; }
.c.e { color: #c0392b; }
.c.e > span { text-align: center; }
.c.w { white-space: pre-wrap; overflow-wrap: anywhere; align-items: flex-start; padding-top: 3px; line-height: 1.3; }
.c.ov { overflow: visible; z-index: 1; border-right-color: transparent; }
.c.ov > span { overflow: visible; }
.c.spill { color: #3d4560; }
.sel { position: absolute; box-sizing: border-box; border: 1px solid var(--accent); background: rgba(91, 76, 240, .07); pointer-events: none; z-index: 3; }
.active-cell { position: absolute; box-sizing: border-box; border: 2px solid var(--accent); pointer-events: none; z-index: 4; border-radius: 1px; }
.fill-handle { position: absolute; right: -5px; bottom: -5px; width: 9px; height: 9px; background: var(--accent); border: 2px solid #fff; border-radius: 2px; cursor: crosshair; pointer-events: auto; z-index: 6; touch-action: none; }
.fill-preview { position: absolute; box-sizing: border-box; border: 2px dashed var(--accent); pointer-events: none; z-index: 5; }
.copy-ants { position: absolute; box-sizing: border-box; border: 2px dashed #14b8a6; pointer-events: none; z-index: 4; animation: ants 1s linear infinite; }
@keyframes ants { 50% { border-color: #0e7f72; } }
.cell-input { position: absolute; z-index: 8; box-sizing: border-box; margin: 0; border: 2px solid var(--accent); border-radius: 2px; padding: 3px 4px; font: 13px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: calc(13px * var(--z)); color: #1b2133; background: #fff; resize: none; overflow: hidden; white-space: pre; box-shadow: 0 6px 18px rgba(27, 33, 51, .18); outline: none; }
.cell-input.idle { opacity: 0; pointer-events: none; width: 2px !important; height: 2px !important; border: 0; padding: 0; box-shadow: none; caret-color: transparent; }
.fn-hint { position: absolute; z-index: 9; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 220px; max-width: 360px; font-size: 12.5px; }
.fn-hint button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 8px; border-radius: 7px; cursor: pointer; font: inherit; }
.fn-hint button:hover, .fn-hint button.on { background: var(--hover); }
.fn-hint b { font-family: ui-monospace, Menlo, Consolas, monospace; }
.fn-hint small { display: block; color: var(--muted); }
.fn-hint .syntax { padding: 5px 8px; }

.chart-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 7; transform-origin: 0 0; }
.chart-body.pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.comment-pop { position: fixed; z-index: 95; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; }
.comment-head { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.comment-head b { color: var(--fg); }
.comment-pop textarea { width: 100%; box-sizing: border-box; min-height: 74px; border: 1px solid #d9dcea; border-radius: 9px; padding: 8px; font: 13px/1.4 system-ui, sans-serif; resize: vertical; }
.comment-pop .actions { margin-top: 8px; }
body[data-mode="view"] .toolbar.pill, body[data-mode="comment"] .toolbar.pill .tgroup:not(:nth-child(5)) { opacity: .45; pointer-events: none; }

/* Panels for the editor frame: Elements, Text, Tools. */
.sp { display: flex; flex-direction: column; gap: 8px; }
.sp-h { margin: 10px 0 2px; font: 700 14px/1.2 system-ui, sans-serif; color: var(--fg); }
.sp-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.sp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 1px solid #e6e8f0; border-radius: 12px; background: #fff; cursor: pointer; font: 600 12.5px/1.2 system-ui, sans-serif; color: var(--fg); }
.sp-tile:hover, .sp-tile:focus-visible { border-color: #cfc9ff; background: #faf9ff; outline: none; }
.sp-tile svg { width: 64px; height: 46px; stroke-width: 1.5; }
.sp-emoji { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sp-emoji button { height: 44px; border: 1px solid #e6e8f0; border-radius: 10px; background: #fff; font-size: 22px; cursor: pointer; }
.sp-emoji.sym button { font-size: 18px; color: #334155; }
.sp-emoji button:hover { background: #f5f3ff; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-chips button { border: 0; border-radius: 99px; padding: 7px 12px; font: 650 12.5px/1 system-ui, sans-serif; cursor: pointer; }
.sp-wide { text-align: left; border: 1px solid #e6e8f0; border-radius: 12px; background: #fff; padding: 10px 12px; cursor: pointer; font: 13px/1.3 system-ui, sans-serif; }
.bar-demo { color: #5b4cf0; display: block; letter-spacing: -1px; }
.sp-text { display: flex; flex-direction: column; gap: 8px; }
.sp-text button { text-align: left; border: 1px solid #e6e8f0; border-radius: 10px; background: #fff; padding: 12px 14px; cursor: pointer; color: var(--fg); font-family: system-ui, sans-serif; }
.sp-text button:hover { border-color: #cfc9ff; background: #faf9ff; }
.ts-heading { font-size: 24px; font-weight: 800; }
.ts-subheading { font-size: 17px; font-weight: 700; }
.ts-body { font-size: 13px; }
.ts-band { background: #5b4cf0 !important; color: #fff !important; font-weight: 700; font-size: 16px; }
.ts-header { background: #ece9ff !important; color: #2a2373 !important; font-weight: 700; border-bottom: 2px solid #5b4cf0 !important; }
.ts-note { font-size: 11.5px; font-style: italic; color: #64748b !important; }
.ts-total { font-weight: 700; background: #f3f4fb !important; border-top: 2px solid #334155 !important; }
.sp-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sp-fonts button { border: 1px solid #e6e8f0; border-radius: 10px; background: #fff; padding: 9px; cursor: pointer; font-size: 14px; }
.sp-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-tools button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 1px solid #e6e8f0; border-radius: 12px; background: #fff; cursor: pointer; font: 600 12.5px/1.2 system-ui, sans-serif; color: var(--fg); }
.sp-tools button:hover { border-color: #cfc9ff; background: #faf9ff; }
.sp-tools svg { width: 22px; height: 22px; color: var(--accent); }
.sp-search { border: 1px solid #d9dcea; border-radius: 10px; padding: 9px 10px; font: inherit; font-size: 13px; }
.sp-fn { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sp-fn button { width: 100%; text-align: left; border: 0; background: none; border-radius: 9px; padding: 7px 8px; cursor: pointer; font: 13px/1.3 system-ui, sans-serif; }
.sp-fn button:hover { background: #f5f3ff; }
.sp-fn b { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); }
.sp-fn small { display: block; color: var(--muted); }
.chart { position: absolute; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; touch-action: none; }
.chart:focus-within, .chart.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 76, 240, .15), var(--shadow); }
.chart-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-bottom: 1px solid var(--line); background: #fafaff; cursor: move; }
.chart-title { flex: 1; min-width: 40px; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; font: 650 13px/1.2 system-ui, sans-serif; background: transparent; }
.chart-title:focus { border-color: var(--accent); background: #fff; outline: none; }
.chart-bar select { height: 26px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; background: #fff; }
.chart-bar button { height: 26px; min-width: 26px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font: 600 11.5px/1 system-ui, sans-serif; cursor: pointer; padding: 0 6px; }
.chart-bar button:hover { background: var(--hover); }
.chart-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.chart-body svg { width: 100%; height: 100%; stroke: none; }
.chart-body .msg { color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }
.chart-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, #b9b3f7 50%); border-bottom-right-radius: 14px; }
/* Floating text boxes (Text panel): no card, a dashed outline on hover, the move bar above while in use. */
.chart.tbox { background: transparent; border: 1px dashed transparent; border-radius: 6px; box-shadow: none; overflow: visible; }
.chart.tbox:hover { border-color: #c9c3f7; }
.chart.tbox:focus-within, .chart.tbox.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 76, 240, .15); }
.chart.tbox .tbox-bar { position: absolute; left: -1px; bottom: 100%; margin-bottom: 4px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); visibility: hidden; }
.chart.tbox:hover .tbox-bar, .chart.tbox:focus-within .tbox-bar { visibility: visible; }
.tbox-grip { font: 600 11px/1 system-ui, sans-serif; color: var(--muted); padding: 0 4px; }
.chart.tbox .tbox-body { display: block; flex: none; padding: 6px; min-height: 1.25em; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.chart.tbox .chart-resize { width: 12px; height: 12px; border-bottom-right-radius: 6px; visibility: hidden; }
.chart.tbox:hover .chart-resize, .chart.tbox:focus-within .chart-resize { visibility: visible; }

.side { width: 360px; flex: none; border-radius: 0; border-width: 0 0 0 1px; box-shadow: none; display: flex; flex-direction: column; padding: 0; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.side-head h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.side-body { overflow: auto; padding: 12px 16px 24px; flex: 1; min-height: 0; }
.side-body h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.side-body p { margin: 6px 0; }
.side-body .muted { color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; font-weight: 600; }
.field input[type=text], .field select, .field textarea { border: 1px solid #d9dcea; border-radius: 9px; padding: 8px 9px; font: inherit; font-weight: 400; background: #fff; width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.field.check { flex-direction: row; align-items: center; font-weight: 400; }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pill-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.stat-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: #fff; }
.stat-card h4 { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stat-card h4 small { font: 600 11px/1 system-ui, sans-serif; color: var(--accent); background: #efedff; padding: 4px 7px; border-radius: 99px; text-transform: uppercase; }
.stat-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; margin: 6px 0; }
.stat-card dl div { background: #f7f7fc; border-radius: 8px; padding: 6px 8px; min-width: 0; }
.stat-card dt { font-size: 11px; color: var(--muted); }
.stat-card dd { margin: 2px 0 0; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: #3d4560; }
.trend-up { color: #14866d; } .trend-down { color: #c0392b; }
.suggest { display: flex; align-items: center; gap: 10px; border: 1px dashed #cfc9ff; border-radius: 12px; padding: 9px 10px; margin: 8px 0; background: #fbfaff; }
.suggest div { flex: 1; min-width: 0; font-size: 13px; }
.suggest b { display: block; }
.ai-line { margin-top: 16px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(180deg, #fff, #f8f7ff); border: 1px solid #e4e0ff; font-size: 13px; }
.fn-list { list-style: none; margin: 0; padding: 0; }
.fn-list li { border-bottom: 1px solid var(--line); padding: 9px 0; display: flex; gap: 8px; align-items: flex-start; }
.fn-list li div { flex: 1; min-width: 0; font-size: 13px; }
.fn-list code, .code { font: 12.5px/1.4 ui-monospace, Menlo, Consolas, monospace; background: #f4f3ff; padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.preview { margin-top: 10px; padding: 10px; border-radius: 10px; background: #f7f7fc; font-size: 13px; overflow-wrap: anywhere; }
.preview .bad { color: #c0392b; }
.find-status { min-height: 20px; color: var(--muted); font-size: 13px; }
.filter-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.filter-list label { display: flex; gap: 8px; align-items: center; padding: 4px 6px; font-size: 13px; }
.filter-list label small { margin-left: auto; color: var(--muted); }

.tabs-bar { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--bar); border-top: 1px solid var(--line); min-height: 40px; }
.sheet-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; flex: 1; min-width: 0; }
.sheet-tab { border: 1px solid transparent; background: none; border-radius: 9px; padding: 6px 12px; font: 600 13px/1 system-ui, sans-serif; color: var(--muted); cursor: pointer; white-space: nowrap; }
.sheet-tab:hover { background: var(--hover); }
.sheet-tab[aria-selected="true"] { background: #fff; color: var(--accent); border-color: #cfc9ff; box-shadow: 0 1px 4px rgba(27, 33, 51, .1); }
.sheet-tab input { font: inherit; width: 120px; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 4px; }
.status { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

.ctx-menu { position: fixed; right: auto; top: 0; left: 0; min-width: 210px; z-index: 70; }
.gallery { padding: 18px 20px 22px; width: min(820px, calc(100vw - 32px)); }
.gallery-head { display: flex; justify-content: space-between; align-items: center; }
.gallery-head h2 { margin: 0; font-size: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.card { text-align: left; border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 14px; font: 650 15px/1.3 system-ui, sans-serif; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 120px; transition: transform .15s var(--ease), box-shadow .15s; }
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #cfc9ff; outline: none; }
.card small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.card .mini-svg svg { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid #eef0f6; stroke: none; }
.card .mini { height: 46px; border-radius: 10px; background-image: linear-gradient(#0000 0 0); display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 6px; }
.card .mini i { background: rgba(255, 255, 255, .85); border-radius: 3px; }
.card.blank { justify-content: center; align-items: center; text-align: center; border-style: dashed; color: var(--accent); }

.ad-toast { bottom: 64px; }

/* Phones: compact bar, tools in a scrollable bottom bar, panels as a bottom sheet. */
@media (max-width: 640px) {
  .top { padding: 6px 8px; gap: 6px; }
  .brand-text { display: none; }
  .ad-brand-mark { width: 32px; height: 32px; }
  .name-input { width: auto; flex: 1; min-width: 0; font-size: 14px; }
  .save-state, .grow { display: none; }
  .btn { padding: 7px 10px; font-size: 13px; }
  .toolbar.pill { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; width: auto; max-width: calc(100% - 12px); margin: 6px; }
  .toolbar.pill::-webkit-scrollbar { display: none; }
  .tgroup { flex: none; }
  .fbar { padding: 4px 8px; }
  .name-box { width: 64px; }
  .grid { grid-template-columns: 38px 1fr; }
  .rowhead .h { width: 38px; }
  .side { position: fixed; left: 0; right: 0; bottom: env(safe-area-inset-bottom); width: auto; max-height: 62vh; z-index: 45; border-width: 1px 0 0; border-radius: 18px 18px 0 0; box-shadow: 0 -12px 30px rgba(27, 33, 51, .18); }
  /* In the editor frame the phone sheet sits above the frame's bottom bar and tab strip (like the frame's own sheets),
     so its last buttons are never hidden behind them. */
  body.shelled .side { bottom: calc(var(--ads-bot, 44px) + var(--ads-tabs, 62px) + env(safe-area-inset-bottom)); max-height: min(56dvh, calc(100dvh - var(--ads-top, 52px) - var(--ads-bot, 44px) - var(--ads-tabs, 62px) - 24px)); }
  .ad-toast { bottom: 120px; }
  .fx { padding: 0 2px; }
  .stat-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .menu { max-width: calc(100vw - 16px); }
}
.cf-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.cf-btns .btn { padding: 4px 8px; font-size: 12.5px; }
.dd-rows { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dd-rows li { display: grid; grid-template-columns: 92px 1fr 30px 30px 30px; gap: 4px; align-items: center; }
.dd-rows .dd-c { height: 32px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12.5px; }
.dd-rows .dd-l { height: 32px; padding: 0 8px; border: 1px solid #cbd5e1; border-radius: 6px; }
.dd-rows .btn.sm { padding: 0; height: 30px; }
