/* ═══════════════════════════════════════════════════════════
   Graph Studio — FikraSmart graphing + math simulations (js/tools/graph/)
   Touch first: 44px targets, big inputs, pinch/pan canvas. Chrome follows the app theme,
   the plotting surface stays white so exports match the board.
   ═══════════════════════════════════════════════════════════ */
.fgs-win {
    --fgs-bg: #ffffff;
    --fgs-side: #f4f6fa;
    --fgs-fg: #0f172a;
    --fgs-muted: #64748b;
    --fgs-line: #e2e8f0;
    --fgs-line-strong: #cbd5e1;
    --fgs-accent: #2563eb;
    --fgs-accent-soft: rgba(37, 99, 235, .10);
    --fgs-item: #f1f5f9;
    --fgs-card: #ffffff;
    --fgs-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 1px rgba(15, 23, 42, .03);
    --fgs-math: 'Cambria Math', 'Latin Modern Math', 'Times New Roman', serif;
    --fgs-ui: 'Outfit', 'Cairo', system-ui, -apple-system, sans-serif;
    position: fixed; left: 0; top: 0; z-index: 100001;
    display: none; flex-direction: column;
    min-width: 560px; min-height: 420px;
    background: var(--fgs-bg); color: var(--fgs-fg);
    border: 1px solid var(--fgs-line); border-radius: 20px;
    box-shadow: 0 32px 90px rgba(15, 23, 42, .28), 0 4px 14px rgba(15, 23, 42, .10);
    overflow: hidden; font-family: var(--fgs-ui);
    user-select: none; -webkit-user-select: none;
    opacity: 0; transform: translateY(8px) scale(.985); transition: opacity .18s, transform .18s;
}
.fgs-win.show { display: flex; opacity: 1; transform: none; }
.fgs-win.dragging { transition: none; box-shadow: 0 44px 110px rgba(15, 23, 42, .4); }
.fgs-win.full { border-radius: 0; border: 0; }
[data-theme="dark"] .fgs-win {
    --fgs-bg: #0f172a; --fgs-side: #111c31; --fgs-fg: #e2e8f0; --fgs-muted: #94a3b8;
    --fgs-line: rgba(148, 163, 184, .16); --fgs-line-strong: rgba(148, 163, 184, .3);
    --fgs-item: rgba(148, 163, 184, .10); --fgs-card: #16213a; --fgs-accent-soft: rgba(96, 165, 250, .16);
    --fgs-shadow: none;
}
.fgs-win i.fas, .fgs-win i.far { display: inline-flex; align-items: center; justify-content: center; line-height: 1; width: 1.1em; height: 1em; }

/* ── header ── */
.fgs-head { display: flex; align-items: center; gap: 12px; padding: 0 14px 0 16px; height: 66px; border-bottom: 1px solid var(--fgs-line); background: var(--fgs-bg); cursor: grab; flex: none; }
.fgs-win.dragging .fgs-head { cursor: grabbing; }
.fgs-brand { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.fgs-logo { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-size: 17px; flex: none; background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%); box-shadow: 0 8px 18px rgba(79, 70, 229, .32), inset 0 1px 0 rgba(255, 255, 255, .25); }
.fgs-title { flex: 1 1 0; min-width: 0; max-width: 380px; height: 40px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--fgs-fg); font: 700 17px/1 var(--fgs-ui); padding: 0 10px; cursor: text; transition: background .15s, border-color .15s; }
.fgs-title:hover { background: var(--fgs-item); }
.fgs-title:focus { border-color: var(--fgs-accent); background: var(--fgs-bg); outline: none; box-shadow: 0 0 0 3px var(--fgs-accent-soft); }
.fgs-title::placeholder { color: var(--fgs-muted); font-weight: 600; }
.fgs-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.fgs-tools, .fgs-cta { display: flex; align-items: center; gap: 6px; }
.fgs-tools { padding: 4px; border-radius: 14px; background: var(--fgs-item); }
.fgs-btn { height: 42px; min-width: 42px; padding: 0 14px; border-radius: 11px; border: 1px solid transparent; background: transparent; color: var(--fgs-fg); font: 600 14px var(--fgs-ui); display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, transform .08s, box-shadow .15s; -webkit-tap-highlight-color: transparent; }
.fgs-btn:hover { background: var(--fgs-bg); box-shadow: var(--fgs-shadow); }
.fgs-btn:active { transform: scale(.96); }
.fgs-btn.fgs-icon { width: 42px; padding: 0; font-size: 15px; }
.fgs-btn.fgs-ai-btn { color: #7c3aed; }
.fgs-btn.fgs-ai-btn:hover { background: rgba(124, 58, 237, .12); }
[data-theme="dark"] .fgs-btn.fgs-ai-btn { color: #c4b5fd; }
.fgs-btn.fgs-tpl-btn:hover { color: var(--fgs-accent); }
.fgs-cta .fgs-btn { color: #fff; border-color: transparent; }
.fgs-btn.fgs-live-btn { background: linear-gradient(135deg, #059669, #0d9488); box-shadow: 0 8px 18px rgba(5, 150, 105, .28); }
.fgs-btn.fgs-primary { background: linear-gradient(135deg, #2563eb, #4f46e5); box-shadow: 0 8px 18px rgba(37, 99, 235, .28); }
.fgs-cta .fgs-btn:hover { filter: brightness(1.07); box-shadow: 0 10px 22px rgba(37, 99, 235, .3); }
.fgs-btn.fgs-x { border-radius: 50%; color: var(--fgs-muted); background: var(--fgs-item); }
.fgs-btn.fgs-x:hover { background: #fee2e2; color: #dc2626; }
@media (max-width: 960px) { .fgs-tools .fgs-btn span { display: none; } .fgs-tools .fgs-btn { padding: 0; width: 42px; } }
@media (max-width: 820px) { .fgs-cta .fgs-btn span { display: none; } .fgs-cta .fgs-btn { padding: 0; width: 42px; } }

/* ── body ── */
.fgs-body { flex: 1 1 0; min-height: 0; display: flex; }
.fgs-side { flex: none; display: flex; flex-direction: column; min-width: 220px; border-right: 1px solid var(--fgs-line); background: var(--fgs-side); }
.fgs-split { flex: none; width: 8px; margin: 0 -4px; cursor: col-resize; z-index: 2; touch-action: none; }
.fgs-split:hover { background: var(--fgs-accent-soft); }
.fgs-rows { flex: 1 1 0; min-height: 0; overflow: auto; padding: 10px 10px 0; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.fgs-row { border: 1px solid var(--fgs-line); border-radius: 14px; margin-bottom: 8px; background: var(--fgs-card); box-shadow: var(--fgs-shadow); transition: border-color .15s, box-shadow .15s; }
.fgs-row.focus { border-color: var(--fgs-accent); box-shadow: 0 0 0 3px var(--fgs-accent-soft); }
.fgs-row.has-error { border-color: rgba(220, 38, 38, .45); }
.fgs-row.hidden-item .fgs-in { opacity: .45; text-decoration: line-through; }
.fgs-row-main { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; min-height: 56px; }
.fgs-dot { width: 26px; height: 26px; border-radius: 50%; border: 0; flex: none; cursor: pointer; background: var(--c); box-shadow: 0 0 0 3px var(--fgs-card), 0 0 0 4px var(--c); transition: transform .12s; }
.fgs-dot:hover { transform: scale(1.1); }
.fgs-dot:active { transform: scale(.94); }
.fgs-in { flex: 1 1 0; min-width: 0; height: 44px; border: 0; background: transparent; color: var(--fgs-fg); font: 500 17px/1 var(--fgs-math), var(--fgs-ui); padding: 0 4px; outline: none; }
.fgs-in::placeholder { color: var(--fgs-muted); font: 500 13px var(--fgs-ui); opacity: .85; }
.fgs-eye, .fgs-del { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--fgs-muted); cursor: pointer; font-size: 14px; flex: none; display: inline-flex; align-items: center; justify-content: center; opacity: .75; transition: background .15s, color .15s, opacity .15s; }
.fgs-row:hover .fgs-eye, .fgs-row:hover .fgs-del, .fgs-row.focus .fgs-eye, .fgs-row.focus .fgs-del { opacity: 1; }
.fgs-eye:hover { background: var(--fgs-item); color: var(--fgs-fg); }
.fgs-del:hover { background: #fee2e2; color: #dc2626; }
.fgs-row-sub:empty { display: none; }
.fgs-row-sub { padding: 0 12px 10px; }
.fgs-err { color: #dc2626; font: 600 12.5px var(--fgs-ui); display: flex; gap: 6px; align-items: center; }
.fgs-val { color: var(--fgs-muted); font: 600 13.5px var(--fgs-ui); direction: ltr; text-align: left; letter-spacing: .01em; word-break: break-word; }
/* slider */
.fgs-slider { display: flex; align-items: center; gap: 8px; }
.fgs-slider input[type=range] { flex: 1 1 0; min-width: 0; height: 44px; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; touch-action: pan-y; }
.fgs-slider input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #3b82f6, #8b5cf6); }
.fgs-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -13px; border-radius: 50%; background: #fff; border: 3px solid var(--fgs-accent); box-shadow: 0 3px 8px rgba(15, 23, 42, .22); cursor: grab; }
.fgs-slider input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #60a5fa; }
.fgs-slider input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid var(--fgs-accent); }
.fgs-sl-min, .fgs-sl-max { font: 600 12px var(--fgs-ui); color: var(--fgs-muted); min-width: 22px; text-align: center; direction: ltr; }
.fgs-sl-name { font: 700 14px var(--fgs-ui); color: var(--fgs-accent); direction: ltr; min-width: 58px; text-align: center; padding: 0 8px; height: 32px; line-height: 32px; border-radius: 9px; background: var(--fgs-accent-soft); white-space: nowrap; flex: none; }
.fgs-play, .fgs-range-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--fgs-line); background: var(--fgs-card); color: var(--fgs-fg); cursor: pointer; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.fgs-play:hover, .fgs-range-btn:hover { border-color: var(--fgs-line-strong); }
.fgs-play.on { background: var(--fgs-accent); color: #fff; border-color: transparent; }
.fgs-range { display: flex; gap: 8px; margin-top: 8px; }
.fgs-range[hidden], .fgs-pop[hidden] { display: none; }
.fgs-range label { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; font: 600 11px var(--fgs-ui); color: var(--fgs-muted); }
.fgs-range input { width: 100%; min-width: 0; box-sizing: border-box; height: 36px; border: 1px solid var(--fgs-line); border-radius: 9px; background: var(--fgs-bg); color: var(--fgs-fg); padding: 0 8px; font: 500 14px var(--fgs-ui); direction: ltr; }
/* side footer */
.fgs-add { margin: 2px 10px 8px; height: 46px; border-radius: 12px; border: 1.5px dashed rgba(37, 99, 235, .45); background: transparent; color: var(--fgs-accent); font: 700 14px var(--fgs-ui); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; transition: background .15s, border-color .15s; }
.fgs-add:hover { background: var(--fgs-accent-soft); border-color: var(--fgs-accent); }
.fgs-sidefoot { display: flex; gap: 8px; padding: 0 10px 10px; flex: none; }
.fgs-mini { height: 38px; flex: 1 1 0; border-radius: 10px; border: 1px solid var(--fgs-line); background: var(--fgs-card); color: var(--fgs-muted); font: 600 12.5px var(--fgs-ui); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; box-shadow: var(--fgs-shadow); }
.fgs-mini:hover { color: var(--fgs-fg); border-color: var(--fgs-line-strong); }
.fgs-mini.on { color: var(--fgs-accent); border-color: var(--fgs-accent); background: var(--fgs-accent-soft); }

/* ── stage ── */
.fgs-stage { flex: 1 1 0; min-width: 0; position: relative; background: #fff; overflow: hidden; }
.fgs-canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.fgs-zoom { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; background: rgba(255, 255, 255, .94); border: 1px solid rgba(100, 116, 139, .22); border-radius: 14px; box-shadow: 0 8px 24px rgba(15, 23, 42, .14); backdrop-filter: blur(8px); overflow: hidden; }
.fgs-zbtn { width: 44px; height: 44px; border: 0; border-bottom: 1px solid rgba(100, 116, 139, .16); background: transparent; color: #0f172a; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; -webkit-tap-highlight-color: transparent; transition: background .12s, color .12s; }
.fgs-zbtn:last-child { border-bottom: 0; }
.fgs-zbtn:hover { background: rgba(37, 99, 235, .08); color: var(--fgs-accent); }
.fgs-zbtn:active { background: rgba(37, 99, 235, .16); }
.fgs-pop { position: absolute; top: 12px; right: 12px; width: min(440px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; background: var(--fgs-bg); color: var(--fgs-fg); border: 1px solid var(--fgs-line); border-radius: 18px; box-shadow: 0 24px 64px rgba(15, 23, 42, .24); padding: 14px; z-index: 5; animation: fgs-pop .16s ease-out; }
@keyframes fgs-pop { from { transform: translateY(-6px) scale(.98); } }   /* no opacity: a paused animation (background tab) must not hide the panel */
.fgs-pop-head { font: 700 15px var(--fgs-ui); margin: 2px 4px 12px; display: flex; align-items: center; gap: 8px; }
.fgs-tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.fgs-tpl-item { min-height: 60px; border-radius: 14px; border: 1px solid var(--fgs-line); background: var(--fgs-card); color: var(--fgs-fg); padding: 8px 10px; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; font: 600 13px/1.25 var(--fgs-ui); transition: border-color .15s, background .15s, transform .08s; }
.fgs-tpl-item i { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); flex: none; font-size: 13px; }
.fgs-tpl-item:hover { border-color: var(--fgs-accent); background: var(--fgs-accent-soft); }
.fgs-tpl-item:active { transform: scale(.98); }
.fgs-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 4px 6px; border-bottom: 1px solid var(--fgs-line); font: 600 14px var(--fgs-ui); }
.fgs-opt:last-of-type { border-bottom: 0; }
.fgs-opt input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--fgs-accent); }
.fgs-opt select { height: 38px; border-radius: 10px; border: 1px solid var(--fgs-line); background: var(--fgs-bg); color: var(--fgs-fg); padding: 0 10px; font: 600 14px var(--fgs-ui); }
.fgs-seg { display: inline-flex; border: 1px solid var(--fgs-line); border-radius: 10px; overflow: hidden; background: var(--fgs-item); padding: 2px; gap: 2px; }
.fgs-seg button { height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--fgs-fg); font: 600 13px var(--fgs-ui); cursor: pointer; }
.fgs-seg button.on { background: var(--fgs-card); color: var(--fgs-accent); box-shadow: var(--fgs-shadow); }
.fgs-set .fgs-mini { margin-top: 12px; height: 42px; width: 100%; }

/* ── AI card ── */
.fgs-ai { position: absolute; inset: 0; z-index: 6; display: flex; align-items: flex-start; justify-content: center; padding: 18px; background: rgba(15, 23, 42, .22); backdrop-filter: blur(3px); }
.fgs-ai[hidden] { display: none; }
.fgs-ai-card { width: min(660px, 100%); background: var(--fgs-bg); color: var(--fgs-fg); border: 1px solid var(--fgs-line); border-radius: 20px; box-shadow: 0 28px 80px rgba(15, 23, 42, .32); padding: 16px; display: flex; flex-direction: column; gap: 12px; animation: fgs-pop .18s ease-out; }
.fgs-ai-head { display: flex; align-items: center; gap: 10px; font: 700 16px var(--fgs-ui); color: #7c3aed; }
[data-theme="dark"] .fgs-ai-head { color: #c4b5fd; }
.fgs-ai-head .fgs-ai-x { margin-left: auto; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--fgs-item); color: var(--fgs-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.fgs-ai-head .fgs-ai-x:hover { background: #fee2e2; color: #dc2626; }
.fgs-ai-text { width: 100%; min-height: 88px; resize: vertical; border: 1px solid var(--fgs-line); border-radius: 14px; background: var(--fgs-item); color: var(--fgs-fg); padding: 12px 14px; font: 500 15px/1.5 var(--fgs-ui); outline: none; }
.fgs-ai-text:focus { border-color: #7c3aed; background: var(--fgs-bg); box-shadow: 0 0 0 3px rgba(124, 58, 237, .15); }
.fgs-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fgs-ai-chips button { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(124, 58, 237, .3); background: rgba(124, 58, 237, .06); color: #6d28d9; font: 600 13px var(--fgs-ui); cursor: pointer; }
.fgs-ai-chips button:hover { background: rgba(124, 58, 237, .14); }
[data-theme="dark"] .fgs-ai-chips button { color: #c4b5fd; }
.fgs-ai-foot { display: flex; justify-content: flex-end; }
.fgs-ai-foot .fgs-btn { color: #fff; background: linear-gradient(135deg, #7c3aed, #4f46e5); box-shadow: 0 8px 18px rgba(124, 58, 237, .3); }

/* ── busy + toast ── */
.fgs-busy { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(255, 255, 255, .8); backdrop-filter: blur(4px); color: #0f172a; font: 700 16px var(--fgs-ui); }
.fgs-busy[hidden] { display: none; }
.fgs-spin { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(124, 58, 237, .2); border-top-color: #7c3aed; animation: fgs-spin .8s linear infinite; }
@keyframes fgs-spin { to { transform: rotate(360deg); } }
.fgs-toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 8; background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 999px; font: 600 14px var(--fgs-ui); box-shadow: 0 12px 32px rgba(15, 23, 42, .3); max-width: 80%; text-align: center; animation: fgs-pop .18s ease-out; }
.fgs-toast[hidden] { display: none; }

/* ── resize corner ── */
.fgs-resize { position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; cursor: nwse-resize; touch-action: none; }
.fgs-resize::after { content: ''; position: absolute; right: 7px; bottom: 7px; width: 10px; height: 10px; border-right: 2px solid var(--fgs-muted); border-bottom: 2px solid var(--fgs-muted); border-radius: 0 0 3px 0; opacity: .6; }
.fgs-win.full .fgs-resize { display: none; }

/* ── tooltips (data-tip) ── */
.fgs-win [data-tip] { position: relative; }
@media (hover: hover) {
    .fgs-win [data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); background: #0f172a; color: #fff; font: 600 12px var(--fgs-ui); padding: 6px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none; z-index: 20; }
    .fgs-zoom [data-tip]:hover::after { left: auto; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
}

/* ── narrow (phones / split view): full-screen window, plot on top, expressions as a bottom sheet ── */
.fgs-win.full { min-width: 0; min-height: 0; }
@media (max-width: 760px) {
    .fgs-win { min-width: 0; min-height: 0; left: 0 !important; top: 0 !important; width: 100% !important; height: var(--app-vh, 100%) !important; border-radius: 0; border: 0; }
    .fgs-head { padding: 0 8px; height: 56px; gap: 6px; }
    .fgs-logo { width: 34px; height: 34px; font-size: 14px; border-radius: 11px; }
    .fgs-title { font-size: 15px; height: 36px; }
    .fgs-actions { gap: 6px; }
    .fgs-tools { padding: 2px; gap: 2px; }
    .fgs-btn { height: 40px; min-width: 40px; width: 40px; border-radius: 10px; }
    .fgs-full-btn { display: none; }
    .fgs-body { flex-direction: column; }
    .fgs-stage { order: 0; flex: 1 1 0; min-height: 160px; }
    .fgs-split { display: none; }
    .fgs-side { order: 1; width: 100% !important; min-width: 0; flex: 0 1 auto; max-height: 52%; border-right: 0; border-top: 1px solid var(--fgs-line); }
    .fgs-rows { flex: 1 1 auto; min-height: 96px; }
    .fgs-resize { display: none; }
    .fgs-zoom { bottom: 10px; right: 10px; flex-direction: row; }
    .fgs-zbtn { border-bottom: 0; border-right: 1px solid rgba(100, 116, 139, .16); }
    .fgs-zbtn:last-child { border-right: 0; }
    .fgs-pop { top: 8px; right: 8px; left: 8px; width: auto; }
    .fgs-tpl-grid { grid-template-columns: 1fr; }
    .fgs-ai { padding: 8px; }
    .fgs-keyboard { gap: 8px; padding: 6px 8px; }
    .fgs-key { height: 38px; font-size: 15px; }
    .fgs-kpane.left, .fgs-kpane.mid { gap: 4px; }
}

/* ═══════════ Live graphs on the board (js/tools/graph/GraphLive.js) ═══════════ */
.fgl-layer { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.fgl-wrap { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: auto; border-radius: 10px; overflow: visible; box-shadow: 0 0 0 1px rgba(100, 116, 139, .25); background: #fff; display: flex; flex-direction: column; }
.fgl-layer.fgl-drawing .fgl-wrap { pointer-events: none; }
.fgl-layer.fgl-dragging .fgl-stage, .fgl-layer.fgl-dragging .fgl-sliders { pointer-events: none; }
.fgl-stage { flex: 1 1 0; min-height: 0; position: relative; border-radius: 10px 10px 0 0; overflow: hidden; }
.fgl-canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.fgl-sliders { flex: none; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 10px; background: rgba(248, 250, 252, .96); border-top: 1px solid rgba(100, 116, 139, .18); border-radius: 0 0 10px 10px; }
.fgl-sliders[hidden] { display: none; }
.fgl-sl { display: flex; align-items: center; gap: 6px; flex: 1 1 240px; min-width: 0; }
.fgl-play { width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(100, 116, 139, .25); background: #fff; color: #0f172a; font-size: 11px; cursor: pointer; flex: none; display: grid; place-items: center; }
.fgl-play.on { background: #2563eb; color: #fff; border-color: transparent; }
.fgl-sl-name { font: 700 13px 'Outfit', sans-serif; color: #2563eb; direction: ltr; white-space: nowrap; min-width: 60px; text-align: center; background: rgba(37, 99, 235, .1); border-radius: 7px; padding: 4px 6px; flex: none; }
.fgl-sl input[type=range] { flex: 1 1 0; min-width: 60px; height: 44px; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; touch-action: pan-y; }
.fgl-sl input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 3px; background: linear-gradient(90deg, rgba(37, 99, 235, .55), rgba(124, 58, 237, .55)); }
.fgl-sl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -12px; border-radius: 50%; background: #fff; border: 3px solid #2563eb; box-shadow: 0 2px 6px rgba(15, 23, 42, .25); cursor: grab; }
.fgl-sl input[type=range]::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 3px solid #2563eb; }
.fgl-small .fgl-sl { flex-basis: 100%; }
/* teacher bar above the frame */
.fgl-bar { position: absolute; bottom: calc(100% + 8px); right: 0; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 12px; background: #0f172a; color: #e2e8f0; box-shadow: 0 8px 24px rgba(15, 23, 42, .3); opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; white-space: nowrap; }
.fgl-wrap.fgl-hover .fgl-bar, .fgl-wrap:focus-within .fgl-bar { opacity: 1; transform: none; }
.fgl-bar::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 10px; }
@media (hover: none) { .fgl-bar { opacity: .94; transform: none; } }
.fgl-name { font: 700 12.5px 'Outfit', 'Cairo', sans-serif; padding: 0 8px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.fgl-small .fgl-name { display: none; }
.fgl-btn { width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: #e2e8f0; cursor: pointer; font-size: 13px; display: grid; place-items: center; }
.fgl-btn:hover { background: rgba(255, 255, 255, .14); }
.fgl-btn.danger:hover { background: #dc2626; color: #fff; }
.fgl-grip { cursor: grab; touch-action: none; }
.fgl-grip:active { cursor: grabbing; }
.fgl-bar-left .fgl-bar { right: auto; left: 0; }
.fgl-bar-below .fgl-bar { bottom: auto; top: calc(100% + 8px); }
.fgl-bar-below .fgl-bar::after { top: auto; bottom: 100%; }
.fgl-resize { position: absolute; right: -13px; bottom: -13px; width: 26px; height: 26px; border-radius: 50%; cursor: nwse-resize; touch-action: none; opacity: 0; transition: opacity .18s; background: #2563eb; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .35); }
.fgl-resize::after { content: ''; position: absolute; inset: -10px; }
.fgl-wrap.fgl-hover .fgl-resize { opacity: 1; }
@media (hover: none) { .fgl-resize { opacity: .9; } }


/* ═══════════ Desmos-style keyboard (full width under the window) ═══════════ */
.fgs-keyboard { display: none; grid-template-columns: 4fr 4fr 2.2fr; gap: 16px; padding: 10px 16px 12px; border-top: 1px solid var(--fgs-line); background: var(--fgs-side); flex: none; }
.fgs-keyboard.on { display: grid; }
.fgs-keyboard[data-mode="abc"], .fgs-keyboard[data-mode="fn"] { grid-template-columns: 1fr; }
.fgs-kpane { display: grid; gap: 6px; }
.fgs-kpane.left, .fgs-kpane.mid { grid-template-columns: repeat(4, 1fr); }
.fgs-kpane.right { grid-template-columns: 1fr 1fr; }
.fgs-kpane.abc, .fgs-kpane.fn { grid-template-columns: repeat(10, 1fr); }
.fgs-key { height: 46px; min-width: 0; border-radius: 10px; border: 1px solid var(--fgs-line); background: var(--fgs-card); color: var(--fgs-fg); font: 500 18px var(--fgs-math), var(--fgs-ui); cursor: pointer; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; -webkit-tap-highlight-color: transparent; box-shadow: 0 1px 0 rgba(15, 23, 42, .08); user-select: none; -webkit-user-select: none; transition: background .1s, transform .06s; }
.fgs-key:hover { border-color: var(--fgs-line-strong); }
.fgs-key:active, .fgs-key.on { background: var(--fgs-accent); color: #fff; border-color: transparent; transform: translateY(1px); box-shadow: none; }
.fgs-key.v { font-style: italic; }
.fgs-key sup { font-size: 11px; font-style: italic; vertical-align: top; position: relative; top: -4px; margin-left: 1px; }
.fgs-key.n { background: var(--fgs-item); font: 600 17px var(--fgs-ui); }
.fgs-key.g { background: var(--fgs-item); font: 600 14px var(--fgs-ui); }
.fgs-key.wide { grid-column: span 2; }
.fgs-key.span4 { grid-column: span 4; }
.fgs-key.enter { background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff; border-color: transparent; font: 600 18px var(--fgs-ui); box-shadow: 0 6px 14px rgba(37, 99, 235, .25); }
.fgs-kpane.fn .fgs-key { font: 500 14px var(--fgs-math), var(--fgs-ui); }
.fgs-kpane.abc .fgs-key { font: 500 17px var(--fgs-math), var(--fgs-ui); font-style: italic; }
.fgs-kpane.abc .fgs-key.g, .fgs-kpane.abc .fgs-key.enter { font-style: normal; }
[data-theme="dark"] .fgs-key { box-shadow: none; }

/* ═══════════ typeset expressions (KaTeX) ═══════════ */
.fgs-math { flex: 1 1 0; min-width: 0; min-height: 44px; display: none; align-items: center; padding: 4px 6px; font-size: 19px; color: var(--fgs-fg); cursor: text; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; }
.fgs-math::-webkit-scrollbar { display: none; }
.fgs-math .katex { font-size: 1.1em; }
.fgs-math .katex-display { margin: 0; }
.fgs-row.has-math:not(.focus) .fgs-in { display: none; }
.fgs-row.has-math:not(.focus) .fgs-math { display: flex; }
.fgs-row.hidden-item .fgs-math { opacity: .45; }
.fgs-row.has-error .fgs-math { color: #dc2626; }
