    /* ========== THEME: CSS variables (no refresh) ========== */
    :root{
      --bg-page:#F8FAFC;
      --card-bg:#fff;
      --card-border:#e5e7eb;
      --card-radius:14px;
      --card-shadow:0 4px 16px rgba(15,23,42,.07);
      --text:#111827;
      --text-muted:#64748b;
      --tab-bg:#e5e7eb;
      --tab-active-bg:#5b2c3a;
      --tab-active-text:#fff;
      --fw-type-active-bg:linear-gradient(135deg, #5b2c3a 0%, #7a4354 100%);
      --fw-type-active-text:#fff;
      --fw-type-active-border:rgba(91,44,58,.4);
      --fw-type-active-shadow:0 1px 3px rgba(91,44,58,.22);
      --btn-primary-bg:#5b2c3a;
      --btn-primary-hover:#7a4354;
      --btn-ghost-bg:#eef2ff;
      --btn-ghost-text:#3730a3;
      --kbd-bg:#f8fafc;
      --kbd-border:#e2e8f0;
      --kbd-key-bg:#fff;
      --kbd-key-shadow:0 1px 2px rgba(0,0,0,.06);
      --input-border:#d1d5db;
      --input-focus:#5b2c3a;
      --divider:#e5e7eb;
      --transition-duration:0.2s;
      /* Default accent: Bordeaux (overridden by setButtonTheme when palette changes) */
      --ai-accent-from:#5b2c3a;
      --ai-accent-to:#7a4354;
      --ai-accent-red:#8b5cf6;
      --ai-glow:rgba(91,44,58,.25);
      --ai-options-card-bg:linear-gradient(135deg, rgba(91,44,58,.08) 0%, rgba(91,44,58,.06) 100%);
      --ai-options-card-border:rgba(91,44,58,.25);
      --ai-options-card-hover:rgba(91,44,58,.1);
      --ai-options-card-active-border:#5b2c3a;
      --ai-btn-hover:#7a4354;
      --btn-gradient-start:#5b2c3a;
      --btn-gradient-end:#7a4354;
      --accent:#5b2c3a;
      --accent-subtle:rgba(91,44,58,.14);
      --btn-secondary-bg:rgba(0,0,0,.05);
      --btn-secondary-tint:rgba(91,44,58,.16);
      --btn-border:rgba(0,0,0,.12);
      --btn-text:#111827;
    }
    html[data-theme="dark"]{
      --bg-page:#0f172a;
      --card-bg:#1e293b;
      --card-border:#3b4a63;
      --card-shadow:0 4px 20px rgba(0,0,0,.25);
      --text:#f1f5f9;
      --text-muted:#94a3b8;
      --tab-bg:#334155;
      --tab-active-bg:#5b2c3a;
      --tab-active-text:#fff;
      --fw-type-active-bg:linear-gradient(135deg, #5b2c3a 0%, #7a4354 100%);
      --fw-type-active-text:#fff;
      --fw-type-active-border:rgba(91,44,58,.45);
      --fw-type-active-shadow:0 0 0 1px rgba(91,44,58,.3);
      --btn-primary-bg:#5b2c3a;
      --btn-primary-hover:#7a4354;
      --btn-ghost-bg:#1e293b;
      --btn-ghost-text:#e2e8f0;
      --kbd-bg:#1e293b;
      --kbd-border:#475569;
      --kbd-key-bg:#334155;
      --kbd-key-shadow:0 1px 3px rgba(0,0,0,.2);
      --input-border:#475569;
      --input-focus:#5b2c3a;
      --divider:#334155;
      --ai-accent-from:#5b2c3a;
      --ai-accent-to:#7a4354;
      --ai-accent-red:#8b5cf6;
      --ai-glow:rgba(91,44,58,.28);
      --ai-options-card-bg:linear-gradient(135deg, rgba(91,44,58,.1) 0%, rgba(91,44,58,.07) 100%);
      --ai-options-card-border:rgba(91,44,58,.3);
      --ai-options-card-hover:rgba(91,44,58,.14);
      --ai-options-card-active-border:#5b2c3a;
      --ai-btn-hover:#7a4354;
      --btn-gradient-start:#5b2c3a;
      --btn-gradient-end:#7a4354;
      --accent:#5b2c3a;
      --accent-subtle:rgba(91,44,58,.2);
      --btn-secondary-bg:rgba(255,255,255,.05);
      --btn-secondary-tint:rgba(91,44,58,.16);
      --btn-border:rgba(255,255,255,.12);
      --btn-text:#e8ecf3;
    }
    /* Dark Mode only: keep all panels/inputs/selects/cards dark – no white blocks */
    html[data-theme="dark"] input:not(#calculator-display),
    html[data-theme="dark"] textarea,
    html[data-theme="dark"] select{
      background:var(--card-bg) !important;
      color:var(--text) !important;
      border-color:var(--card-border) !important;
      box-shadow:none;
    }
    html[data-theme="dark"] input:not(#calculator-display)::placeholder,
    html[data-theme="dark"] textarea::placeholder{
      color:var(--text-muted);
    }
    html[data-theme="dark"] input:not(#calculator-display):focus,
    html[data-theme="dark"] textarea:focus,
    html[data-theme="dark"] select:focus{
      border-color:var(--input-focus) !important;
      box-shadow:0 0 0 2px var(--ai-glow);
      outline:none;
    }
    html[data-theme="dark"] select option{
      background:#1e293b;
      color:#f1f5f9;
    }

    *{box-sizing:border-box}
    html{-webkit-text-size-adjust:100%}
    body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:var(--bg-page);color:var(--text);font-size:14.5px;transition:background var(--transition-duration) ease,color var(--transition-duration) ease}
    main{width:100%;max-width:none;margin:0;padding:16px 20px}

    h1{margin:4px 0 2px 0;font-size:1.3rem;color:var(--text)}
    .main-header-row{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:10px;padding-bottom:10px;border-bottom:1px solid var(--card-border)}
.theme-toggle-wrap{display:flex;gap:4px;flex-shrink:0}
.theme-btn{border:1px solid var(--card-border);background:var(--card-bg);color:var(--text);border-radius:6px;padding:6px 12px;cursor:pointer;font-size:1rem;transition:background var(--transition-duration) ease,border-color var(--transition-duration) ease,opacity var(--transition-duration) ease}
.theme-btn:hover{opacity:.9}
.theme-btn.active{background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));color:var(--tab-active-text);border-color:var(--btn-gradient-start)}
.btn-theme-wrap{display:flex;gap:4px;flex-shrink:0;align-items:center}
.btn-theme-btn{width:26px;height:26px;border-radius:6px;border:2px solid var(--card-border);cursor:pointer;padding:0;transition:transform .15s ease,box-shadow .15s ease}
.btn-theme-btn:hover{transform:scale(1.08);box-shadow:0 2px 8px rgba(0,0,0,.2)}
.btn-theme-btn.active{border-color:var(--text);box-shadow:0 0 0 2px var(--bg-page), 0 0 0 4px var(--text)}
.lang-toggle-wrap{display:flex;gap:4px;flex-shrink:0;align-items:center;flex-wrap:wrap}
.lang-btn{border:1px solid var(--card-border);background:var(--card-bg);color:var(--text);border-radius:6px;padding:5px 10px;cursor:pointer;font-size:0.82rem;font-weight:600;transition:background var(--transition-duration) ease,border-color var(--transition-duration) ease,opacity var(--transition-duration) ease}
.lang-btn:hover{opacity:.9}
.lang-btn.active{background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));color:var(--tab-active-text);border-color:var(--btn-gradient-start)}
.subtitle{margin:0 0 6px 0;font-size:.82rem;color:var(--text-muted);white-space:nowrap}
@media(max-width:480px){.subtitle{white-space:normal}}
    .edu-note-small{font-size:.75rem;color:var(--text-muted);margin-bottom:8px}

    .top-grid{display:grid;gap:14px;align-items:stretch}
    .top-grid .card{margin-bottom:0;min-height:0}
    .main-workspace-card{display:flex;flex-direction:column;min-height:0}
    .main-workspace-tabs{display:none}
    .main-workspace-tab{border:0;border-radius:8px;padding:6px 12px;font-size:.82rem;font-weight:600;cursor:pointer;background:transparent;color:var(--text-muted);transition:background .2s ease,color .2s ease}
    .main-workspace-tab:hover{color:var(--text);background:var(--btn-ghost-bg)}
    .main-workspace-tab[aria-selected="true"]{background:var(--btn-ghost-bg);color:var(--text);border:1px solid var(--card-border)}
    .main-tab-panel{display:flex;flex-direction:column;min-height:0;flex:1}
    .main-tab-panel[hidden]{display:none}
    .main-tab-panel .card-body-wrap{padding:0;margin:0}
    #main-functions-tab-panel.functions-popover-panel{
      position:absolute;bottom:100%;right:0;margin-bottom:8px;
      width:min(420px, calc(100vw - 24px));min-width:280px;max-height:min(70vh, 480px);
      display:flex;flex-direction:column;background:var(--card-bg);border:1px solid var(--card-border);
      border-radius:var(--card-radius);box-shadow:var(--card-shadow);padding:14px 16px;
      z-index:100;overflow:hidden
    }
    #main-functions-tab-panel.functions-popover-panel[hidden]{display:none}
    #main-functions-tab-panel.functions-popover-panel .functions-workspace-panel{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
    #main-functions-tab-panel.functions-popover-panel .fw-body{overflow-y:auto;flex:1;min-height:0}
    .functions-workspace-panel{background:transparent;border:0;border-radius:0;box-shadow:none;display:flex;flex-direction:column;min-height:0;overflow:hidden;transition:background var(--transition-duration) ease,border-color var(--transition-duration) ease}
    .functions-workspace-panel .fw-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 0 10px 0;border-bottom:1px solid var(--card-border);font-weight:700;font-size:.88rem;color:var(--text);flex-shrink:0}
    .functions-workspace-panel .fw-body{flex:1;min-height:0;overflow-y:auto;padding:10px 0 12px 0}
    .fw-type-buttons{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}
    .fw-type-buttons .btn{text-align:left;justify-content:flex-start}
    .fw-type-btn{transition:background 0.2s ease,color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease}
    .fw-type-btn.active{background:var(--fw-type-active-bg);color:var(--fw-type-active-text);border:1px solid var(--fw-type-active-border);font-weight:600;box-shadow:var(--fw-type-active-shadow)}
    .fw-op-btn{transition:background 0.2s ease,color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease}
    .fw-op-btn.active{background:var(--fw-type-active-bg);color:var(--fw-type-active-text);border:1px solid var(--fw-type-active-border);font-weight:600;box-shadow:var(--fw-type-active-shadow)}
    .fw-form-section{margin-top:12px}
    .fw-form-section:empty{display:none}
    .fw-form-section label{display:block;font-size:0.8rem;margin-bottom:4px;color:var(--text-muted)}
    .fw-form-section input,.fw-form-section textarea{width:100%;margin-bottom:8px;padding:6px 8px;border-radius:6px;border:1px solid var(--input-border);font-size:0.85rem}
    .fw-function-list{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px;min-height:0}
    .fw-function-list:empty{display:none}
    .fw-function-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:6px;border:1px solid var(--card-border);background:var(--btn-ghost-bg);font-size:0.8rem;cursor:pointer;color:var(--text)}
    .fw-function-chip:hover{background:var(--input-bg);border-color:var(--text-muted)}
    .fw-function-chip.active{background:var(--accent-subtle);border-color:var(--accent);color:var(--accent)}
    .fw-operations{margin-top:14px;padding-top:12px;border-top:1px solid var(--card-border)}
    .fw-operations:empty{display:none}
    .fw-operations-title{font-size:0.85rem;font-weight:700;margin-bottom:8px;color:var(--text)}
    .fw-operations-btns{display:flex;flex-wrap:wrap;gap:6px}
    .fw-operations-btns .btn{font-size:0.8rem;padding:5px 10px}
    .fw-branch{margin-bottom:12px;padding:8px;background:var(--btn-ghost-bg);border-radius:8px;border:1px solid var(--card-border)}
    .fw-branch-label{font-weight:700;font-size:0.8rem;margin-bottom:6px;color:var(--text)}

    .card{background:var(--card-bg);border:1px solid var(--card-border);border-radius:var(--card-radius);box-shadow:var(--card-shadow);padding:14px 16px;margin-bottom:14px;transition:background var(--transition-duration) ease,border-color var(--transition-duration) ease,box-shadow var(--transition-duration) ease}
    label{font-weight:700;font-size:.86rem}
    .muted{color:var(--text-muted);font-size:.78rem}

    textarea,input[type="text"],input[type="number"]{
      width:100%;padding:8px 10px;border-radius:10px;border:1px solid var(--input-border);
      font-family:"JetBrains Mono",ui-monospace,monospace;font-size:.9rem;background:var(--card-bg);color:var(--text);
      transition:border-color var(--transition-duration) ease,box-shadow var(--transition-duration) ease;
    }
    textarea{min-height:70px}
    #unified-input{min-height:180px;resize:vertical;padding:10px 12px}
    textarea:focus,input:focus{border-color:var(--input-focus);box-shadow:0 0 0 3px var(--ai-glow);outline:none}
    @media(max-width:650px){ textarea,input[type="text"],input[type="number"]{font-size:16px} }
    @media(max-width:650px){ #unified-input{min-height:156px} }

    .row{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-top:10px}
    .guided-mode-cell{display:flex;flex-direction:column;align-items:flex-start;gap:8px;min-width:0}
    .mode-desc{font-size:0.78rem;color:var(--text-muted);max-width:none;text-align:left;line-height:1.35}
    .solve-option-caption{display:block;font-size:0.82rem;color:var(--text-muted);margin-top:0;line-height:1.35;font-weight:400}
    .guided-mode-row{align-items:stretch}
    .guided-mode-row .guided-mode-cell{margin-right:0}

    .btn{border:0;border-radius:6px;padding:6px 12px;font-weight:600;cursor:pointer;font-size:.82rem;touch-action:manipulation;white-space:nowrap;transition:background var(--transition-duration) ease,border-color var(--transition-duration) ease,box-shadow var(--transition-duration) ease,color var(--transition-duration) ease}
    .btn.ghost{background:var(--btn-ghost-bg);color:var(--btn-ghost-text)}
    .btn.ghost:hover:not(:disabled){opacity:.9}
    .btn-secondary-theme{background:var(--btn-secondary-bg);color:var(--btn-text);border:1px solid var(--btn-border);border-radius:12px;padding:0 18px;height:40px;font-weight:600;display:inline-flex;align-items:center;justify-content:center;gap:8px;box-sizing:border-box;cursor:pointer;transition:background .2s ease,border-color .2s ease,color .2s ease}
    .btn-secondary-theme:hover:not(:disabled){opacity:.9;border-color:var(--btn-border)}
    .btn-secondary-theme:disabled{opacity:.55;cursor:not-allowed}
    /* Tool panels + main AI panel: secondary buttons use selection/button theme color */
    .tool-panel .btn-secondary-theme,
    #ai-panel .btn-secondary-theme{background:var(--btn-secondary-tint);color:var(--text);border:1px solid var(--btn-gradient-start)}
    .tool-panel .btn-secondary-theme:hover:not(:disabled),
    #ai-panel .btn-secondary-theme:hover:not(:disabled){background:var(--btn-secondary-tint);border-color:var(--btn-gradient-end);opacity:1}
    .btn:disabled{opacity:.55;cursor:not-allowed}
    .btn.ghost.ai-accent{background:transparent;color:var(--ai-accent-from);border:1px solid rgba(79,70,229,0.45)}
    .btn.ghost.ai-accent:hover:not(:disabled){background:rgba(79,70,229,0.1);color:var(--ai-accent-from)}
    .btn .btn-secondary-hint{display:block;font-size:.72em;color:var(--text-muted);margin-top:1px;line-height:1.25}
    /* Unified action button: Ask AI, Stop AI, Clear, Calculate, Convert, Transform, Venn, etc. */
    .btn-ai-primary{height:40px;padding:0 18px;border-radius:12px;font-weight:600;border:none;color:#fff;background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));box-shadow:0 4px 14px var(--ai-glow);transition:all .2s ease;display:inline-flex;align-items:center;justify-content:center;gap:8px;box-sizing:border-box;cursor:pointer;font-size:.9rem}
    .btn-ai-primary:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 6px 18px var(--ai-glow)}
    .btn-ai-primary:disabled{opacity:.5;cursor:not-allowed}
    .btn-ai-primary:disabled,.btn-ai-primary:disabled *{color:inherit}
    .btn-ai-primary.is-loading{opacity:.95;cursor:wait;pointer-events:none}
    .btn-ai-primary .btn-inline-spinner{width:16px;height:16px;border:2px solid rgba(255,255,255,.35);border-top-color:#fff;border-radius:50%;animation:thinking-spin .7s linear infinite;flex-shrink:0}
    .btn-ai-primary .primary-action-btn-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;position:relative;z-index:1;font-size:18px;line-height:1}
    .btn-ai-primary .primary-action-btn-icon svg{width:100%;height:100%;display:block;color:inherit}

    .action-groups{display:grid;gap:8px;margin-bottom:0}
    .action-group{
      display:flex;flex-direction:column;gap:10px;padding:12px 16px;border:1px solid var(--card-border);
      border-radius:var(--card-radius);background:var(--card-bg);box-shadow:var(--card-shadow)
    }
    .action-group-primary{
      padding:0;gap:8px;border:0;background:transparent;box-shadow:none
    }
    .action-group-learning{
      margin-top:12px;padding:14px 18px;
      border-radius:var(--card-radius);border:1px solid var(--card-border);background:var(--card-bg);box-shadow:var(--card-shadow)
    }
    .action-group-split .action-group-split-inner{display:grid;grid-template-columns:1fr;gap:12px;align-items:start}
    .action-group-split-half{min-width:0}
    .action-group-split .action-group-status-row{border-top:1px solid var(--card-border);margin-top:12px;padding-top:10px;grid-column:1/-1}
    .action-group-split-tools .action-group-row .btn-ai-primary{flex:0 1 auto;min-width:0;height:36px;padding:0 14px;font-size:.8rem;box-shadow:0 1px 5px rgba(0,0,0,.10)}
    .action-group-split-tools .action-group-row .btn-ai-primary:hover:not(:disabled){box-shadow:0 3px 9px rgba(0,0,0,.14)}
    #adaptive-lesson-modal .exam-modal-content{max-width:min(560px,calc(100vw - 32px));max-height:85vh;display:flex;flex-direction:column}
    #adaptive-lesson-modal.adaptive-lesson-modal--fs .exam-modal-content{
      max-width:min(100vw - 16px,100%);width:min(100vw - 16px,100%);max-height:min(100vh - 16px,100%);min-height:min(92vh,100vh - 16px);
      height:auto;border-radius:14px
    }
    #adaptive-lesson-modal.adaptive-lesson-modal--fs .adaptive-lesson-modal-body{padding:0 4px 10px}
    .adaptive-lesson-modal-body{overflow-y:auto;flex:1;min-height:0;padding:4px 2px 12px}
    #structured-output-modal .exam-modal-content,
    #revision-output-modal .exam-modal-content,
    .lesson-plan-modal-hero{
      height:min(118px, 30vw);
      max-height:140px;
      margin:0 0 12px 0;
      border-radius:10px;
      border:1px solid rgba(148,163,184,.22);
      background:url("../images/hub-lesson-plan-art.png") 0 34% / 200% auto no-repeat;
      -webkit-mask-image:linear-gradient(to bottom, #000 0%, #000 84%, transparent 100%);
      mask-image:linear-gradient(to bottom, #000 0%, #000 84%, transparent 100%);
      box-shadow:inset 0 0 24px rgba(99,102,241,0.08);
    }
    .library-concept-scope #hub-card-cognitive-profile.concept-hub-card{
      overflow:visible;
    }
    #lesson-plan-output-modal .exam-modal-content{
      max-width:min(860px,calc(100vw - 32px));min-width:min(320px,calc(100vw - 32px));
      max-height:85vh;display:flex;flex-direction:column;position:relative;overflow:hidden;box-sizing:border-box
    }
    .modal-resize-handle{position:absolute;z-index:12;box-sizing:border-box;background:transparent}
    .modal-resize-handle.modal-resize-n{top:0;left:10px;right:10px;height:8px;cursor:ns-resize}
    .modal-resize-handle.modal-resize-s{bottom:0;left:10px;right:10px;height:8px;cursor:ns-resize}
    .modal-resize-handle.modal-resize-e{top:10px;right:0;bottom:10px;width:8px;cursor:ew-resize}
    .modal-resize-handle.modal-resize-w{top:10px;left:0;bottom:10px;width:8px;cursor:ew-resize}
    .modal-resize-handle.modal-resize-nw{top:0;left:0;width:12px;height:12px;cursor:nwse-resize}
    .modal-resize-handle.modal-resize-ne{top:0;right:0;width:12px;height:12px;cursor:nesw-resize}
    .modal-resize-handle.modal-resize-sw{bottom:0;left:0;width:12px;height:12px;cursor:nesw-resize}
    .modal-resize-handle.modal-resize-se{bottom:0;right:0;width:12px;height:12px;cursor:nwse-resize}
    .structured-output-modal-body,
    .revision-output-modal-body,
    .lesson-plan-output-modal-body{overflow-y:auto;flex:1;min-height:0;padding:4px 2px 12px}
    .action-with-help{display:inline-flex;flex-wrap:nowrap;align-items:center;gap:5px;max-width:100%;vertical-align:middle}
    .action-help-wrap{position:relative;display:inline-flex;align-items:center;flex-shrink:0}
    .action-help-btn{
      width:22px;height:22px;padding:0;border-radius:50%;
      border:1px solid var(--card-border);background:var(--kbd-bg);color:var(--text-muted);
      font-size:.72rem;font-weight:700;line-height:1;cursor:pointer;flex-shrink:0
    }
    .action-help-btn:hover,.action-help-btn:focus-visible{color:var(--text);border-color:var(--btn-primary-bg);outline:none}
    .action-help-popover{
      position:absolute;top:calc(100% + 6px);left:0;
      width:min(320px,calc(100vw - 32px));
      max-width:min(320px,calc(100vw - 32px));
      box-sizing:border-box;
      white-space:normal;
      overflow-wrap:break-word;
      word-wrap:break-word;
      padding:10px 12px;font-size:.82rem;line-height:1.45;color:var(--text);
      background:var(--card-bg);border:1px solid var(--card-border);border-radius:10px;
      box-shadow:0 8px 24px rgba(0,0,0,.14);z-index:120
    }
    .action-help-wrap-inline .action-help-popover{left:auto;right:0}
    .action-help-popover.action-help-popover-preline{white-space:pre-line}
    .matrix-help-popover{padding:11px 13px;font-size:0.83rem;line-height:1.42;color:var(--text)}
    .matrix-help-popover .matrix-help-line{margin:0;padding:0}
    .matrix-help-popover .matrix-help-line + .matrix-help-callout{margin-top:8px;padding-top:8px;border-top:1px solid var(--card-border)}
    .matrix-help-popover .matrix-help-callout{margin:0;padding:0;white-space:pre-line}
    .adaptive-learning-title-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
    .adaptive-learning-title-row .adaptive-learning-title{margin:0}
    @media(max-width:768px){
      .action-group-split .action-group-split-inner{grid-template-columns:1fr}
    }
    .action-group-tools{
      background:linear-gradient(135deg, rgba(255,255,255,.01) 0%, rgba(99,102,241,.02) 100%)
    }
    .action-group-copy{display:flex;flex-direction:column;gap:2px}
    .action-group-title{font-size:.8rem;font-weight:700;letter-spacing:.01em;color:var(--text)}
    .action-group-subtitle{font-size:.75rem;line-height:1.35;color:var(--text-muted)}
    .action-group-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
    .action-group-row .btn-ai-primary,
    .action-group-row .btn-secondary-theme{min-height:36px}
    .action-group-primary .action-group-row .btn-ai-primary{
      flex:0 1 auto;min-width:0;height:36px;padding:0 14px;font-size:.84rem
    }
    .action-group-primary .action-group-row .btn-secondary-theme{
      flex:0 1 auto;min-width:0;height:36px;padding:0 14px;font-size:.84rem;
      border-radius:12px;background:var(--btn-secondary-tint);border:1px solid var(--btn-gradient-start);color:var(--text);
      box-shadow:inset 0 1px 0 rgba(255,255,255,.04)
    }
    .action-group-primary .action-group-row .btn-secondary-theme:hover:not(:disabled){
      background:var(--btn-secondary-tint);border-color:var(--btn-gradient-end);opacity:1
    }
    .action-group-primary .action-group-row{gap:7px}
    .action-group-primary .action-group-row-primary{
      align-items:flex-end;
      flex-wrap:nowrap;
      gap:6px;
      max-width:100%;
      overflow-x:auto;
      -webkit-overflow-scrolling:touch;
    }
    .action-group-learning .action-group-row .btn-ai-primary{
      flex:0 1 auto;min-width:0;height:36px;padding:0 14px;font-size:.8rem;box-shadow:0 1px 5px rgba(0,0,0,.10)
    }
    .action-group-learning .action-group-row .btn-ai-primary:hover:not(:disabled){box-shadow:0 3px 9px rgba(0,0,0,.14)}
    .action-group-tools .action-group-row .btn-ai-primary{
      flex:0 1 auto;min-width:170px;height:36px;padding:0 14px;font-size:.8rem;box-shadow:0 1px 5px rgba(0,0,0,.10)
    }
    .action-group-tools .action-group-row .btn-secondary-theme{flex:0 1 auto;min-width:170px;height:36px;padding:0 14px;font-size:.8rem}
    .action-group-meta{
      display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;min-height:18px
    }
    .action-group-status-row{
      min-height:16px;padding-top:8px;border-top:1px solid var(--card-border)
    }
    .action-group-status-row #status{display:block;font-size:.78rem;line-height:1.35;color:var(--text-muted)}
    .adaptive-learning-wrap{margin-top:4px;padding:0;border:0;background:transparent;box-shadow:none}
    .adaptive-learning-card{
      max-width:720px;margin:0 auto;padding:18px 20px;border:1px solid var(--card-border);border-radius:14px;
      background:linear-gradient(165deg, rgba(99,102,241,.06) 0%, var(--card-bg) 48%);box-shadow:var(--card-shadow)
    }
    .adaptive-learning-head{margin-bottom:6px}
    .adaptive-learning-title{font-size:1.05rem;font-weight:700;color:var(--text);letter-spacing:.01em}
    .adaptive-learning-sub{font-size:.82rem;margin:6px 0 0;line-height:1.4}
    .adaptive-learning-progress-row{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin:10px 0 6px;font-size:.88rem;color:var(--text-muted)}
    .adaptive-learning-dots{display:flex;gap:7px;align-items:center}
    .adaptive-learning-dot{width:11px;height:11px;border-radius:50%;background:var(--text-muted);opacity:.28;transition:opacity .15s,transform .15s}
    .adaptive-learning-dot.filled{opacity:1;background:var(--btn-primary-bg);box-shadow:0 0 0 2px rgba(99,102,241,.2)}
    .adaptive-question-figure{margin:10px 0;text-align:center}
    .adaptive-question-figure-img{
      max-width:min(100%,240px);
      max-height:200px;
      width:auto;
      height:auto;
      object-fit:contain;
      border-radius:8px;
      border:1px solid var(--card-border);
      vertical-align:middle;
    }
    .adaptive-question-body{font-size:1.02rem;line-height:1.55;margin:14px 0;color:var(--text);overflow-wrap:break-word}
    .adaptive-question-body .katex{font-size:1.05em}
    .adaptive-mcq-group{display:flex;flex-direction:column;gap:10px;margin:12px 0}
    .adaptive-mcq-opt{display:flex;align-items:flex-start;gap:8px;cursor:pointer}
    .adaptive-math-input{width:100%;box-sizing:border-box;padding:8px;border-radius:8px;border:1px solid var(--card-border);background:var(--bg);color:var(--text);resize:vertical}
    .adaptive-learning-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px;align-items:center}
    .adaptive-learning-actions .btn{min-height:40px}
    .profile-dash-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:12px}
    @media(max-width:720px){.profile-dash-grid{grid-template-columns:1fr}}
    .profile-dash-card{background:var(--card-bg);border:1px solid var(--card-border);border-radius:var(--card-radius);padding:10px}
    .adaptive-hub-wrap{margin-top:6px}
    .adaptive-hub-head{margin-bottom:14px}
    .adaptive-hub-main-title{font-size:1.08rem;font-weight:700;color:var(--text);letter-spacing:.01em;margin:0;line-height:1.25}
    .adaptive-hub-main-sub{font-size:.82rem;margin:6px 0 0;line-height:1.42;color:var(--text-muted)}
    .adaptive-hub-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
    @media(max-width:640px){.adaptive-hub-grid{grid-template-columns:1fr}}
    .adaptive-hub-card{
      border:1px solid var(--card-border);border-radius:14px;padding:14px 16px 16px;
      background:linear-gradient(165deg, rgba(99,102,241,.08) 0%, var(--card-bg) 52%);
      box-shadow:var(--card-shadow);display:flex;flex-direction:column;gap:8px;min-height:118px;
      transition:border-color .15s, box-shadow .15s, transform .12s
    }
    .adaptive-hub-card:hover{border-color:rgba(99,102,241,.35);box-shadow:0 4px 18px rgba(0,0,0,.08)}
    .adaptive-hub-card--soon{background:linear-gradient(165deg, rgba(99,102,241,.03) 0%, var(--card-bg) 60%);opacity:0.95}
    .adaptive-hub-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
    .adaptive-hub-card-title{font-size:0.95rem;font-weight:700;color:var(--text);line-height:1.28;margin:0}
    .adaptive-hub-card-desc{font-size:0.8rem;margin:0;line-height:1.42}
    .adaptive-hub-badge{font-size:0.72rem;font-weight:600;padding:3px 9px;border-radius:999px;background:var(--kbd-bg);color:var(--text-muted);border:1px solid var(--card-border);white-space:nowrap;flex-shrink:0}
    .adaptive-hub-card-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:auto;padding-top:6px}
    .adaptive-hub-card-actions .btn{min-height:36px;font-size:0.84rem}
    .adaptive-hub-card-actions .btn-ghost-tight{min-height:34px;padding:6px 12px;font-size:0.8rem}
    .profile-stats-row{display:flex;flex-wrap:wrap;gap:10px;margin-top:10px}
    .profile-stat-pill{padding:8px 12px;border-radius:10px;background:var(--tab-bg);font-size:0.9rem}
    .cognitive-test-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.45);display:none;align-items:center;justify-content:center;z-index:10006;padding:12px;box-sizing:border-box}
    .cognitive-test-modal{max-width:720px;width:100%;max-height:92vh;overflow:auto;background:var(--card-bg);border-radius:12px;padding:14px;border:1px solid var(--card-border)}
    .cog-opt-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;margin-top:10px}
    .cog-opt{border:2px solid var(--card-border);border-radius:8px;padding:6px;cursor:pointer;text-align:center}
    .cog-opt.selected{border-color:var(--tab-active-bg);background:rgba(91,44,58,.12)}
    .adaptive-feedback-banner{padding:11px 14px;border-radius:10px;margin-top:12px;font-size:.92rem;line-height:1.45}
    .adaptive-feedback-banner.ok{border:1px solid rgba(34,197,94,.4);background:rgba(34,197,94,.1)}
    .adaptive-feedback-banner.bad{border:1px solid rgba(239,68,68,.38);background:rgba(239,68,68,.09)}
    .adaptive-feedback-banner.neutral{border:1px solid var(--card-border);background:var(--kbd-bg)}
    .adaptive-concept-chip{display:inline-block;padding:5px 12px;border-radius:999px;background:var(--kbd-bg);font-size:.82rem;margin:5px 8px 0 0;color:var(--text)}
    .adaptive-end-highlight{display:flex;flex-direction:column;gap:4px;padding:10px 12px;border-radius:10px;border:1px solid var(--card-border);margin-top:8px;background:var(--kbd-bg)}
    .adaptive-practice-item{padding:12px;border-radius:10px;border:1px solid var(--card-border);margin-top:10px;background:var(--card-bg)}
    .adaptive-textarea{width:100%;min-height:4.5em;padding:10px 12px;border-radius:10px;border:1px solid var(--card-border);background:var(--bg-input, var(--card-bg));color:var(--text);font-size:.95rem;box-sizing:border-box;resize:vertical}
    .action-group #learning-scope-badge{margin-left:0}
    .action-group #thinking-banner{margin-left:auto}
    @media(max-width:900px){
      .action-group-tools .action-group-row .btn-ai-primary,
      .action-group-tools .action-group-row .btn-secondary-theme{min-width:150px}
    }
    @media(max-width:650px){
      .action-group{padding:12px 14px}
      .action-group-primary{justify-self:stretch;width:auto;padding:0}
      .action-group-learning{padding:12px 14px}
      .action-group-primary .action-group-row .btn-ai-primary,
      .action-group-primary .action-group-row .btn-secondary-theme,
      .action-group-learning .action-group-row .btn-ai-primary,
      .action-group-tools .action-group-row .btn-ai-primary,
      .action-group-tools .action-group-row .btn-secondary-theme{flex:1 1 auto;min-width:0}
      .action-group #thinking-banner{margin-left:0}
    }
    .solve-options-row{
      display:grid;grid-template-columns:1fr minmax(0, 0.5fr) minmax(0, 0.5fr) auto;gap:16px;align-items:start;
      margin-top:12px;padding:14px 18px;border:1px solid var(--card-border);border-radius:var(--card-radius);
      background:var(--card-bg);box-shadow:var(--card-shadow)
    }
    .solve-options-row-segment.solve-options-segment-functions{position:relative;justify-content:flex-start;align-items:flex-start}
    .solve-options-row-segment{min-width:0;display:flex;flex-direction:column;gap:6px;justify-content:flex-start}
    .solve-options-row-segment.solve-options-segment-primary{justify-content:flex-start;align-items:flex-start}
    .solve-options-segment-primary .action-group-primary{width:100%;max-width:100%;border:0;background:transparent;box-shadow:none;padding:0;gap:8px}
    .solve-options-row .solve-option-panel{padding:0;border:0;background:transparent;box-shadow:none;gap:6px}
    .solve-options-row .solve-option-panel-title{font-size:.75rem;font-weight:700;letter-spacing:.02em;color:var(--text-muted);margin:0;line-height:1.25}
    .solve-options-row .solve-option-toolbar-row{display:flex;flex-direction:column;align-items:stretch;gap:8px;margin:0;min-width:0}
    .solve-options-row .solve-option-buttons-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0}
    .solve-options-row .solve-option-meta-row{display:flex;flex-wrap:wrap;align-items:center;gap:4px;min-width:0}
    .solve-options-row .solve-option-label-cluster{display:inline-flex;align-items:center;gap:4px;flex:0 1 auto;max-width:100%}
    .solve-options-row .solve-option-help-wrap{flex-shrink:0}
    .solve-mode-help-popover .solve-help-p{margin:0 0 10px;font-size:.82rem;line-height:1.45;color:var(--text)}
    .solve-mode-help-popover .solve-help-p:last-child{margin-bottom:0}
    .solve-mode-help-popover .solve-help-sub{font-size:.78rem;margin-top:6px}
    .solve-options-row .solve-level-group{display:flex;flex-wrap:wrap;gap:8px;align-items:center;flex:0 1 auto;min-width:0;justify-content:flex-start}
    .solve-options-row .solve-level-group .level-btn{min-width:72px;height:40px;padding:0 12px;font-size:.82rem;font-weight:600;border-radius:12px;box-sizing:border-box}
    .solve-options-row .guided-mode-grid{display:flex;flex-wrap:wrap;gap:8px;grid-template-columns:none;align-items:center;flex:0 1 auto;min-width:0;justify-content:flex-start}
    .solve-options-row .guided-mode-card{display:inline-flex;padding:0;gap:0;border:0;border-radius:0;background:transparent;box-shadow:none;min-width:0}
    .solve-options-row .guided-mode-card:hover{transform:none}
    .solve-options-row .guided-mode-card.active{border:0;background:transparent;box-shadow:none}
    .solve-options-row .guided-mode-card .guided-mode-btn{min-width:72px;height:40px;padding:0 12px;font-size:.82rem;font-weight:600;border-radius:12px;border:1px solid var(--card-border);box-sizing:border-box}
    .solve-options-row .mode-desc{display:none}
    @media(max-width:900px){
      .solve-options-row{grid-template-columns:1fr;align-items:stretch;gap:14px;padding:14px 16px}
      .solve-options-row-segment.solve-options-segment-primary{align-items:stretch;justify-content:flex-start}
      .solve-options-row-segment.solve-options-segment-functions{align-items:stretch;justify-content:flex-start}
      .solve-options-row .solve-option-toolbar-row{gap:10px}
      .solve-options-row .solve-level-group,.solve-options-row .guided-mode-grid{width:100%;justify-content:flex-start}
      #main-functions-tab-panel.functions-popover-panel{left:0;right:0;width:auto;max-height:60vh}
    }
    .solve-options-block{
      margin-top:10px;padding:10px 12px;border:1px solid var(--card-border);border-radius:12px;
      background:linear-gradient(135deg, rgba(99,102,241,.05) 0%, rgba(139,92,246,.025) 100%);
      box-shadow:inset 0 1px 0 rgba(255,255,255,.025), 0 2px 8px rgba(15,23,42,.04)
    }
    .solve-options-grid{display:grid;grid-template-columns:minmax(0, .95fr) minmax(0, 1.35fr);gap:10px;align-items:stretch}
    .solve-option-panel{
      display:flex;flex-direction:column;gap:6px;min-width:0;padding:10px 12px;
      border:1px solid var(--card-border);border-radius:12px;background:var(--card-bg)
    }
    .solve-option-panel-title{font-size:.8rem;font-weight:700;letter-spacing:.02em;color:var(--text);margin:0}
    .solve-option-subtext{font-size:.8rem;color:var(--text-muted);line-height:1.35}
    .solve-level-group{display:flex;gap:8px;flex-wrap:wrap}
    .solve-level-group .level-btn{
      min-width:100px;height:40px;border-radius:12px;border:1px solid var(--card-border);
      display:inline-flex;align-items:center;justify-content:center;padding:0 16px;font-size:.9rem;font-weight:600
    }
    .guided-mode-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
    .guided-mode-card{
      display:flex;flex-direction:column;align-items:flex-start;gap:6px;padding:10px 12px;
      border:1px solid var(--card-border);border-radius:12px;background:rgba(255,255,255,.02);
      transition:border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .2s ease
    }
    .guided-mode-card:hover{border-color:var(--accent);box-shadow:0 6px 18px rgba(0,0,0,.10);transform:translateY(-1px)}
    .guided-mode-card .guided-mode-btn{
      width:100%;height:40px;min-height:40px;border-radius:12px;display:inline-flex;align-items:center;justify-content:center;font-size:.9rem;font-weight:600
    }
    .guided-mode-card.active{
      border-color:var(--accent);
      background:var(--accent-subtle);
      box-shadow:0 10px 24px rgba(0,0,0,.10)
    }
    @media(max-width:900px){
      .solve-options-grid{grid-template-columns:1fr}
    }
    @media(max-width:650px){
      .guided-mode-grid{grid-template-columns:1fr}
      .solve-level-group .level-btn{flex:1}
      .solve-options-row .guided-mode-card{flex:1 1 auto;min-width:0}
    }

    .divider{height:1px;background:var(--divider);margin:10px 0}

    #math-preview-box{margin-top:10px;border-radius:var(--card-radius);border:1px solid var(--card-border);padding:12px 14px;background:var(--card-bg);min-height:48px;font-size:.9rem;color:var(--text);min-width:0;max-width:100%;overflow-x:hidden}
    #math-preview{min-height:36px;white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;min-width:0;max-width:100%}
    #math-preview.math-preview-error{color:#b85450;font-size:.85rem;white-space:pre-wrap;word-break:break-all}
    #math-preview-placeholder{color:var(--text-muted);font-size:.75rem}

    /* Choice buttons should not compete with the primary CTA */
    .level-btn.active,.guided-mode-btn.active{background:var(--accent-subtle);color:var(--text);border-color:var(--accent);box-shadow:none}
    .solve-options-row .solve-level-group .level-btn.active,
    .solve-options-row .guided-mode-cell .guided-mode-btn.active{
      background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      color:#fff;
      border:none;
      box-shadow:0 2px 12px var(--ai-glow);
      font-weight:600;
    }
    .solve-options-row .solve-level-group .level-btn.active:hover:not(:disabled),
    .solve-options-row .guided-mode-cell .guided-mode-btn.active:hover:not(:disabled){
      box-shadow:0 4px 16px var(--ai-glow);
      transform:translateY(-1px);
      opacity:1;
    }
    .solutions-count-btn{padding:4px 10px;font-size:0.8rem;}
    .solutions-count-btn.active{background:var(--accent-subtle);color:var(--text);border-color:var(--accent);box-shadow:none}

    #analysis-section{margin-top:10px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg);overflow:hidden}
    #analysis-section summary{font-size:0.9em;font-weight:600;color:var(--text);padding:8px 10px;cursor:pointer;list-style:none;display:flex;align-items:center;gap:6px}
    #analysis-section summary::-webkit-details-marker{display:none}
    #analysis-section summary::before{content:"";display:inline-block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid var(--text-muted);transition:transform .15s}
    #analysis-section[open] summary::before{transform:rotate(-90deg)}
    #analysis-section .analysis-body{padding:8px 10px 10px;border-top:1px solid var(--card-border)}
    #analysis-section .analysis-checkboxes{display:flex;flex-wrap:wrap;gap:8px 14px;font-size:0.85rem;color:var(--text)}
    #analysis-section .analysis-checkboxes label{display:flex;align-items:center;gap:5px;cursor:pointer;white-space:nowrap}
    #analysis-section .analysis-actions{margin-top:8px;font-size:0.8rem}
    #analysis-section .analysis-actions button{background:none;border:none;color:var(--ai-accent-from);cursor:pointer;text-decoration:underline;padding:0 4px}
    #analysis-section .analysis-actions button:hover{color:var(--ai-accent-to)}

    /* Solve options panel: "Ποιο τρόπο θες να συνεχίσεις;" – ίδια κλάση ai-accent με Ask AI / Τετράδιο / Calculator */
    #solve-result-wrap{background:var(--ai-options-card-bg);border:1px solid var(--ai-options-card-border);border-left:4px solid var(--ai-accent-from);box-shadow:0 2px 8px rgba(0,0,0,.06);border-radius:var(--card-radius)}
    #solve-result-wrap label{color:var(--text);font-weight:700}
    .solve-method-card{min-width:120px;text-align:center;padding:10px 14px;white-space:normal}
    .solve-method-card:hover{transform:translateY(-1px)}
    .solve-method-card:active{transform:translateY(0)}
    /* Structured math presentation: πολύ έντονος διαχωρισμός – κάθε μέθοδος σε ξεχωριστό «κάρτα» */
    .solve-method-section{
      margin-top:2em;padding:1.25em 1.25em 1em 1.25em;
      border:1px solid rgba(79,70,229,.18);border-left:4px solid var(--ai-accent-from);
      background:linear-gradient(90deg, rgba(79,70,229,.04) 0%, transparent 18%);
      border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.04);
    }
    .solve-method-section:first-child{margin-top:0;border:1px solid rgba(79,70,229,.2);border-left:4px solid var(--ai-accent-from);background:linear-gradient(90deg, rgba(79,70,229,.06) 0%, transparent 18%);border-radius:8px;padding:1.25em 1.25em 1em 1.25em;box-shadow:0 1px 4px rgba(0,0,0,.04);}
    .solve-method-section-title{font-size:1.05rem;font-weight:700;color:var(--text);margin:0 0 0.5em 0;line-height:1.3;padding-bottom:0.4em;border-bottom:1px solid var(--card-border);}
    .solve-method-section-body{font-size:0.9rem;line-height:1.45;color:var(--text);}
    .solve-method-section-body .step-title{font-weight:700;font-size:0.9rem;margin-top:0.4em;margin-bottom:0.15em;}
    .solve-method-section-body .step-body{margin-bottom:0.35em;white-space:pre-wrap;}

    /* Guided Mode: visual only – friendlier colors, slightly larger hints */
    main:has(.guided-mode-btn[data-guided="true"].active) .muted{font-size:.85em}
    main:has(.guided-mode-btn[data-guided="true"].active) .card{box-shadow:0 6px 16px rgba(15,23,42,.06)}

    .imgwrap{display:grid;gap:8px;margin-top:6px}
    .preview{width:100%;max-height:280px;object-fit:contain;border-radius:12px;border:1px dashed var(--card-border);background:var(--card-bg)}

    .answer{
      white-space:pre-wrap;word-break:break-word;overflow-wrap:break-word;border:1px solid var(--card-border);border-left:4px solid var(--btn-gradient-start);border-radius:14px;padding:14px 16px;min-height:100px;background:var(--card-bg);font-size:.9rem;
      min-width:0;max-width:100%;overflow-x:auto;color:var(--text);transition:border-color var(--transition-duration) ease,background var(--transition-duration) ease;
    }
    .answer .ai-summary-table{border-collapse:collapse;width:100%;margin:8px 0;font-size:inherit;}
    .answer .ai-summary-table th,.answer .ai-summary-table td{border:1px solid var(--card-border);padding:6px 10px;text-align:left;vertical-align:top;word-wrap:break-word;overflow-wrap:break-word;}
    .answer .ai-summary-table th{background:var(--card-bg);font-weight:600;}
    .answer .ai-summary-table td{background:var(--card-bg);}
    @media (max-width: 480px){
      .answer{font-size:.8rem;-webkit-overflow-scrolling:touch;padding:8px}
      .answer .katex{font-size:85% !important}
    }
    .answer-scroll-hint{display:none;font-size:.75rem;color:var(--text-muted);margin-bottom:6px;text-align:center}
    @media (max-width: 480px){.answer-scroll-hint{display:block}}
    .solution-output {
      user-select: text;
      -webkit-user-select: text;
      -ms-user-select: text;
      -webkit-touch-callout: default;
    }
    .solution-output .katex,
    .solution-output .katex * {
      user-select: text !important;
      -webkit-user-select: text !important;
    }
    #answer-card{scroll-margin-top:14px;border-left:4px solid var(--btn-gradient-start);position:relative}
    .answer-header-bar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding:12px 14px;border-bottom:1px solid var(--card-border);background:linear-gradient(135deg, var(--card-bg) 0%, rgba(99,102,241,.03) 100%);border-radius:14px 14px 0 0;min-height:44px;box-sizing:border-box}
    .answer-header-primary{display:flex;align-items:center;flex-wrap:wrap;gap:10px 12px;flex:1;min-width:min(100%,240px)}
    .answer-header-title{margin:0;font-size:1rem;font-weight:700;color:var(--text);line-height:1.25}
    .answer-utility{display:flex;gap:8px;align-items:center;flex-shrink:0;flex-wrap:wrap;justify-content:flex-end}
    .answer-utility .btn{padding:6px 12px;font-size:0.8rem}
    .answer-utility .saved-info{font-size:0.75rem;color:var(--text-muted);white-space:nowrap;max-width:180px;overflow:hidden;text-overflow:ellipsis}
    .verify-badge{display:inline-flex;align-items:center;gap:5px;font-size:0.8rem;font-weight:700;padding:5px 12px;border-radius:999px;border:1px solid var(--card-border);max-width:min(320px,70vw);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:opacity .15s, box-shadow .15s;box-shadow:0 0 0 1px rgba(0,0,0,.04)}
    .answer-header-primary .verify-badge:not(.hidden){flex-shrink:0;animation:verify-badge-pop .35s ease-out}
    @keyframes verify-badge-pop{0%{transform:scale(.92);opacity:.6}100%{transform:scale(1);opacity:1}}
    .verify-badge.hidden{display:none!important}
    .verify-badge.checking{color:var(--text-muted);background:rgba(99,102,241,.12);border-color:rgba(99,102,241,.4);box-shadow:0 0 0 2px rgba(99,102,241,.12)}
    .verify-badge.checking::before{content:"";width:11px;height:11px;border:2px solid rgba(99,102,241,.35);border-top-color:var(--btn-gradient-start);border-radius:50%;animation:verify-spin .7s linear infinite;margin-right:2px}
    @keyframes verify-spin{to{transform:rotate(360deg)}}
    .verify-badge.verified{color:#15803d;background:rgba(22,163,74,.16);border-color:rgba(22,163,74,.5);box-shadow:0 0 0 2px rgba(22,163,74,.12), 0 2px 8px rgba(22,163,74,.08)}
    .verify-badge.uncertain{color:var(--text-muted);background:rgba(148,163,184,.18);border-color:rgba(100,116,139,.5);box-shadow:0 0 0 2px rgba(148,163,184,.1)}
    .verify-badge.not-checked{color:var(--text-muted);background:rgba(148,163,184,.14);border-color:rgba(100,116,139,.45)}
    .verify-badge.incorrect{font-size:0.82rem;padding:6px 14px;cursor:pointer;box-shadow:0 0 0 2px rgba(220,38,38,.22), 0 2px 12px rgba(220,38,38,.15);color:#b91c1c;background:rgba(239,68,68,.14);border-color:rgba(220,38,38,.55);border-width:2px}
    .verify-badge.warning{font-size:0.82rem;padding:6px 14px;cursor:pointer;box-shadow:0 0 0 2px rgba(217,119,6,.22), 0 2px 12px rgba(245,158,11,.12);color:#b45309;background:rgba(245,158,11,.16);border-color:rgba(217,119,6,.5);border-width:2px}
    .verify-badge.partial{font-size:0.82rem;padding:6px 14px;cursor:pointer;box-shadow:0 0 0 2px rgba(202,138,4,.25), 0 2px 12px rgba(234,179,8,.14);color:#a16207;background:rgba(234,179,8,.18);border-color:rgba(202,138,4,.55);border-width:2px}
    html[data-theme="dark"] .verify-badge.incorrect{color:#fecaca}
    html[data-theme="dark"] .verify-badge.warning{color:#fde68a}
    html[data-theme="dark"] .verify-badge.partial{color:#fef08a}
    .verify-issues-panel{margin:0 14px 10px 14px;padding:10px 12px;border-radius:8px;border-left:4px solid rgba(217,119,6,.75);background:rgba(245,158,11,.08);font-size:0.85rem;line-height:1.45;color:var(--text);max-width:100%;box-sizing:border-box;position:relative}
    .verify-issues-panel .verify-issues-body{padding-right:36px}
    .verify-issues-panel .verify-issues-close{position:absolute;top:8px;right:10px;z-index:5;width:32px;height:32px;margin:0;padding:0;border:0;border-radius:8px;background:var(--kbd-bg);color:var(--text);font-size:1.35rem;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 1px 3px rgba(0,0,0,.12)}
    .verify-issues-panel .verify-issues-close:hover,.verify-issues-panel .verify-issues-close:focus-visible{background:var(--card-border);outline:2px solid var(--btn-gradient-start);outline-offset:1px}
    .verify-issues-panel.verify-issues-error{border-left-color:rgba(220,38,38,.75);background:rgba(239,68,68,.09)}
    .verify-issues-panel.hidden{display:none!important}
    .verify-issues-panel .verify-issues-title{font-weight:700;margin-bottom:6px;color:var(--text)}
    .verify-issues-panel ul{margin:6px 0 8px 18px;padding:0}
    .verify-issues-panel .verify-advice{margin-top:8px;padding-top:8px;border-top:1px solid var(--card-border);color:var(--text-muted);font-size:0.82rem}
    .verify-regenerate-btn{padding:6px 12px;font-size:0.8rem}
    .verify-regenerate-btn.hidden{display:none!important}
    .verify-float-pill{position:fixed;inset-inline-end:max(14px,env(safe-area-inset-right));bottom:max(88px,calc(14px + env(safe-area-inset-bottom)));z-index:9500;max-width:min(300px,calc(100vw - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)));padding:9px 15px;border-radius:999px;border:1px solid rgba(255,255,255,.28);font-size:0.78rem;font-weight:700;line-height:1.25;text-align:start;cursor:pointer;box-shadow:0 4px 22px rgba(0,0,0,.14),0 0 0 1px rgba(0,0,0,.04);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);background:rgba(255,255,255,.48);color:var(--text);transition:transform .2s ease,opacity .2s ease,box-shadow .2s ease;display:none;align-items:center;gap:7px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    html[data-theme="dark"] .verify-float-pill{background:rgba(30,41,59,.58);border-color:rgba(255,255,255,.14);box-shadow:0 4px 22px rgba(0,0,0,.35),0 0 0 1px rgba(255,255,255,.06)}
    .verify-float-pill:not(.hidden){display:flex}
    .verify-float-pill:focus-visible{outline:2px solid var(--btn-gradient-start);outline-offset:2px}
    @media (prefers-reduced-motion:reduce){.verify-float-pill{transition:none}}
    .verify-float-pill.checking{color:var(--text-muted);border-color:rgba(99,102,241,.45)}
    .verify-float-pill.checking::before{content:"";flex-shrink:0;width:11px;height:11px;border:2px solid rgba(99,102,241,.35);border-top-color:var(--btn-gradient-start);border-radius:50%;animation:verify-spin .7s linear infinite}
    @media (prefers-reduced-motion:reduce){.verify-float-pill.checking::before{animation:none;border-top-color:rgba(99,102,241,.6)}}
    .verify-float-pill.verified{color:#15803d;border-color:rgba(22,163,74,.45)}
    html[data-theme="dark"] .verify-float-pill.verified{color:#86efac}
    .verify-float-pill.uncertain{color:var(--text-muted);border-color:rgba(100,116,139,.45)}
    .verify-float-pill.not-checked{color:var(--text-muted);border-color:rgba(100,116,139,.4)}
    .verify-float-pill.incorrect{color:#b91c1c;border-color:rgba(220,38,38,.5)}
    .verify-float-pill.partial{color:#a16207;border-color:rgba(202,138,4,.5)}
    .verify-float-pill.warning{color:#b45309;border-color:rgba(217,119,6,.5)}
    html[data-theme="dark"] .verify-float-pill.incorrect{color:#fecaca}
    html[data-theme="dark"] .verify-float-pill.partial{color:#fef08a}
    html[data-theme="dark"] .verify-float-pill.warning{color:#fde68a}
    .verify-issues-panel.verify-float-highlight{animation:verify-float-highlight-pulse 1.25s ease-out}
    @keyframes verify-float-highlight-pulse{0%{box-shadow:0 0 0 0 rgba(99,102,241,.35)}40%{box-shadow:0 0 0 4px rgba(99,102,241,.2)}100%{box-shadow:0 0 0 0 rgba(99,102,241,0)}}
    @media (prefers-reduced-motion:reduce){.verify-issues-panel.verify-float-highlight{animation:none;outline:2px solid rgba(99,102,241,.45);outline-offset:2px}}

    .continue-box{margin-top:10px;border-top:1px solid #e5e7eb;padding-top:10px;display:none}
    .exam-modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center;z-index:9998}
    #library-modal.exam-modal-backdrop{
      z-index:10005;
      align-items:stretch;
      justify-content:stretch;
      padding:0;
    }
    #library-modal .exam-modal-content.card{
      display:flex;
      flex-direction:column;
      width:100vw;
      max-width:100vw;
      height:100vh;
      max-height:100vh;
      margin:0;
      border-radius:0;
      overflow:hidden;
    }
    #library-modal #library-learning-scope{
      flex:1 1 auto;
      min-height:0;
      overflow-y:auto;
      overflow-x:hidden;
      -webkit-overflow-scrolling:touch;
    }
    #library-modal .library-modal-footer-bar{
      flex-shrink:0;
      display:flex;
      gap:8px;
      margin-top:12px;
      padding-top:10px;
      border-top:1px solid var(--card-border);
    }
    #library-modal #library-learning-scope::-webkit-scrollbar{width:8px}
    #library-modal #library-learning-scope::-webkit-scrollbar-track{background:rgba(15,23,42,.35);border-radius:6px}
    #library-modal #library-learning-scope::-webkit-scrollbar-thumb{background:rgba(100,116,139,.55);border-radius:6px}
    #library-modal #library-learning-scope{scrollbar-width:thin;scrollbar-color:rgba(100,116,139,.55) rgba(15,23,42,.35)}
    #library-modal .exam-modal-header.library-modal-header-row{flex-shrink:0}
    /* Syllabus picker opens from Library; must stack above #library-modal (10005), below ink/camera overlays (~10400+) and VKB (~10600). */
    #library-syllabus-modal.exam-modal-backdrop{z-index:10008}
    /* Revision / exam / adaptive / lesson plan open from Library concept hub — must stack above #library-modal (10005). */
    #revision-modal.exam-modal-backdrop,
    #exam-mode-modal.exam-modal-backdrop,
    #adaptive-lesson-modal.exam-modal-backdrop,
    #lesson-plan-modal.exam-modal-backdrop,
    #lesson-plan-output-modal.exam-modal-backdrop{
      z-index:10007;
    }
    .exam-modal-content{max-width:480px;width:92vw;max-height:90vh;overflow:auto}
    #learning-scope-modal .exam-modal-content.card{
      max-height:90vh;
      overflow-y:auto;
    }
    #learning-scope-modal .exam-modal-header{
      position:sticky;
      top:0;
      z-index:6;
      background:var(--card-bg);
      padding-bottom:8px;
      margin-bottom:8px;
      box-shadow:0 12px 10px -10px var(--card-bg);
    }
    .exam-modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;font-weight:700;gap:8px}
    .exam-modal-header-actions{display:inline-flex;align-items:center;gap:2px;flex-shrink:0}
    .exam-modal-minimize{border:0;background:transparent;font-size:1.15rem;line-height:1;cursor:pointer;color:var(--text-muted);padding:0 4px;font-weight:700}
    .exam-modal-minimize:hover,.exam-modal-minimize:focus-visible{color:var(--text)}
    .exam-modal-close{border:0;background:transparent;font-size:1.4rem;cursor:pointer;color:var(--text-muted);line-height:1}
    .exam-modal-print{border:0;background:transparent;font-size:0.88rem;font-weight:600;cursor:pointer;color:var(--text-muted);padding:4px 8px;border-radius:8px;line-height:1}
    .exam-modal-print:hover,.exam-modal-print:focus-visible{color:var(--text);background:var(--kbd-bg)}
    #active-material-bar-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:10px;flex-shrink:0;max-width:100%;padding-right:56px}
    #minimized-modals-tray{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;pointer-events:none;max-width:min(100%,520px)}
    #minimized-modals-tray .minimized-modal-tab{pointer-events:auto;display:none;align-items:center;gap:8px;padding:8px 12px;border-radius:10px;border:1px solid rgba(255,255,255,0.25);background:linear-gradient(135deg,var(--btn-gradient-start,#6366f1),var(--btn-gradient-end,#8b5cf6));box-shadow:0 2px 10px rgba(0,0,0,0.35);font-size:0.86rem;max-width:min(280px,calc(100vw - 120px));color:#fff}
    .minimized-modal-tab-main{flex:1;min-width:0;text-align:left;border:0;background:transparent;color:#fff;cursor:pointer;font-size:inherit;font-weight:600;padding:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
    .minimized-modal-tab-dismiss{border:0;background:transparent;color:rgba(255,255,255,0.85);cursor:pointer;font-size:1.15rem;line-height:1;padding:0 4px;border-radius:4px}
    .minimized-modal-tab-dismiss:hover{color:#fff;background:rgba(0,0,0,0.15)}
    .library-breadcrumb-wrap{display:flex;align-items:center;flex-wrap:wrap;gap:4px;margin-bottom:10px;font-size:0.95rem;color:var(--text-muted)}
    .library-breadcrumb-wrap span{cursor:pointer}
    .library-breadcrumb-wrap span:hover{color:var(--text);text-decoration:underline}
    .library-folder-card,.library-book-card{display:flex;align-items:center;gap:10px;padding:10px 12px;margin-bottom:6px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg);cursor:pointer;transition:background .15s,border-color .15s}
    .library-folder-card:hover,.library-book-card:hover{background:var(--kbd-bg);border-color:var(--input-focus)}
    .library-folder-card .library-card-icon,.library-book-card .library-card-icon{font-size:1.25rem;flex-shrink:0;opacity:0.85}
    .library-folder-card .library-card-body,.library-book-card .library-card-body{flex:1;min-width:0}
    .library-folder-card .library-card-title,.library-book-card .library-card-title{font-weight:600;font-size:0.95rem;color:var(--text)}
    .library-book-card .library-card-meta{font-size:0.8rem;color:var(--text-muted);margin-top:2px}
    .library-folder-card .library-card-actions,.library-book-card .library-card-actions{display:flex;align-items:center;gap:6px;flex-shrink:0}
    .library-book-card-menu-wrap{position:relative;display:inline-flex}
    .library-book-card-menu-trigger{width:32px;height:32px;padding:0;border:none;background:transparent;color:var(--text-muted);cursor:pointer;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;font-size:1.1rem;line-height:1}
    .library-book-card-menu-trigger:hover{background:var(--kbd-bg);color:var(--text)}
    .library-book-card-dropdown{position:absolute;bottom:100%;right:0;margin-bottom:6px;min-width:160px;background:var(--card-bg);border:1px solid var(--card-border);border-radius:8px;box-shadow:var(--card-shadow);z-index:100;display:none;padding:4px 0}
    .library-book-card-dropdown.open{display:block}
    .library-book-card-dropdown-floating{position:fixed;min-width:220px;max-width:min(280px,calc(100vw - 24px));max-height:min(70vh,420px);overflow-x:hidden;overflow-y:auto;background:var(--card-bg);background-color:var(--card-bg);border:1px solid var(--card-border);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.25),0 2px 8px rgba(0,0,0,.15);z-index:10001;padding:4px 0;display:block;word-wrap:break-word;-webkit-overflow-scrolling:touch}
    .library-book-card-dropdown-item{display:block;width:100%;padding:8px 14px;border:none;background:0;color:var(--text);text-align:left;cursor:pointer;font-size:0.9rem;white-space:nowrap}
    .library-book-card-dropdown-item:hover{background:var(--kbd-bg)}
    .library-book-card-popover-info{padding:10px 14px;border-bottom:1px solid var(--card-border);font-size:0.82rem;color:var(--text-muted);max-height:140px;overflow-y:auto;word-wrap:break-word;white-space:normal}
    .library-book-card-popover-info .library-book-card-popover-info-title{margin-bottom:6px;font-weight:600;color:var(--text);font-size:0.9rem}
    .library-book-card-popover-info .library-book-card-popover-info-book{font-weight:600;color:var(--text);margin-bottom:4px;font-size:0.88rem}
    .library-book-card-popover-info .library-book-card-popover-info-chapters{margin-top:4px;padding-left:12px;list-style:disc}
    .library-picker-check{flex-shrink:0;cursor:pointer;accent-color:var(--btn-primary-bg);width:1.15rem;height:1.15rem;margin-top:2px}
    .library-picker-mode-banner{display:none;margin:0 0 10px;padding:10px 12px;border-radius:8px;border:1px solid var(--btn-gradient-start, #6366f1);background:rgba(99,102,241,0.12);font-size:0.88rem;line-height:1.45;color:var(--text)}
    .library-picker-mode-banner strong{display:block;margin-bottom:4px;font-size:0.92rem}
    .library-picker-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px;padding:10px 12px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg)}
    .library-picker-bar .library-picker-count{font-size:0.9rem;color:var(--text-muted)}
    .library-layout{display:grid;grid-template-columns:1fr 1fr;gap:24px;position:relative;min-height:280px}
    @media (max-width:900px){.library-layout{grid-template-columns:1fr}}
    .library-action-hub{margin-top:4px}
    .library-hub-instructions{padding:12px 14px;border:1px solid var(--card-border);border-radius:10px;background:var(--card-bg);max-height:min(42vh,360px);overflow-y:auto}
    .library-hub-instructions-text{margin:0;font-size:0.9rem;line-height:1.5;color:var(--text);white-space:pre-line}
    #active-material-bar{position:fixed;bottom:0;left:0;right:0;padding:12px 20px;padding-right:76px;background:#111;color:#fff;display:flex;justify-content:space-between;align-items:center;gap:12px;z-index:120;box-sizing:border-box}
    #active-material-bar #active-material-text{font-size:0.9rem;flex:1;min-width:0;padding-right:8px}
    body.has-active-bar{padding-bottom:60px}
    #active-material-bar .btn{background:#fff;color:#111;border:none;padding:6px 12px;border-radius:8px;cursor:pointer;font-size:0.85rem}
    .active-material-bar-buttons{display:flex;align-items:center;gap:8px;flex-shrink:0}
    .library-book-card .library-book-card-actions-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:6px;align-self:flex-start}
    .library-book-card .select-material-btn{font-size:0.8rem;padding:4px 10px;flex-shrink:0;margin-top:0;align-self:auto}
    .library-book-card .library-book-deep-enrich-btn{font-size:0.8rem;padding:4px 10px;flex-shrink:0}
    .library-modal-header-row{display:flex;align-items:center;justify-content:flex-start;gap:10px;flex-wrap:wrap;width:100%}
    .library-modal-header-row > span:first-child{flex:1;min-width:120px;font-weight:600}
    .library-folders-error-banner{display:none;margin-bottom:10px;padding:10px 12px;border-radius:6px;border:1px solid #b91c1c;background:rgba(185,28,28,0.12);font-size:0.88rem;line-height:1.45;color:var(--text,#1e293b)}
    body.dark-theme .library-folders-error-banner, [data-theme="dark"] .library-folders-error-banner{border-color:#f87171;background:rgba(248,113,113,0.12);color:var(--text,#f1f5f9)}
    .lib-guide-toolbar{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;gap:4px;padding:6px 2px 0;margin-top:2px;min-height:32px}
    .lib-guide-toolbar-label{margin:0;font-size:0.78rem;font-weight:600;color:var(--text-muted);text-align:center;line-height:1.2}
    .lib-guide-toolbar .lib-guide-toggle-wrap{margin-left:0;margin-right:0}
    .lib-guide-toggle-wrap{position:relative;display:inline-flex;align-items:center;cursor:pointer;flex-shrink:0;opacity:0.95}
    .lib-guide-toggle-wrap:focus-within{outline:2px solid var(--btn-gradient-start,#6366f1);outline-offset:2px;border-radius:999px}
    .lib-guide-toggle-input{position:absolute;opacity:0;width:0;height:0;pointer-events:none}
    .lib-guide-toggle-slider{position:relative;display:inline-block;width:42px;height:24px;border-radius:999px;background:var(--text-muted);opacity:0.45;transition:background .2s,opacity .2s;vertical-align:middle}
    .lib-guide-toggle-slider::after{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,0.2);transition:transform .2s}
    .lib-guide-toggle-input:checked + .lib-guide-toggle-slider{background:var(--btn-gradient-start,#6366f1);opacity:1}
    .lib-guide-toggle-input:checked + .lib-guide-toggle-slider::after{transform:translateX(18px)}
    .lib-guide-toggle-wrap:has(.lib-guide-toggle-input:not(:checked)){opacity:0.55}
    .lib-guide-panel{display:none;margin-top:0;padding:10px 10px 12px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg);font-size:0.82rem;line-height:1.4;box-shadow:0 2px 8px rgba(0,0,0,0.06);max-height:280px;overflow-y:auto}
    .lib-guide-intro{margin-bottom:0}
    .lib-guide-step{display:flex;align-items:flex-start;gap:6px;padding:6px 8px;margin-bottom:4px;border-radius:6px;border-left:3px solid transparent;color:var(--text-muted);transition:background .15s,color .15s,border-color .15s,opacity .15s}
    .lib-guide-steps .lib-guide-step:last-child{margin-bottom:8px}
    .lib-guide-step .lib-guide-num{font-weight:700;flex-shrink:0;opacity:0.75}
    .lib-guide-step .lib-guide-text{flex:1;min-width:0}
    .lib-guide-step.active{color:var(--text);border-left-color:var(--btn-gradient-start,#6366f1);background:rgba(99,102,241,0.08);font-weight:600}
    .lib-guide-step.done{text-decoration:line-through;opacity:0.55;color:var(--text-muted)}
    .lib-guide-step.done .lib-guide-num{opacity:0.5}
    .lib-guide-arrow-layer{position:absolute;left:0;top:0;right:0;bottom:0;width:100%;height:100%;pointer-events:none;z-index:30;overflow:visible}
    .lib-guide-arrow-layer path[stroke]{stroke:var(--btn-gradient-start,#6366f1)}
    .lib-guide-arrow-layer circle[fill]{fill:var(--btn-gradient-start,#6366f1)}
    .library-active-material-badge{display:inline-block;margin-left:6px;padding:2px 8px;border-radius:6px;background:rgba(34,197,94,0.2);color:var(--text);font-size:0.72rem;font-weight:600;vertical-align:middle}
    .library-panes{display:flex;gap:12px;align-items:flex-start;min-height:280px}
    .library-left-column{display:flex;flex-direction:column;gap:8px;width:260px;flex-shrink:0;align-self:stretch}
    .library-folder-tree{width:100%;flex-shrink:0;border:1px solid var(--card-border);border-radius:6px;background:var(--bg-page,#f8fafc);overflow-y:auto;max-height:320px;padding:6px 0}
    .library-tree-group{margin-left:0;padding-left:16px;border-left:1px solid var(--card-border);position:relative}
    .library-tree-group .library-tree-group{margin-top:0}
    .library-tree-node{display:flex;align-items:center;gap:4px;padding:4px 8px;cursor:pointer;font-size:0.9rem;color:var(--text);border-radius:4px;transition:background .15s;position:relative;min-height:24px}
    .library-tree-node:hover{background:var(--kbd-bg)}
    .library-tree-node.current{background:var(--input-focus, rgba(99,102,241,.15));color:var(--text)}
    .library-tree-group .library-tree-node::before{content:"";position:absolute;left:-16px;top:50%;width:12px;height:0;border-top:1px solid var(--card-border);pointer-events:none}
    .library-tree-node .library-tree-icon{font-size:1rem;opacity:0.9;flex-shrink:0}
    .library-tree-node.folder-open .library-tree-icon{opacity:1}
    .library-tree-node .library-tree-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
    .library-tree-toggle{width:20px;height:20px;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;border:none;background:transparent;cursor:pointer;border-radius:2px;color:var(--text-muted);font-size:0.7rem;padding:0;line-height:1;transition:transform .15s}
    .library-tree-toggle:hover{color:var(--text);background:var(--kbd-bg)}
    .library-tree-toggle.expanded{transform:rotate(90deg)}
    .library-right-pane{flex:1;min-width:0;display:flex;flex-direction:column}
    .library-add-fields-grid{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr);gap:10px;align-items:end}
    @media (max-width:640px){.library-add-fields-grid{grid-template-columns:1fr}}
    #library-add-form.library-add-form-enlarged{padding:12px;border-radius:8px;font-size:1.05rem}
    #library-add-form.library-add-form-enlarged .btn{padding:8px 14px;font-size:0.95rem}
    @media (max-width:520px){#library-add-file-toolbar{flex-wrap:wrap!important}}
    .library-selection-tags{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:32px;padding:6px 0}
    .library-selection-tag{display:inline-flex;align-items:center;gap:4px;padding:4px 8px;border-radius:6px;background:var(--kbd-bg);border:1px solid var(--card-border);font-size:0.85rem;color:var(--text);max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
    .library-selection-tag .library-tag-remove{border:0;background:transparent;cursor:pointer;padding:0 2px;font-size:1rem;line-height:1;color:var(--text-muted)}
    .library-selection-tag .library-tag-remove:hover{color:var(--text)}
    #library-syllabus-modal .exam-modal-content{
      width:min(96vw,1420px);height:min(90vh,880px);max-width:min(98vw,1920px);max-height:96vh;
      min-width:min(320px,calc(100vw - 32px));min-height:min(360px,70vh);
      display:flex;flex-direction:column;position:relative;overflow:hidden;box-sizing:border-box
    }
    #library-syllabus-modal .exam-modal-content.card{padding:6px 10px 8px}
    #library-syllabus-modal .exam-modal-header{margin-bottom:4px;min-height:0}
    #library-syllabus-body{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;padding:2px 0 6px;gap:0}
    @media (max-width:780px){ #library-syllabus-body{overflow-y:auto;-webkit-overflow-scrolling:touch} }
    .library-syllabus-top-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:stretch;flex:1 1 0;min-height:min(58vh,620px);min-width:0}
    @media (max-width:780px){ .library-syllabus-top-grid{grid-template-columns:1fr;min-height:0;flex:0 1 auto} }
    .library-syllabus-col-left,.library-syllabus-col-tree{display:flex;flex-direction:column;min-width:0;min-height:0}
    .library-syllabus-preview-details{position:relative;border:1px solid var(--card-border);border-radius:10px;background:var(--card-bg);flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
    .library-syllabus-preview-sum{list-style:none;cursor:pointer;padding:8px 36px 8px 10px;background:var(--kbd-bg);font-weight:600;font-size:0.86rem;color:var(--text);flex-shrink:0}
    .library-syllabus-preview-sum::-webkit-details-marker{display:none}
    .library-syllabus-preview-help{position:absolute;top:6px;right:8px;z-index:2}
    .library-syllabus-preview-body{padding:8px 10px;overflow-y:auto;flex:1;min-height:0;max-height:min(32vh,280px)}
    #library-syllabus-stats{margin:8px 0 4px;font-size:0.85rem;flex-shrink:0}
    .library-syllabus-selected-panel{border:1px solid var(--card-border);border-radius:10px;background:var(--card-bg);padding:10px 12px;flex:0 1 auto;min-height:0;max-height:min(24vh,220px);overflow-y:auto}
    .library-syllabus-bulk-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px;flex-shrink:0}
    .library-syllabus-bulk-actions .btn-ai-primary{height:36px;padding:0 14px;font-size:0.84rem}
    .library-syllabus-tree-panel{display:flex;flex-direction:column;flex:1;min-height:0;border:1px solid var(--card-border);border-radius:8px;background:var(--bg-page,#f8fafc);overflow:hidden}
    .library-syllabus-tree-panel .library-syllabus-tree{flex:1;min-height:0;overflow-y:auto;padding:8px;font-size:0.9rem;border:none;border-radius:0;background:transparent}
    .library-syllabus-tree-footer{flex-shrink:0;display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:10px 12px;border-top:1px solid var(--card-border);background:var(--card-bg)}
    .library-syllabus-col-tree > h3.library-syllabus-tree-title{flex-shrink:0;margin:0 0 8px!important}
    .library-syllabus-chapter{margin-bottom:10px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg);overflow:hidden}
    .library-syllabus-chapter > summary{list-style:none;cursor:pointer;padding:8px 10px;background:var(--kbd-bg)}
    .library-syllabus-chapter > summary::-webkit-details-marker{display:none}
    .library-syllabus-chapter-row{display:flex;align-items:center;gap:10px}
    .library-syllabus-chapter-title{font-weight:600;color:var(--text)}
    .library-syllabus-sections{padding:6px 10px 10px 36px;display:flex;flex-direction:column;gap:6px}
    .library-syllabus-section-item{display:flex;align-items:flex-start;gap:8px;cursor:pointer;line-height:1.35}
    .library-syllabus-section-item input{margin-top:3px;flex-shrink:0}
    .library-syllabus-hidden-row{opacity:0.58}
    .library-syllabus-enrich-badge{font-size:0.65rem;margin-left:6px;padding:1px 5px;border-radius:4px;background:var(--kbd-bg);color:var(--text-muted);vertical-align:middle;white-space:nowrap;font-weight:500}
    .library-syllabus-bulk-actions label.library-syllabus-show-hidden-label{display:inline-flex;align-items:center;gap:6px;font-size:0.84rem;color:var(--text);cursor:pointer;user-select:none}
    .library-syllabus-bulk-actions label.library-syllabus-show-hidden-label input{margin:0}
    #library-syllabus-operation-status{display:none;margin:0 0 8px;padding:10px 12px;font-size:0.88rem;line-height:1.4;color:var(--text);background:var(--kbd-bg);border:1px solid var(--card-border);border-radius:8px;flex-shrink:0}
    #library-syllabus-operation-status[aria-busy="true"]{border-color:rgba(37,99,235,0.45)}
    .library-syllabus-lesson-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:10px}
    .library-syllabus-lesson-row select{flex:1;min-width:160px;padding:6px 8px;border-radius:6px;border:1px solid var(--card-border);background:var(--card-bg);color:var(--text)}
    .library-syllabus-nav-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px}
    #library-syllabus-player{min-height:120px;max-height:min(50vh,480px);overflow-y:auto;padding:10px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg)}
    .library-syllabus-player-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px;margin-bottom:10px;flex-wrap:wrap}
    .library-syllabus-player-head h4{margin:0;font-size:0.95rem;color:var(--text)}
    .library-syllabus-mark-row{margin-top:12px;padding-top:10px;border-top:1px solid var(--card-border)}
    .lesson-block-card{margin-bottom:12px;padding:12px;border-radius:10px;border:2px solid var(--card-border);background:var(--card-bg)}
    .lesson-block-badge{display:inline-block;font-size:0.72rem;font-weight:700;text-transform:uppercase;letter-spacing:0.04em;padding:3px 8px;border-radius:6px;margin-bottom:8px}
    .lesson-block-body{font-size:0.95rem;line-height:1.5;color:var(--text);overflow-wrap:break-word}
    .lesson-block-theory{border-color:rgba(37,99,235,0.45);background:rgba(37,99,235,0.06)}
    .lesson-block-theory .lesson-block-badge{background:rgba(37,99,235,0.2);color:#1d4ed8}
    html[data-theme="dark"] .lesson-block-theory .lesson-block-badge{color:#93c5fd}
    .lesson-block-example{border-color:rgba(22,163,74,0.45);background:rgba(22,163,74,0.06)}
    .lesson-block-example .lesson-block-badge{background:rgba(22,163,74,0.22);color:#15803d}
    html[data-theme="dark"] .lesson-block-example .lesson-block-badge{color:#86efac}
    .lesson-block-exercise{border-color:rgba(220,38,38,0.45);background:rgba(220,38,38,0.06)}
    .lesson-block-exercise .lesson-block-badge{background:rgba(220,38,38,0.2);color:#b91c1c}
    html[data-theme="dark"] .lesson-block-exercise .lesson-block-badge{color:#fca5a5}
    .lesson-block-neutral{border-color:var(--card-border)}
    .lesson-block-neutral .lesson-block-badge{background:var(--kbd-bg);color:var(--text-muted)}
    .material-context-box{padding:10px 12px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg);margin-bottom:10px}
    .material-context-box .material-context-header-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
    .material-context-box .material-context-title{font-size:0.85rem;font-weight:700;color:var(--text);margin-bottom:0}
    .material-context-box .material-context-edit-btn{padding:4px 10px;font-size:0.8rem;white-space:nowrap}
    .material-context-box .material-context-text{font-size:0.85rem;color:var(--text-muted);line-height:1.4}
    .material-context-box.material-context-empty{border-style:dashed;opacity:0.92;background:rgba(148,163,184,0.06)}
    .material-context-box.material-context-ready{border-color:var(--btn-gradient-start, #4a90e2);box-shadow:0 0 0 1px rgba(74,144,226,0.12)}
    .material-context-box .material-context-empty-hint{font-size:0.82rem;margin:6px 0 0;line-height:1.35}
    .material-context-named-list{margin-top:8px}
    .material-context-book{margin:6px 0;border:1px solid var(--card-border);border-radius:6px;padding:6px 8px;background:var(--kbd-bg)}
    .material-context-book>summary{cursor:pointer;font-weight:600;color:var(--text);font-size:0.86rem}
    .material-context-chapter{margin:6px 0 0 8px}
    .material-context-chapter-title{font-size:0.82rem;font-weight:600;color:var(--text)}
    .material-context-sections{margin:4px 0 0 14px;padding-left:14px}
    .material-context-sections li{font-size:0.8rem;color:var(--text-muted);line-height:1.35}
    .learning-scope-badge{font-size:0.8rem;margin-left:6px;padding:2px 6px;border-radius:4px;background:var(--card-bg);border:1px solid var(--card-border)}
    .structured-progress{margin-bottom:8px;font-size:0.85rem;color:#555}
    .structured-progress-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
    .structured-progress-bar{height:4px;background:#eee;border-radius:4px;overflow:hidden}
    #structured-progress-fill{height:100%;width:0%;background:#4a90e2;transition:width 0.3s ease}
    .hierarchical-progress{margin-bottom:12px;font-size:0.9rem}
    .hierarchical-progress-title{margin-bottom:8px;font-weight:600;color:var(--text)}
    .chapter-progress-item{border:1px solid var(--card-border);border-radius:8px;margin-bottom:6px;background:var(--card-bg);overflow:hidden}
    .chapter-progress-header{display:flex;align-items:center;gap:8px;padding:8px 10px;cursor:pointer;user-select:none}
    .chapter-progress-header:hover{background:var(--kbd-bg)}
    .chapter-progress-header .chapter-toggle{font-size:0.75rem;opacity:0.7;transition:transform 0.2s}
    .chapter-progress-header.expanded .chapter-toggle{transform:rotate(90deg)}
    .chapter-progress-header .chapter-name{flex:1}
    .chapter-progress-bar-wrap{flex:0 0 80px;height:6px;background:#eee;border-radius:4px;overflow:hidden}
    .chapter-progress-bar-fill{height:100%;background:linear-gradient(90deg,#4a90e2,#6633ee);border-radius:4px;transition:width 0.3s ease}
    .chapter-progress-pct{font-size:0.75rem;min-width:2.5em;color:var(--muted)}
    .chapter-concepts{display:none;padding:8px 10px 10px 28px;border-top:1px solid var(--card-border);background:rgba(0,0,0,.02)}
    .chapter-concepts.visible{display:block}
    .chapter-concepts .concept-row{display:flex;justify-content:space-between;align-items:center;padding:4px 0;font-size:0.85rem}
    .chapter-concepts .concept-name{color:var(--text)}
    .chapter-concepts .concept-score{font-weight:500;color:var(--text)}
    .diagnostic-stage-message{margin-bottom:12px;padding:10px 12px;font-size:0.95rem;line-height:1.5;color:var(--text);background:var(--card-bg);border:1px solid var(--card-border);border-radius:8px}
    .structured-question-block{margin-top:8px;padding:12px;border:1px solid var(--card-border);border-radius:8px;background:var(--card-bg);overflow-wrap:break-word}
    .structured-question-block .structured-question-text{margin-bottom:12px;font-size:1rem;line-height:1.5;color:var(--text);overflow-wrap:break-word}
    .structured-options{display:flex;flex-direction:column;gap:6px;margin-bottom:12px;list-style:none;padding:0;margin-left:0;max-width:100%}
    .structured-options li{margin:0;padding:0;max-width:100%;min-width:0}
    .structured-options .structured-option-btn{display:block;width:100%;max-width:100%;min-width:0;text-align:left;padding:10px 12px;border:1px solid var(--card-border);border-radius:6px;background:var(--card-bg);cursor:pointer;font-size:0.95rem;color:var(--text);white-space:normal;overflow-wrap:break-word;word-break:break-word}
    .structured-options .structured-option-btn:hover{border-color:var(--btn-gradient-start);background:var(--kbd-bg)}
    .structured-options .structured-option-btn.selected{border-color:var(--btn-gradient-start);background:rgba(74,144,226,0.12)}
    .structured-option-label{display:block;line-height:1.4;white-space:normal;overflow-wrap:break-word;word-break:break-word;max-width:100%}
    .structured-option-label .katex{display:inline !important;max-width:100%;overflow-wrap:anywhere}
    .structured-answer-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
    .structured-answer-row .structured-answer-input{flex:1;min-width:180px;padding:8px 10px;border:1px solid var(--card-border);border-radius:6px;font-size:0.95rem}
    .structured-submit-btn{white-space:nowrap;display:inline-flex;width:auto;min-width:auto}
    .structured-feedback{margin-top:10px;padding:8px 10px;border-radius:6px;font-size:0.9rem}
    .structured-feedback.correct{background:rgba(34,197,94,0.12);border:1px solid rgba(34,197,94,0.4);color:var(--text)}
    .structured-feedback.incorrect{background:rgba(239,68,68,0.08);border:1px solid rgba(239,68,68,0.3);color:var(--text)}
    .structured-session-complete{margin-top:12px;padding:14px;border:1px solid var(--card-border);border-radius:10px;background:var(--card-bg)}
    .structured-session-complete-title{font-size:1rem;font-weight:700;color:var(--text);margin-bottom:6px}
    .structured-session-complete-meta{font-size:0.9rem;color:var(--text-muted);margin-bottom:12px}
    .structured-session-complete-actions{display:flex;flex-wrap:wrap;gap:8px}
    .structured-session-complete-actions .btn{min-width:180px;justify-content:center}
    .structured-explanation{margin-top:10px;padding:10px 12px;border-radius:6px;font-size:0.9rem;line-height:1.5;color:var(--text);background:var(--card-bg);border:1px solid var(--card-border)}
    /* History prev/next: disabled ghost must stay visibly a button (not plain text) in dark theme */
    .structured-history-nav .btn.ghost{
      border:1px solid var(--card-border);
      min-width:7.5em;
      box-sizing:border-box;
    }
    .structured-history-nav .btn.ghost:disabled{
      opacity:0.8;
      cursor:not-allowed;
      border:1px solid var(--card-border);
      color:var(--text-muted);
      background:var(--kbd-bg);
    }
    .guided-proof-step-header{font-size:0.9rem;font-weight:600;color:var(--text-muted);margin-bottom:8px}
    .guided-proof-so-far{margin:10px 0;padding:10px 12px;border-radius:8px;border:1px dashed var(--card-border);background:var(--kbd-bg)}
    .guided-proof-so-far-title{font-size:0.8rem;text-transform:uppercase;letter-spacing:0.04em;color:var(--text-muted);margin-bottom:6px}
    .guided-proof-line{margin-bottom:6px;font-size:0.95rem;line-height:1.45}
    .guided-proof-current-state{margin:8px 0;padding:8px 10px;border-radius:6px;background:rgba(74,144,226,0.06);border:1px solid var(--card-border);font-size:0.95rem}
    .guided-proof-step-question{margin:10px 0;font-size:1rem;line-height:1.5}
    .tutor-feedback-continue-wrap{margin-top:14px}
    .tutor-follow-up-wrap{margin-top:14px;display:flex;flex-direction:column;gap:8px;max-width:100%}
    .tutor-follow-up-input{width:100%;min-height:60px;padding:8px 10px;border-radius:6px;border:1px solid var(--card-border);font-size:0.9rem;resize:vertical;box-sizing:border-box;background:var(--card-bg);color:var(--text)}
    .tutor-follow-up-input:focus{outline:none;border-color:var(--input-focus);box-shadow:0 0 0 2px var(--ai-glow)}
    .hidden{display:none}
    .continue-q{font-weight:900;font-size:.85rem;margin-bottom:6px;color:var(--text)}
    #solution-chat-wrap{margin-top:14px;border-top:1px solid var(--card-border);padding-top:12px;display:none}
    #solution-chat-wrap .solution-chat-title{font-weight:700;font-size:0.9rem;margin-bottom:8px;color:var(--text)}
    #solution-chat-messages{max-height:280px;overflow-y:auto;background:var(--card-bg);border:1px solid var(--card-border);border-radius:8px;padding:10px;margin-bottom:8px;min-height:0}
    #solution-chat-messages:empty{min-height:0;padding:0;margin-bottom:0;border:none;background:transparent}
    .solution-chat-msg{margin-bottom:10px;font-size:0.9rem;line-height:1.45}
    .solution-chat-msg.user{color:var(--text);font-weight:500}
    .solution-chat-msg.assistant{color:var(--text);border-left:3px solid var(--btn-gradient-start);padding-left:10px}
    .solution-chat-msg .label{font-size:0.75rem;color:var(--text-muted);margin-bottom:2px}
    .solution-chat-input-row{display:flex;gap:8px;align-items:flex-end}
    #solution-chat-input{flex:1;min-height:40px;padding:8px 10px;border-radius:8px;border:1px solid var(--card-border);font-size:0.9rem;resize:vertical}
    #solution-chat-send{padding:8px 14px;white-space:nowrap}

    .toast{
      position:fixed;left:50%;transform:translateX(-50%);bottom:14px;z-index:10050;
      background:rgba(17,24,39,.92);color:#fff;padding:10px 14px;border-radius:6px;
      box-shadow:0 12px 28px rgba(0,0,0,.22);display:none;align-items:center;gap:10px;
      max-width:92vw;font-size:.85rem;backdrop-filter: blur(6px);
    }
    .toast .toast-btn{
      border:0;background:var(--ai-accent-from);color:#fff;font-weight:700;border-radius:6px;padding:8px 12px;box-shadow:0 2px 8px rgba(79,70,229,.2);
      cursor:pointer;touch-action:manipulation;white-space:nowrap;box-shadow:0 2px 8px var(--ai-glow);
    }
    @keyframes stream-arrow-bounce{
      0%,100%{ transform:translateY(0); }
      50%{ transform:translateY(6px); }
    }
    @keyframes stream-more-glow{
      0%,100%{ box-shadow:0 4px 20px rgba(0,0,0,.3), 0 0 0 0 rgba(99,102,241,.35); }
      50%{ box-shadow:0 6px 24px rgba(0,0,0,.35), 0 0 20px 2px rgba(99,102,241,.4); }
    }
    #stream-more-below{
      position:fixed;right:20px;bottom:24px;left:auto;z-index:9998;
      display:none;align-items:center;gap:10px;padding:12px 18px;border-radius:28px;
      background:rgba(17,24,39,.95);color:var(--text);font-size:.85rem;cursor:pointer;
      box-shadow:0 4px 20px rgba(0,0,0,.3);backdrop-filter:blur(8px);
      border:1px solid rgba(255,255,255,.12);transition:opacity .2s ease, transform .2s ease;
      animation:stream-more-glow 2s ease-in-out infinite;
    }
    #stream-more-below:hover{ opacity:.95; }
    #stream-more-below .stream-more-arrow{
      display:inline-flex;align-items:center;justify-content:center;
      width:34px;height:34px;font-size:1.5rem;line-height:1;font-weight:700;
      color:#fff;background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      border-radius:50%;box-shadow:0 3px 12px rgba(99,102,241,.5);
      animation:stream-arrow-bounce 1.1s ease-in-out infinite;
    }
    .stream-rendered-chunk{margin:0 0 10px 0;padding:0}
    .stream-raw-zone{margin-top:2px;word-break:break-word}
    .stream-cursor{display:inline-block;vertical-align:text-bottom;opacity:.85;animation:stream-cursor-blink 1s step-end infinite}
    @keyframes stream-cursor-blink{50%{opacity:0}}

    .tools-header{display:flex;gap:10px;align-items:flex-start;flex-wrap:wrap}
    .tools-header > div{display:flex;flex-direction:column;gap:8px}
    .tool-tabs{display:flex;gap:6px;flex-wrap:wrap}
    .tool-tab{border:0;border-radius:8px;padding:8px 14px;background:var(--tab-bg);color:var(--text);cursor:pointer;font-weight:900;font-size:.82rem;touch-action:manipulation;transition:background var(--transition-duration) ease,color var(--transition-duration) ease}
    .tool-tab.active{background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));color:var(--tab-active-text)}
    .tool-panel{display:none;margin-top:14px}
    .tool-panel.active{display:block}

    .geogebra-link-section{display:none !important; margin-top:10px;padding:10px 12px;border:1px solid var(--card-border);border-radius:12px;background:var(--card-bg)}
    .geogebra-link-section .muted{font-size:.85rem;margin-top:8px}
    #geogebra-answer-banner{display:none;margin-top:10px;padding:10px 12px;border:1px solid var(--card-border);border-radius:12px;background:var(--card-bg)}
    #geogebra-answer-banner .muted{font-size:.85rem;margin:0}

    .mini-card{border:1px solid var(--card-border);border-radius:14px;padding:10px;background:var(--card-bg);height:100%;transition:background var(--transition-duration) ease,border-color var(--transition-duration) ease}
    .mini-title{font-weight:950;font-size:.86rem;margin-bottom:8px;color:var(--text)}
    .result-box{border:1px dashed var(--card-border);border-radius:12px;padding:8px 10px;background:var(--card-bg);min-height:52px;color:var(--text)}
    .mono{font-family:"JetBrains Mono",ui-monospace,monospace}

    .matrix-wide{display:grid;gap:10px}
    @media(min-width:1100px){ .matrix-wide{grid-template-columns:1fr 1fr 1.25fr} }
    @media(min-width:820px) and (max-width:1099px){ .matrix-wide{grid-template-columns:1fr 1fr} }
    .matrix-size-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px}
    .matrix-size-label{display:inline-flex;align-items:center;gap:6px;margin:0}
    .matrix-dim-input{width:52px;padding:6px 8px;border-radius:8px;border:1px solid var(--card-border);background:var(--card-bg);color:var(--text);font-size:0.9rem;text-align:center;-moz-appearance:textfield}
    .matrix-dim-input::-webkit-outer-spin-button,.matrix-dim-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
    .matrix-size-x{font-weight:700;opacity:0.75;user-select:none}
    .matrix-grid-wrap{margin-top:10px;overflow-x:auto;padding:4px 2px 2px}
    .matrix-grid{display:grid;grid-template-columns:repeat(var(--matrix-cols, 3), minmax(44px, 1fr));gap:6px;width:max-content;max-width:100%;--matrix-cols:3}
    .matrix-grid input.matrix-cell{width:52px;min-width:44px;height:44px;padding:4px 6px;border-radius:8px;border:1px solid var(--card-border);background:var(--card-bg);color:var(--text);font-size:0.9rem;font-family:"JetBrains Mono",ui-monospace,monospace;text-align:center;box-sizing:border-box}
    .matrix-grid input.matrix-cell:focus{outline:2px solid var(--btn-gradient-start, #3b82f6);outline-offset:1px}
    /* Number Systems: Send to Question. Hidden by default; set display:block (or inline-block) to re-enable (e.g. Advanced/Pro mode). */
    .numsys-advanced-wrap{display:none}

    .two-col{display:grid;gap:10px}
    @media(min-width:920px){ .two-col{grid-template-columns:1.1fr .9fr} }

    .inline-inputs{display:grid;grid-template-columns:1fr 1fr;gap:8px;align-items:end}

    .stats-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:10px}
    .stats-tab{border:0;border-radius:6px;padding:6px 12px;background:var(--tab-bg);color:var(--text);cursor:pointer;font-weight:900;font-size:.8rem;touch-action:manipulation;transition:background var(--transition-duration) ease,color var(--transition-duration) ease}
    .stats-tab.active{background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));color:var(--tab-active-text)}
    .sequences-subpanel{display:none}
    .sequences-subpanel.active{display:block}
    .stats-subpanel{display:none}
    .stats-subpanel.active{display:block}
    .variables-grid{border-collapse:collapse; font-size:0.82rem}
    .variables-grid th,.variables-grid td{border:1px solid var(--card-border); padding:4px 6px}
    .variables-grid th{background:var(--kbd-bg)}
    .variables-grid .grid-index{background:var(--bg-page); color:var(--text-muted); font-weight:600; text-align:center; min-width:2rem; user-select:none}
    .variables-grid input{width:100%; min-width:48px; border:0; padding:2px 4px; background:transparent; color:var(--text)}
    .variables-grid input:focus{outline:1px solid var(--input-focus)}

    @media(max-width:650px){
      .btn{padding:10px 14px;font-size:14px}
      .tool-tab{padding:10px 14px}
      .toast{font-size:14px}
      .toast .toast-btn{padding:10px 14px}
    }

    .footer-note{font-size:.78rem;color:var(--text-muted);line-height:1.4}

    /* ===== Answer actions (RESTORED) ===== */
    .answer-actions{
      display:flex; gap:8px; flex-wrap:wrap; align-items:center;
      margin-top:10px;
    }
    .answer-actions .btn{padding:8px 12px;font-size:.8rem}
    .answer-actions .pill{
      font-size:.75rem; color:var(--text-muted);
      border:1px solid var(--card-border); background:var(--card-bg); padding:6px 10px; border-radius:6px;
    }

    /* Bigger + red thinking/status */
    .status-thinking{
      color:#dc2626 !important;
      font-weight:950;
      font-size:.92rem;
    }
    .thinking-banner {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-top: 12px;
      padding: 10px 14px;
      border-radius: 8px;
      background: var(--card-bg);
      border: 1px solid var(--card-border);
      animation: thinking-fade-in 0.25s ease-out;
    }
    @keyframes thinking-fade-in {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    .thinking-spinner {
      width: 20px;
      height: 20px;
      border: 2px solid rgba(220,38,38,0.3);
      border-top-color: #dc2626;
      border-radius: 50%;
      animation: thinking-spin 0.8s linear infinite;
    }
    @keyframes thinking-spin {
      to { transform: rotate(360deg); }
    }
    .material-upload-loading {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-top: 10px;
      padding: 12px 14px;
      border-radius: 10px;
      background: var(--card-bg);
      border: 1px solid var(--card-border);
    }
    .material-upload-spinner {
      width: 22px;
      height: 22px;
      border: 2px solid rgba(102,51,238,0.25);
      border-top-color: var(--btn-gradient-start, #6633ee);
      border-radius: 50%;
      animation: thinking-spin 0.75s linear infinite;
      flex-shrink: 0;
    }
    .exam-upload-loading-wrap {
      margin-top: 10px;
      padding: 12px 14px;
      border-radius: 10px;
      background: var(--card-bg);
      border: 1px solid var(--card-border);
    }
    .exam-upload-steps {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .exam-step {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 0.95rem;
    }
    .exam-step-icon {
      width: 22px;
      height: 22px;
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 1rem;
    }
    .exam-step.step-done .exam-step-icon { color: var(--success, #0a0); }
    .exam-step.step-current .exam-step-icon {
      width: 22px;
      height: 22px;
      border: 2px solid rgba(102,51,238,0.25);
      border-top-color: var(--btn-gradient-start, #6633ee);
      border-radius: 50%;
      animation: thinking-spin 0.75s linear infinite;
      color: transparent;
    }
    .exam-step.step-pending .exam-step-label { color: var(--muted, #666); opacity: 0.8; }
    .material-upload-success {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .file-upload-control {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-bottom: 6px;
    }
    .file-upload-trigger {
      cursor: pointer;
      margin: 0;
    }
    .file-upload-name {
      font-size: 0.9rem;
      color: var(--text-muted);
    }
    .visually-hidden-file-input {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }
    .exam-upload-filename {
      font-size: 0.9rem;
      color: var(--text);
    }
    .exam-upload-check {
      color: #16a34a;
      font-weight: 600;
      font-size: 0.95rem;
    }

    /* ===== Ink Modal ===== */
    .modal-backdrop{
      position:fixed; inset:0;
      background:rgba(15,23,42,.55);
      display:none;
      z-index:10000;
      padding:12px;
      overflow:auto;
    }
    .modal-backdrop.show{display:block;}
    .modal{
      width:min(1200px, 96vw);
      margin:24px auto;
      background:var(--card-bg);
      border:1px solid var(--card-border);
      border-radius:18px;
      box-shadow:var(--card-shadow);
      overflow:hidden;
    }
    .modal-head{
      display:flex;align-items:center;justify-content:space-between;gap:10px;
      padding:10px 12px;background:#0f172a;color:#fff;
    }
    .modal-title{font-weight:950; font-size:.92rem;}
    .modal-close{
      border:0;background:rgba(255,255,255,.14);color:#fff;border-radius:6px;
      padding:8px 12px;cursor:pointer;font-weight:900;
    }
    .modal-body{padding:10px 12px;}

    .ink-controls{
      display:flex; gap:10px; flex-wrap:wrap; align-items:center;
      padding:8px 10px;border:1px solid var(--card-border);border-radius:6px;background:var(--card-bg);margin:8px 0 10px 0;
    }
    .ink-controls label{font-weight:900;font-size:.78rem;margin-right:6px}
    .ink-controls .ctrl{display:flex;align-items:center;gap:8px}
    .ink-controls input[type="range"]{width:170px}
    .ink-controls input[type="color"]{width:42px;height:30px;padding:0;border:0;background:transparent;cursor:pointer}
    .ink-controls .val{font-family:"JetBrains Mono",ui-monospace,monospace;font-size:.78rem;color:#334155;min-width:38px;text-align:left}

    .ink-split{display:grid;gap:12px;margin-top:10px}
    @media(min-width:980px){ .ink-split{ grid-template-columns:1fr 1fr; } }

    .ink-pane{
      border:1px solid var(--card-border);
      border-radius:16px;
      background:var(--card-bg);
      padding:10px;
    }
    .ink-pane-title{
      font-weight:950;
      font-size:.88rem;
      color:var(--text);
      margin-bottom:8px;
      display:flex; align-items:center; gap:8px;
    }

    .ink-wrap{
      border:1px dashed #cbd5e1;border-radius:14px;background:#fff;
      height:min(52vh, 520px);width:100%;overflow:hidden;position:relative;
      touch-action:none;
    }
    canvas.ink-canvas{
      width:100%;height:100%;display:block;background:#fff;
      cursor:crosshair;user-select:none;-webkit-user-select:none;touch-action:none;
    }

    .ink-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center;justify-content:space-between;margin-top:10px}
    .ink-tip{font-size:.78rem;color:#475569;margin-top:8px}

    #ink-transfer-status{
      margin-top:8px;
      font-weight:950;
      font-size:1rem;
      color:#dc2626;
    }

    /* Math camera modal */
    .camera-modal-body{ padding:12px; }
    .camera-stage{ margin-bottom:12px; }
    .camera-video{ display:block; width:100%; max-width:640px; max-height:400px; border-radius:8px; border:1px solid var(--card-border); background:#000; }
    .camera-error{ margin:8px 0; font-weight:700; }
    .camera-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
    .camera-crop-wrap{ position:relative; display:inline-block; max-width:100%; border:1px solid var(--card-border); border-radius:8px; overflow:hidden; }
    .camera-crop-wrap canvas{ display:block; max-width:100%; height:auto; cursor:crosshair; }
    .camera-crop-overlay{ position:absolute; left:0; top:0; right:0; bottom:0; pointer-events:none; }
    .camera-crop-hint{ font-size:.85rem; margin:8px 0; }
    .camera-recognizing{ font-weight:700; margin:8px 0; }
    .camera-latex-preview{ margin:10px 0; padding:10px; border:1px solid var(--card-border); border-radius:8px; background:var(--card-bg); }
    .camera-preview-label{ font-weight:700; font-size:.85rem; display:block; margin-bottom:6px; color:var(--text); }

    .part-head{display:flex;justify-content:space-between;gap:8px;align-items:center;flex-wrap:wrap}
    .part-title{font-weight:950}
    .small{font-size:.78rem;color:var(--text-muted)}
    .inline3{display:grid;gap:8px;grid-template-columns:1fr 1fr 1fr;align-items:end}
    @media(max-width:760px){ .inline3{grid-template-columns:1fr} }

    .qpoints{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
    .qpoints input{width:92px}

    .badge{display:inline-block;border:1px solid var(--card-border);background:var(--card-bg);border-radius:6px;padding:6px 10px;font-weight:900;font-size:.75rem;color:var(--text)}
    .bloom-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
    .tag{display:inline-block;background:#111827;color:#fff;border-radius:6px;padding:5px 10px;font-weight:900;font-size:.72rem}

    /* ===== NOTEBOOK FULL-SCREEN OVERLAY ===== */
    #notebook-overlay{
      position:fixed; inset:0; z-index:11000; display:none;
      flex-direction:column;
      touch-action:none;
    }
    #notebook-overlay.show{ display:flex; }
    #notebook-overlay.notebook-ruled{ background-color:#f5f0e6; }
    #notebook-overlay{ --btn-secondary-bg:rgba(255,255,255,.05); --btn-border:rgba(255,255,255,.12); --btn-text:#e8ecf3; }
    .notebook-ruled{
      flex:1; min-height:0; display:flex; flex-direction:column;
    }
    .notebook-toolbar{
      display:grid; grid-template-rows:auto auto; gap:8px;
      padding:10px 14px; background:var(--card-bg);
      color:var(--text); flex-shrink:0;
      border-bottom:1px solid rgba(255,255,255,.08);
      box-shadow:0 2px 8px rgba(0,0,0,.2);
      overflow:visible;
    }
    /* Row 1: Upper — document & page management. Row 2: Primary action bar — closest to canvas, single row, never wrap. */
    .toolbar-row-1.toolbar-row-doc{
      display:flex; gap:10px; flex-wrap:nowrap; align-items:center; overflow:visible; flex-shrink:0;
      grid-row:1;
    }
    .toolbar-row-2.toolbar-row-primary-action{
      display:flex; justify-content:flex-start; align-items:center; gap:8px; width:100%;
      flex-wrap:nowrap; overflow:visible; flex-shrink:0; grid-row:2;
    }
    .toolbar-row-primary-action .notebook-color-swatches-row{ flex-basis:auto; width:auto; margin:0; flex-shrink:0; }
    .toolbar-row-primary-action .notebook-color-swatches{ flex-wrap:nowrap; }
    .toolbar-row-2 .notebook-toolbar-tools-group{ gap:8px; justify-content:center; align-items:center; }
    .notebook-toolbar-tools-group{
      display:inline-flex; align-items:center; gap:8px;
      padding:4px 8px; border-radius:6px; background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08);
    }
    .notebook-toolbar .btn{
      display:inline-flex; align-items:center; justify-content:center;
    }
    .notebook-toolbar-tools-group .btn{
      background:transparent; color:rgba(255,255,255,.82); border-color:rgba(255,255,255,.12); font-weight:700;
    }
    .notebook-toolbar-tools-group .btn:hover{ background:rgba(255,255,255,.06); color:rgba(255,255,255,.92); border-color:rgba(255,255,255,.18); }
    .notebook-toolbar-tools-group .btn.active{ background:rgba(255,255,255,.12); color:#fff; border-color:rgba(255,255,255,.22); box-shadow:none; }
    .notebook-toolbar-tools-group .btn.active:hover{ background:rgba(255,255,255,.16); border-color:rgba(255,255,255,.28); }
    .notebook-toolbar .btn{
      display:inline-flex; align-items:center; justify-content:center;
      font-size:.85rem; padding:8px 12px; font-weight:800;
      border:1px solid rgba(255,255,255,.12); border-radius:6px;
      transition:background .15s ease, border-color .15s ease, box-shadow .15s ease;
    }
    .notebook-toolbar .btn.btn-ai-primary{
      background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); border:none; color:#fff;
      box-shadow:0 2px 6px rgba(139,92,246,.25);
    }
    .notebook-toolbar .btn.btn-ai-primary:hover:not(:disabled){ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); box-shadow:0 4px 12px rgba(139,92,246,.4); transform:translateY(-1px); }
    .notebook-toolbar .btn.btn-secondary-theme{
      background:var(--btn-secondary-tint); color:var(--text); border:1px solid var(--btn-gradient-start);
    }
    .notebook-toolbar .btn.btn-secondary-theme:hover:not(:disabled){
      background:var(--btn-secondary-tint); border-color:var(--btn-gradient-end); opacity:1;
    }
    .notebook-toolbar .btn.active{ background:var(--ai-accent-from); color:#fff; border-color:rgba(79,70,229,.5); box-shadow:0 2px 6px rgba(79,70,229,.2); }
    .notebook-toolbar .btn.active:hover{ background:var(--ai-btn-hover); border-color:rgba(99,102,241,.5); }
    #notebook-lines-btn{
      font-size:.9rem; padding:8px 14px; font-weight:900;
      background:var(--btn-secondary-bg); color:var(--btn-text); border:1px solid var(--btn-border);
    }
    #notebook-lines-btn:hover{ opacity:.9; }
    #notebook-lines-btn.active{ background:#2563eb; color:#fff; border-color:#3b82f6; box-shadow:0 1px 3px rgba(37,99,235,.35); }
    .notebook-paste-mobile{ display:none; }
    @media (pointer: coarse){
      .notebook-paste-mobile{ display:inline-flex; align-items:center; gap:4px; }
    }
    .notebook-paste-context-menu{
      position:fixed; z-index:10000; padding:6px; border-radius:8px;
      background:var(--card-bg); border:1px solid var(--card-border); box-shadow:0 4px 12px rgba(0,0,0,.2);
    }
    .notebook-paste-context-btn{
      display:block; width:100%; padding:10px 16px; border:0; border-radius:6px;
      background:transparent; color:var(--text); font-size:.9rem; font-weight:700; cursor:pointer;
      text-align:left; white-space:nowrap; touch-action:manipulation;
    }
    .notebook-paste-context-btn:hover{ background:rgba(37,99,235,.15); }
    /* Επιλογή περιοχής: primary emphasis — vibrant accent (blue–purple–orange direction), high contrast */
    .notebook-toolbar-tools-group #notebook-select.notebook-tool-primary{
      background:linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
      color:#fff; border-color:rgba(255,255,255,.28);
      box-shadow:0 2px 8px rgba(99,102,241,.35), 0 0 0 1px rgba(255,255,255,.08);
    }
    .notebook-toolbar-tools-group #notebook-select.notebook-tool-primary:hover{
      background:linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #c084fc 100%);
      color:#fff; border-color:rgba(255,255,255,.35);
      box-shadow:0 3px 12px rgba(99,102,241,.45), 0 0 0 1px rgba(255,255,255,.12);
    }
    .notebook-toolbar-tools-group #notebook-select.notebook-tool-primary.active{
      background:linear-gradient(135deg, #4338ca 0%, #6d28d9 50%, #7e22ce 100%);
      color:#fff; border-color:rgba(255,255,255,.4);
      box-shadow:0 2px 10px rgba(124,58,237,.5), 0 0 0 1px rgba(255,255,255,.15);
    }
    .notebook-toolbar-tools-group #notebook-select.notebook-tool-primary.active:hover{
      background:linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
      color:#fff; border-color:rgba(255,255,255,.45);
      box-shadow:0 3px 12px rgba(124,58,237,.55), 0 0 0 1px rgba(255,255,255,.2);
    }
    .notebook-toolbar-tools-group #notebook-select{ background:transparent; color:rgba(255,255,255,.88); border-color:rgba(255,255,255,.14); }
    .notebook-toolbar-tools-group #notebook-select:hover{ background:rgba(255,255,255,.06); border-color:rgba(255,255,255,.2); }
    .notebook-toolbar-tools-group #notebook-select.active{ background:rgba(37,99,235,.28); color:#fff; border-color:rgba(59,130,246,.5); }
    .notebook-toolbar-tools-group #notebook-select.active:hover{ background:rgba(37,99,235,.35); border-color:rgba(59,130,246,.6); }
    /* Strong attention pulse: purple → blue → orange, 1.2s per cycle, 3 times, then stop. Soft outer glow for dark mode. */
    @keyframes attention-pulse{
      0%{ box-shadow:0 0 0 3px rgba(147,51,234,.6), 0 0 20px rgba(147,51,234,.5), 0 0 40px rgba(147,51,234,.25); transform:scale(1); }
      33%{ box-shadow:0 0 0 3px rgba(59,130,246,.6), 0 0 20px rgba(59,130,246,.5), 0 0 40px rgba(59,130,246,.25); transform:scale(1.04); }
      66%{ box-shadow:0 0 0 3px rgba(249,115,22,.6), 0 0 20px rgba(249,115,22,.5), 0 0 40px rgba(249,115,22,.25); transform:scale(1.04); }
      100%{ box-shadow:0 0 0 2px rgba(147,51,234,.15), 0 0 12px rgba(147,51,234,.08); transform:scale(1); }
    }
    .notebook-toolbar-tools-group #notebook-select.attention-pulse{ animation:attention-pulse 1.2s ease-in-out 3 forwards; }
    .notebook-color-wrap{
      display:flex; align-items:center; gap:6px; flex-shrink:0;
    }
    .notebook-pen-size-wrap{ display:flex; align-items:center; gap:6px; flex-shrink:0; }
    .notebook-pen-size-wrap label{ font-size:.75rem; font-weight:800; color:rgba(255,255,255,.9); }
    #notebook-pen-size{ width:72px; accent-color:#3b82f6; }
    .notebook-pen-size-label{ font-size:.75rem; font-weight:700; color:rgba(255,255,255,.95); min-width:4.2em; }
    .notebook-color-wrap label{ font-size:.75rem; font-weight:800; color:rgba(255,255,255,.9); margin-right:2px; }
    #notebook-color-picker{
      width:32px; height:28px; padding:2px; border:1px solid rgba(255,255,255,.3);
      border-radius:6px; cursor:pointer; background:#374151;
    }
    .notebook-color-swatches{ display:flex; gap:4px; flex-wrap:wrap; align-items:center; }
    .toolbar-row-2 .notebook-color-swatches{ flex-wrap:nowrap; }
    .notebook-color-swatches-row .notebook-color-swatches{ margin:0; }
    .notebook-color-swatch{
      width:24px; height:24px; border-radius:50%; border:2px solid rgba(255,255,255,.4);
      cursor:pointer; padding:0; flex-shrink:0;
      transition:transform .12s ease, box-shadow .12s ease;
    }
    .notebook-color-swatch:hover{ transform:scale(1.12); box-shadow:0 2px 6px rgba(0,0,0,.4); }
    .notebook-color-swatch.active{ border-color:#fff; box-shadow:0 0 0 2px #111827; }
    .notebook-page-wrap{ display:flex; align-items:center; gap:4px; flex-shrink:0; }
    .notebook-page-label{ font-size:.8rem; font-weight:800; color:rgba(255,255,255,.95); min-width:3.5em; text-align:center; }
    .notebook-canvas-wrap{
      flex:1; min-height:0; position:relative; overflow-y:auto; overflow-x:hidden;
      background-color:#f5f0e6;
      -webkit-overflow-scrolling:touch;
    }
    .notebook-page-content{
      position:relative; width:100%; min-height:100%; height:3000px;
      flex-shrink:0;
    }
    .notebook-layer{
      position:absolute; left:0; top:0; width:100%; height:100%;
      display:block; box-sizing:border-box;
    }
    .notebook-lines-layer{
      pointer-events:none; z-index:0;
      background-color:#f5f0e6;
    }
    .notebook-draw-layer{
      z-index:1; background:transparent;
      cursor:crosshair; user-select:none; -webkit-user-select:none;
      touch-action:none;
    }
    #notebook-canvas{
      position:absolute; left:0; top:0; width:100%; height:100%;
      display:block; cursor:crosshair; user-select:none; -webkit-user-select:none;
      touch-action:none; background:transparent;
    }
    .notebook-text-layer{
      position:absolute; left:0; top:0; width:100%; height:100%;
      pointer-events:none; z-index:2;
    }
    .notebook-text-layer .notebook-text-object{
      pointer-events:auto; position:absolute;
      font-size:20px; line-height:1.35; color:#111827;
      padding:4px 8px; border-radius:6px; white-space:pre-wrap; word-break:break-word;
      max-width:90%; min-width:40px; cursor:default;
      touch-action:none; user-select:none; -webkit-user-select:none;
      box-sizing:border-box;
    }
    .notebook-text-layer .notebook-text-object:hover{ cursor:default; }
    .notebook-text-layer .notebook-text-object.nb-dragging{ cursor:grabbing; }
    .notebook-text-object-delete{
      position:absolute; top:2px; right:2px; width:20px; height:20px;
      border:0; border-radius:4px; background:rgba(0,0,0,.12); color:#374151;
      font-size:14px; line-height:1; cursor:pointer; display:none;
    }
    .notebook-text-object.selected .notebook-text-object-delete{ display:block; }
    .notebook-text-object.selected{ outline:2px solid #2563eb; outline-offset:2px; }
    .notebook-image-object{
      pointer-events:auto; position:absolute;
      cursor:default; touch-action:none; user-select:none; -webkit-user-select:none;
      box-sizing:border-box; border-radius:8px; overflow:hidden;
    }
    .notebook-image-object img{ display:block; max-width:100%; max-height:100%; object-fit:contain; }
    .notebook-image-object.selected{ outline:2px solid #2563eb; outline-offset:2px; }
    .notebook-image-object.nb-dragging{ cursor:grabbing; }
    .notebook-image-object-delete{
      position:absolute; top:4px; right:4px; width:24px; height:24px;
      border:0; border-radius:6px; background:rgba(0,0,0,.5); color:#fff;
      font-size:16px; line-height:1; cursor:pointer; display:none; z-index:1;
    }
    .notebook-image-object.selected .notebook-image-object-delete{ display:block; }
    .notebook-selection-overlay{
      position:absolute; left:0; top:0; width:100%; height:100%;
      pointer-events:none; z-index:3;
    }
    .notebook-selection-rect{
      position:absolute; border:2px dashed #2563eb; background:rgba(37,99,235,.08);
      box-sizing:border-box;
    }
    .notebook-selection-floating-toolbar{
      position:absolute; display:flex; align-items:center; gap:6px;
      padding:6px 10px; border-radius:6px; background:linear-gradient(180deg, #1f2937 0%, #111827 100%);
      border:1px solid rgba(255,255,255,.15); box-shadow:0 4px 16px rgba(0,0,0,.35);
      z-index:4; pointer-events:auto; flex-shrink:0;
    }
    .notebook-selection-floating-toolbar .btn{
      font-size:.8rem; padding:6px 10px; font-weight:700;
      background:rgba(255,255,255,.08); color:rgba(255,255,255,.95);
      border:1px solid rgba(255,255,255,.18); border-radius:6px;
    }
    .notebook-selection-floating-toolbar .btn:hover{
      background:rgba(255,255,255,.14); border-color:rgba(255,255,255,.25);
    }
    .notebook-selection-floating-toolbar .btn.btn-ai-primary{
      background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      color:#fff; border:none;
    }
    .notebook-selection-floating-toolbar .btn.btn-ai-primary:hover:not(:disabled){ transform:translateY(-1px); box-shadow:0 4px 12px rgba(139,92,246,.4); }
    .notebook-selection-floating-toolbar .notebook-selection-close-btn{
      min-width:28px; padding:6px 8px; font-size:1rem; line-height:1;
    }
    .notebook-voice-math-wrap{ display:flex; align-items:center; gap:6px; font-size:.8rem; color:rgba(255,255,255,.95); }
    .notebook-voice-math-wrap input{ cursor:pointer; }
    /* STAGE recognition modal: clean math preview only – wide, responsive */
    .notebook-result-area{
      position:absolute; display:none; flex-direction:column;
      width:min(560px,92vw); min-width:320px; max-width:92vw;
      height:auto; min-height:140px; max-height:85vh;
      background:#fff; border-radius:12px; box-shadow:0 12px 40px rgba(0,0,0,.25);
      border:1px solid #e5e7eb; overflow:hidden; z-index:12000;
      right:24px; bottom:80px;
      resize:both;
    }
    .notebook-result-area.show{ display:flex; }
    .notebook-panel-title{
      padding:10px 14px; background:linear-gradient(180deg,#1f2937 0%,#111827 100%);
      color:#fff; font-weight:800; font-size:.82rem; cursor:move; user-select:none;
      flex-shrink:0; display:flex; align-items:center; justify-content:space-between; gap:8px;
    }
    .notebook-panel-title span{ flex:1; }
    .notebook-result-area .notebook-panel-title span{ display:none; }
    .notebook-panel-close{
      width:28px; height:28px; border:0; background:rgba(255,255,255,.2); color:#fff;
      border-radius:6px; cursor:pointer; font-size:1rem; line-height:1; flex-shrink:0;
    }
    .notebook-panel-close:hover{ background:rgba(255,255,255,.35); }
    .notebook-panel-body{ flex:1; padding:20px 24px; overflow-y:auto; overflow-x:hidden; display:flex; flex-direction:column; min-height:0; gap:0; -webkit-overflow-scrolling:touch; align-items:stretch; }
    .notebook-preview-label{ font-weight:800; font-size:.82rem; margin-bottom:4px; color:#0f172a; }
    .notebook-math-display-wrap{ flex-shrink:0; width:100%; min-width:0; display:flex; justify-content:center; align-items:center; margin-bottom:0; }
    .notebook-math-block{
      width:100%; box-sizing:border-box; max-width:100%; padding:32px 28px; min-height:72px;
      background:#f8fafc; border:1px solid #e2e8f0; border-radius:12px;
      font-size:1.65rem; line-height:1.5; color:#0f172a; overflow-x:auto; overflow-y:visible;
      text-align:center; margin-bottom:24px;
    }
    .notebook-math-block .katex{ display:inline-block; }
    #notebook-math-preview:empty::before{ content:""; }
    .notebook-preview-placeholder{ color:transparent; font-size:0; }
    .notebook-analyzing-indicator{ display:inline-block; width:24px; height:24px; border:2px solid #e2e8f0; border-top-color:#2563eb; border-radius:50%; animation:notebook-spin .8s linear infinite; }
    .notebook-preview-text{ font-size:1rem; line-height:1.5; word-wrap:break-word; }
    @keyframes notebook-spin{ to{ transform:rotate(360deg); } }
    .notebook-status-text{ display:none !important; }
    .notebook-result-area .notebook-raw-toggle,
    .notebook-result-area .notebook-raw-wrap{ display:none !important; }
    .notebook-edit-row{ flex-shrink:0; }
    .notebook-edit-toggle{
      font-size:.8rem; color:#2563eb; cursor:pointer; background:none; border:none; padding:0; text-decoration:underline;
    }
    .notebook-edit-toggle:hover{ color:#1d4ed8; }
    .notebook-math-edit-wrap{ flex-shrink:0; }
    #notebook-math-edit{
      width:100%; min-height:0; padding:8px 10px; border:1px solid #e2e8f0; border-radius:8px;
      font-family:ui-monospace,monospace; font-size:.9rem; resize:none; background:#fff; overflow-y:auto;
      box-sizing:border-box;
    }
    #notebook-math-edit:focus{ outline:2px solid #2563eb; outline-offset:2px; border-color:#2563eb; }
    .notebook-math-syntax-hint{
      font-size:.8rem; color:#b45309; background:#fffbeb; border:1px solid #fcd34d;
      padding:6px 10px; border-radius:8px; display:none; flex-shrink:0;
    }
    .notebook-math-syntax-hint.show{ display:block; }
    .notebook-solve-row{ flex-shrink:0; margin-top:20px; padding-top:16px; border-top:1px solid #e2e8f0; }
    .notebook-raw-toggle{ font-size:.72rem; color:#94a3b8; cursor:pointer; text-decoration:underline; background:none; border:none; padding:0; flex-shrink:0; }
    .notebook-raw-toggle:hover{ color:#64748b; }
    .notebook-raw-wrap{ display:none; margin-top:6px; flex-shrink:0; }
    .notebook-raw-wrap.show{ display:block; }
    #notebook-raw-text{
      margin-top:4px; padding:8px 10px; background:#f1f5f9; border:1px solid #e2e8f0; border-radius:8px;
      font-family:ui-monospace,monospace; font-size:.78rem; white-space:pre-wrap; word-break:break-word; max-height:100px; overflow:auto;
    }
    .notebook-err{ padding:8px 10px; background:#fef2f2; color:#dc2626; border-radius:8px; font-size:.85rem; display:none; flex-shrink:0; }
    .notebook-err.show{ display:block; }

    /* Voice recognition (Notebook only). When .voice-feature-hidden: feature disabled/hidden; code intact. */
    .voice-feature-hidden{ display:none !important; }
    .notebook-voice-wrap{ display:flex; align-items:center; gap:6px; flex-shrink:0; }
    #notebook-mic-btn{
      padding:8px 12px; font-size:.85rem; display:inline-flex; align-items:center; gap:6px;
    }
    #notebook-mic-btn.listening{ background:#dc2626; color:#fff; border-color:#b91c1c; }
    #notebook-mic-btn.listening .notebook-mic-dot{ display:inline-block; width:8px; height:8px; background:#fff; border-radius:50%; animation:notebook-mic-pulse 1s ease-in-out infinite; }
    @keyframes notebook-mic-pulse{ 0%,100%{ opacity:1; transform:scale(1); } 50%{ opacity:.6; transform:scale(1.2); } }
    .notebook-voice-lang{ display:flex; align-items:center; gap:2px; }
    .notebook-voice-lang button{
      padding:4px 8px; font-size:.7rem; border:1px solid rgba(255,255,255,.3); border-radius:6px;
      background:rgba(255,255,255,.1); color:#fff; cursor:pointer;
    }
    .notebook-voice-lang button.active{ background:rgba(59,130,246,.6); border-color:rgba(147,197,253,.5); }
    .notebook-voice-lang button:hover:not(.active){ background:rgba(255,255,255,.2); }
    #notebook-voice-preview{
      position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
      width:90%; max-width:420px; background:#fff; border-radius:12px; box-shadow:0 12px 40px rgba(0,0,0,.3);
      border:1px solid #e5e7eb; padding:16px; z-index:13000; display:none; flex-direction:column; gap:12px;
    }
    #notebook-voice-preview.show{ display:flex; }
    #notebook-voice-preview .notebook-preview-label{ margin-bottom:0; }
    #notebook-voice-preview-text{ width:100%; min-height:80px; padding:10px; border:1px solid #e2e8f0; border-radius:10px; font-size:.95rem; resize:vertical; }
    .notebook-voice-preview-btns{ display:flex; gap:10px; justify-content:flex-end; }
    #notebook-toast{
      position:absolute; left:50%; bottom:24px; transform:translateX(-50%);
      padding:10px 16px; background:#0f172a; color:#fff; border-radius:6px;
      font-size:.85rem; font-weight:700; z-index:14000; display:none; box-shadow:0 4px 12px rgba(0,0,0,.3);
    }
    #notebook-toast.show{ display:block; }

    /* ===== CALCULATOR (blue–purple gradient, unified buttons, offline notice) ===== */
    /* Function graph: static section + interactive modal */
    .variation-table-wrap { margin: 1rem 0; overflow-x: auto; }
    .variation-table-title { font-weight: 700; margin: 0 0 0.5rem 0; font-size: 1rem; }
    /* Νοερές γραμμές: διαχωρισμός στήλων/γραμμών χωρίς εμφανή γραμμή — πολύ απαλό πλαίσιο ώστε να υπάρχει δομή αλλά όχι κόκκινο/έντονο. */
    .variation-table { border-collapse: collapse; width: auto; min-width: 200px; font-size: 0.9rem; }
    .variation-table th, .variation-table td { border: 1px solid rgba(0,0,0,0.08); padding: 6px 10px; text-align: center; }
    .variation-table th[scope="row"] { text-align: left; background: var(--card-bg-alt, #f9fafb); }
    .variation-table-extrema, .variation-table-inflection { margin: 0.5rem 0 0; font-size: 0.9rem; }
    /* Διπλή γραμμή στα excluded: νοερά (απαλή), όχι κόκκινη — διαχωρισμός υπάρχει αλλά δεν τραβά το μάτι. */
    .variation-table-cell-double { border-left: 2px solid rgba(0,0,0,0.15) !important; }
    .function-graph-section { display: none !important; margin-top: 1rem; }
    .function-graph-static { width: 100%; max-width: 480px; aspect-ratio: 1 / 1; margin: 0.5rem 0; }
    .function-graph-interactive-btn { margin-top: 0.5rem; }
    .function-graph-modal {
      display: none !important;
      position: fixed; inset: 0; z-index: 10400; align-items: center; justify-content: center; padding: 12px;
    }
    .function-graph-modal.show { display: flex; }
    .function-graph-modal-backdrop {
      position: absolute; inset: 0; background: rgba(0,0,0,.5); cursor: pointer;
    }
    .function-graph-modal-content {
      position: relative; background: var(--card-bg, #fff); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
      max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
    }
    .function-graph-modal-header {
      display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-color, #e5e7eb);
    }
    .function-graph-modal-close {
      background: none; border: none; font-size: 24px; cursor: pointer; line-height: 1; padding: 0 6px; color: #6b7280;
    }
    .function-graph-modal-close:hover { color: #111; }
    .function-graph-modal-plot { width: 560px; height: 560px; min-width: 280px; min-height: 280px; flex: 0 0 auto; }

    .calculator-overlay{
      position:fixed; inset:0; z-index:10500; display:none; align-items:center; justify-content:center;
      background:rgba(0,0,0,.5); padding:12px;
    }
    .calculator-overlay.show{ display:flex; }
    /* Calculator: tint from selected button theme (same tokens as VKB) */
    .calculator-panel{
      width:100%; max-width:620px; min-width:320px;
      background:linear-gradient(135deg,color-mix(in srgb,var(--btn-gradient-start) 28%,var(--card-bg)),color-mix(in srgb,var(--btn-gradient-end) 22%,var(--card-bg)));
      color:var(--text);
      border:1px solid var(--card-border); border-radius:16px;
      box-shadow:0 20px 50px rgba(0,0,0,.12), inset 0 0 0 1px rgba(255,255,255,.35);
      overflow:hidden; display:flex; flex-direction:column;
    }
    .calculator-overlay.calculator-context-adaptive{
      align-items:flex-start;
      justify-content:flex-end;
      padding:10px 8px 10px max(8px, min(48vw, calc(100vw - 380px)));
      background:linear-gradient(90deg, rgba(0,0,0,.12) 0%, rgba(0,0,0,.12) 45%, rgba(0,0,0,.38) 100%);
    }
    /* Structured learning MCQ: dock right, lighter mask on the left so the question stays readable */
    .calculator-overlay.calculator-context-structured{
      align-items:flex-start;
      justify-content:flex-end;
      padding:10px 6px 10px max(8px, min(58vw, calc(100vw - 300px)));
      background:linear-gradient(90deg, rgba(0,0,0,.04) 0%, rgba(0,0,0,.04) 50%, rgba(0,0,0,.28) 100%);
    }
    .calculator-overlay.calculator-context-adaptive .calculator-panel,
    .calculator-overlay.calculator-context-structured .calculator-panel{
      max-width:min(360px, calc(100vw - 16px));
      max-height:calc(100vh - 20px);
      min-width:260px;
      width:auto;
    }
    .calculator-overlay.calculator-context-structured .calculator-panel{
      max-width:min(286px, calc(100vw - 12px));
      min-width:220px;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-keypad,
    .calculator-overlay.calculator-context-structured .calculator-keypad{
      flex:0 1 auto;
      min-height:0;
      overflow:visible;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-keypad-main,
    .calculator-overlay.calculator-context-structured .calculator-keypad-main{
      min-height:0;
      gap:5px;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-keypad-left,
    .calculator-overlay.calculator-context-adaptive .calculator-keypad-right,
    .calculator-overlay.calculator-context-structured .calculator-keypad-left,
    .calculator-overlay.calculator-context-structured .calculator-keypad-right{
      gap:5px;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-numpad,
    .calculator-overlay.calculator-context-structured .calculator-numpad{
      gap:5px;
    }
    .calculator-overlay.calculator-context-adaptive .calc-btn,
    .calculator-overlay.calculator-context-adaptive .calc-numpad-btn,
    .calculator-overlay.calculator-context-adaptive .calc-mode-btn,
    .calculator-overlay.calculator-context-structured .calc-btn,
    .calculator-overlay.calculator-context-structured .calc-numpad-btn,
    .calculator-overlay.calculator-context-structured .calc-mode-btn{
      padding:5px 3px;
      font-size:0.78rem;
      min-height:34px;
      min-width:0;
    }
    .calculator-overlay.calculator-context-adaptive .calc-btn .calc-primary,
    .calculator-overlay.calculator-context-structured .calc-btn .calc-primary{ font-size:0.82rem; }
    .calculator-overlay.calculator-context-adaptive .calc-btn .calc-secondary,
    .calculator-overlay.calculator-context-structured .calc-btn .calc-secondary{ font-size:0.62rem; }
    .calculator-overlay.calculator-context-adaptive .calc-shift,
    .calculator-overlay.calculator-context-structured .calc-shift{ font-size:0.72rem; }
    .calculator-overlay.calculator-context-adaptive .calculator-header,
    .calculator-overlay.calculator-context-structured .calculator-header{
      padding:8px 10px;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-title,
    .calculator-overlay.calculator-context-structured .calculator-title{ font-size:0.92rem; }
    .calculator-overlay.calculator-context-adaptive .calculator-offline-notice,
    .calculator-overlay.calculator-context-structured .calculator-offline-notice{ font-size:0.62rem; }
    .calculator-overlay.calculator-context-adaptive .calculator-insert-bar,
    .calculator-overlay.calculator-context-structured .calculator-insert-bar{ padding:8px 10px; }
    .calculator-overlay.calculator-context-adaptive .calc-insert-to-answer-btn,
    .calculator-overlay.calculator-context-structured .calc-insert-to-answer-btn{
      padding:6px 10px;
      font-size:0.82rem;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-display-wrap,
    .calculator-overlay.calculator-context-structured .calculator-display-wrap{
      padding:10px 12px;
      min-height:110px;
    }
    .calculator-overlay.calculator-context-adaptive .calculator-preview,
    .calculator-overlay.calculator-context-structured .calculator-preview{ font-size:1.15rem; min-height:40px; }
    .calculator-overlay.calculator-context-adaptive #calculator-display,
    .calculator-overlay.calculator-context-structured #calculator-display{ font-size:0.98rem; }
    .calculator-overlay.calculator-context-structured .calc-btn,
    .calculator-overlay.calculator-context-structured .calc-numpad-btn,
    .calculator-overlay.calculator-context-structured .calc-mode-btn{
      padding:4px 2px;
      font-size:0.7rem;
      min-height:30px;
    }
    .calculator-overlay.calculator-context-structured .calc-btn .calc-primary{ font-size:0.75rem; }
    .calculator-overlay.calculator-context-structured .calc-btn .calc-secondary{ font-size:0.58rem; }
    .calculator-overlay.calculator-context-structured .calc-shift{ font-size:0.66rem; }
    .calculator-overlay.calculator-context-structured .calculator-header{ padding:6px 8px; }
    .calculator-overlay.calculator-context-structured .calculator-title{ font-size:0.84rem; }
    .calculator-overlay.calculator-context-structured .calculator-offline-notice{ font-size:0.58rem; }
    .calculator-overlay.calculator-context-structured .calculator-display-wrap{
      padding:8px 10px;
      min-height:92px;
    }
    .calculator-overlay.calculator-context-structured .calculator-preview{ font-size:1.02rem; min-height:34px; }
    .calculator-overlay.calculator-context-structured #calculator-display{ font-size:0.86rem; }
    .calculator-overlay.calculator-context-structured .calculator-keypad-main{ gap:4px; }
    .calculator-overlay.calculator-context-structured .calculator-keypad-left,
    .calculator-overlay.calculator-context-structured .calculator-keypad-right{ gap:4px; }
    .calculator-overlay.calculator-context-structured .calculator-numpad{ gap:4px; }
    .calculator-insert-bar{
      display:none;
      flex-wrap:wrap;
      align-items:center;
      gap:8px;
      padding:10px 16px;
      background:color-mix(in srgb,var(--card-bg) 88%,var(--btn-gradient-start));
      border-bottom:1px solid var(--card-border);
    }
    .calc-insert-to-answer-btn{
      border:1px solid var(--btn-gradient-start);
      border-radius:8px;
      padding:8px 14px;
      font-size:.9rem;
      font-weight:700;
      background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      color:#fff;
      cursor:pointer;
      box-shadow:0 2px 8px var(--ai-glow);
    }
    .calc-insert-to-answer-btn:hover{ filter:brightness(1.06); }
    .calculator-header{
      display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 20px;
      background:color-mix(in srgb,var(--card-bg) 82%,transparent); border-bottom:1px solid var(--card-border); flex-wrap:wrap;
    }
    .calculator-title{ font-weight:700; font-size:1.04rem; color:var(--text); display:block; margin:0 0 2px 0; }
    .calculator-offline-notice{ font-size:.7rem; color:var(--text-muted); margin:0; font-weight:400; letter-spacing:.02em; }
    .calculator-modes{ display:flex; gap:5px; align-items:center; }
    .calc-mode-btn{
      border:1px solid var(--card-border); border-radius:6px; padding:5px 10px; font-size:.85rem; font-weight:700;
      background:var(--accent-subtle); color:var(--text-muted); cursor:pointer;
      transition:background .15s ease, border-color .15s ease, color .15s ease;
    }
    .calc-mode-btn:hover:not(.active){ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); color:var(--text); }
    .calc-mode-btn.active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    .calculator-close{
      border:1px solid var(--card-border); background:var(--accent-subtle); color:var(--text);
      border-radius:6px; width:36px; height:36px; cursor:pointer; font-size:1.15rem; line-height:1; padding:0;
    }
    .calculator-close:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    .calculator-display-wrap{ padding:14px 20px; background:linear-gradient(135deg,color-mix(in srgb,var(--btn-gradient-start) 18%,var(--card-bg)),color-mix(in srgb,var(--btn-gradient-end) 14%,var(--card-bg))); min-height:156px; position:relative; display:flex; flex-direction:column; justify-content:flex-start; box-sizing:border-box; border-radius:10px; gap:0; }
    .calculator-display-wrap.showing-frac{ min-height:156px; }
    .calculator-display-wrap.calc-normal-scale{ min-height:195px; }
    .calculator-display-wrap.calc-normal-scale.showing-frac{ min-height:156px; }
    .calculator-preview-wrap{ display:flex; flex-direction:column; gap:4px; flex-shrink:0; pointer-events:auto; cursor:default; }
    .calculator-preview-wrap.is-empty{ display:none; }
    .calculator-preview-label{ font-size:0.7rem; color:var(--text-muted); font-weight:500; text-transform:uppercase; letter-spacing:0.04em; }
    .calculator-preview{ min-height:52px; display:flex; align-items:center; justify-content:center; padding:10px 14px; box-sizing:border-box; text-align:center; font-size:1.51rem; line-height:1.3; color:var(--text); overflow:auto; user-select:none; pointer-events:none; border:1px dashed var(--card-border); border-radius:10px; cursor:default; background:color-mix(in srgb,var(--card-bg) 92%,var(--btn-gradient-start)); }
    .calculator-preview .katex{ font-size:1em; color:inherit; }
    .calculator-preview .calc-preview-frac{ display:inline-flex; flex-direction:column; align-items:center; vertical-align:middle; font-size:.85em; }
    .calculator-preview .calc-preview-num,.calculator-preview .calc-preview-den{ line-height:1.2; }
    .calculator-preview .calc-preview-bar{ border-bottom:1px solid currentColor; width:100%; min-width:1.2em; margin:1px 0; }
    .calculator-preview .calc-preview-fn{ font-style:italic; }
    .calculator-preview .calc-preview-sub{ font-size:0.75em; vertical-align:sub; font-style:normal; line-height:1; }
    .calculator-preview .calc-preview-log{ display:inline; color:var(--text); }
    .calculator-preview .calc-preview-log .calc-preview-fn{ font-style:normal; }
    .calculator-preview .calc-preview-g-sub{ display:inline-flex; flex-direction:column; align-items:flex-end; vertical-align:baseline; line-height:0.85; }
    .calculator-preview .calc-preview-g-sub .calc-preview-sub{ font-size:0.7em; font-style:normal; line-height:1.1; margin-left:0.15em; }
    .calculator-preview .calc-preview-log-arg{ vertical-align:0.12em; color:var(--text); }
    .calculator-preview .calc-preview-root{ font-style:normal; }
    .calculator-preview .calc-preview-placeholder{ opacity:0.7; font-style:normal; }
    .calculator-preview .calc-preview-binom{ display:inline-flex; flex-direction:column; align-items:center; vertical-align:middle; font-size:.9em; }
    .calculator-preview .calc-preview-binom-n,.calculator-preview .calc-preview-binom-r{ line-height:1.15; }
    .calculator-display-separator{ height:0; border-top:1px solid var(--card-border); margin:4px 0; flex-shrink:0; }
    .calculator-input-row{ position:relative; display:flex; flex-direction:column; justify-content:center; flex:1; min-height:2.5em; }
    .calculator-display{
      width:100%; min-height:2.5em; padding:10px 18px 16px; font-size:1.01rem; font-family:"JetBrains Mono",ui-monospace,monospace;
      text-align:right; border:none; border-radius:10px;
      background:transparent; color:var(--text); box-sizing:border-box;
      line-height:1.35; outline:none; box-shadow:none;
      resize:none; overflow-wrap:break-word; word-wrap:break-word; white-space:pre-wrap;
      overflow-y:auto;
    }
    .calculator-display-wrap.calc-normal-scale .calculator-display{ font-size:1.21rem; }
    .calculator-display-wrap.showing-frac .calculator-display{ position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden; opacity:0; pointer-events:none; }
    .calc-display-formatted{ display:none; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:2px 6px; padding:12px 16px; min-height:88px; box-sizing:border-box; text-align:right; font-size:1.27rem; font-family:"JetBrains Mono",ui-monospace,monospace; color:var(--text); overflow:hidden; }
    .calculator-display-wrap.showing-formatted .calc-display-formatted{ display:flex; }
    .calculator-display-wrap.showing-formatted .calculator-display.calc-input-overlay{ position:absolute; inset:14px 20px auto; width:calc(100% - 40px); height:90px; margin:0; color:transparent; background:transparent; caret-color:var(--accent); z-index:1; }
    .calc-frac-inline{ display:inline-flex; flex-direction:column; align-items:center; justify-content:center; vertical-align:middle; }
    .calc-frac-inline .calc-frac-num,.calc-frac-inline .calc-frac-den{ font-size:1.15rem; font-weight:700; color:var(--text); font-family:"JetBrains Mono",ui-monospace,monospace; line-height:1.2; }
    .calc-frac-inline .calc-frac-line{ width:100%; min-width:24px; max-width:48px; height:2px; background:var(--accent); border-radius:1px; margin:2px 0; flex-shrink:0; }
    .calc-stacked-frac{ display:none; text-align:center; padding:12px 16px; }
    .calculator-display-wrap.showing-frac .calc-stacked-frac{ display:flex; flex-direction:column; align-items:center; justify-content:center; }
    .calc-stacked-frac .calc-frac-num,.calc-stacked-frac .calc-frac-den{ font-size:0.95rem; font-weight:700; color:var(--text); font-family:"JetBrains Mono",ui-monospace,monospace; }
    .calc-stacked-frac .calc-frac-line{ width:52px; max-width:100%; height:2px; background:linear-gradient(90deg,var(--btn-gradient-start),var(--btn-gradient-end)); border-radius:1px; margin:4px 0; }
    .calculator-display::placeholder{ color:var(--text-muted); }
    .calculator-error{ font-size:0.69rem; color:#b91c1c; margin-top:8px; min-height:1.4em; }
    .calculator-keypad{
      display:flex; flex-direction:column; gap:14px; padding:14px 20px 20px;
    }
    .calculator-keypad-main{
      display:grid; grid-template-columns:repeat(9,1fr); grid-template-rows:repeat(6,1fr); gap:8px;
      min-height:320px;
    }
    .calculator-keypad-left{
      grid-column:1 / 6; grid-row:1 / 7;
      display:grid; grid-template-columns:repeat(5,1fr); grid-template-rows:repeat(6,1fr); gap:8px;
      min-width:0; min-height:0;
    }
    .calculator-keypad-right{
      grid-column:6 / 10; grid-row:1 / 7;
      display:grid; grid-template-columns:repeat(4,1fr); grid-template-rows:repeat(6,1fr); gap:8px;
      min-width:0; min-height:0;
    }
    .calculator-numpad{
      grid-column:1 / -1; grid-row:3 / 7;
      display:grid; grid-template-columns:repeat(4,1fr); grid-template-rows:repeat(4,1fr); gap:8px;
      min-height:0; min-width:0;
    }
    .calc-btn,.calc-mode-btn,.calc-numpad-btn{
      min-width:0; min-height:0; height:100%; width:100%; box-sizing:border-box;
      border-radius:6px; padding:10px 6px; font-size:1.04rem;
    }
    .calc-numpad-btn{
      border:1px solid var(--card-border);
      font-size:1.04rem; font-weight:700;
      background:var(--accent-subtle); color:var(--text); cursor:pointer; touch-action:manipulation;
      box-shadow:0 1px 2px rgba(0,0,0,.08); transition:opacity .12s ease, transform .12s ease, background .15s ease;
      display:flex; align-items:center; justify-content:center;
    }
    .calc-numpad-btn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    .calc-numpad-btn:active{ transform:scale(0.97); }
    .calculator-numpad .calc-equals{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); border-color:rgba(0,0,0,.15); color:#fff; }
    .calculator-numpad .calc-equals:hover{ filter:brightness(1.06); }
    html[data-theme="dark"] .calc-numpad-btn{ background:var(--accent-subtle); color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .calc-numpad-btn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    html[data-theme="dark"] .calculator-numpad .calc-equals{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; }
    html[data-theme="dark"] .calculator-numpad .calc-equals:hover{ filter:brightness(1.06); }
    .calc-btn{
      border:1px solid var(--card-border); border-radius:6px; padding:10px 6px; font-size:1.04rem; font-weight:700;
      background:var(--accent-subtle); color:var(--text); cursor:pointer; touch-action:manipulation;
      box-shadow:0 1px 2px rgba(0,0,0,.08); transition:opacity .12s ease, transform .12s ease, background .15s ease;
      display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:47px; min-width:44px; width:100%; box-sizing:border-box;
    }
    .calc-btn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    .calc-btn:active{ transform:scale(0.97); }
    .calc-btn .calc-secondary{ font-size:.75rem; color:var(--text-muted); line-height:1.1; margin-bottom:2px; }
    .calc-btn .calc-primary{ font-size:1.04rem; color:var(--text); line-height:1.2; }
    .calc-btn.calc-dual .calc-primary{ font-size:.98rem; }
    .calc-shift{ font-size:.91rem; }
    .calc-shift.active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); box-shadow:0 0 0 2px var(--ai-glow); }
    .calc-fn{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); color:var(--text); }
    .calc-fn:hover{ border-color:var(--btn-gradient-end); filter:brightness(1.03); }
    .calc-equals{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); border-color:rgba(0,0,0,.15); color:#fff; }
    .calc-equals:hover{ filter:brightness(1.06); }
    /* Dark calculator: match selected accent (no hardcoded indigo / cyan-violet) */
    html[data-theme="dark"] .calculator-panel{
      background:linear-gradient(135deg,color-mix(in srgb,var(--btn-gradient-start) 38%,var(--card-bg)),color-mix(in srgb,var(--btn-gradient-end) 32%,var(--card-bg)));
      border-color:var(--card-border);
      color:var(--text);
      box-shadow:0 20px 50px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.06);
    }
    html[data-theme="dark"] .calculator-header{ background:rgba(15,23,42,.35); border-bottom-color:var(--card-border); }
    html[data-theme="dark"] .calculator-title{ color:var(--text); }
    html[data-theme="dark"] .calculator-offline-notice{ color:var(--text-muted); }
    html[data-theme="dark"] .calculator-display-wrap{
      background:linear-gradient(135deg,color-mix(in srgb,var(--btn-gradient-start) 28%,var(--card-bg)),color-mix(in srgb,var(--btn-gradient-end) 22%,var(--card-bg)));
    }
    html[data-theme="dark"] .calculator-display-separator{ border-top-color:var(--card-border); }
    html[data-theme="dark"] .calculator-preview-label{ color:var(--text-muted); }
    html[data-theme="dark"] .calculator-preview{ color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .calculator-preview .calc-preview-log{ color:var(--text); }
    html[data-theme="dark"] .calculator-preview .calc-preview-log-arg{ color:var(--text); }
    html[data-theme="dark"] #calculator-display{
      border:none; outline:none; box-shadow:none;
      color:var(--text) !important; background:transparent !important;
      -webkit-text-fill-color:var(--text) !important;
      opacity:1 !important; visibility:visible !important;
      caret-color:var(--accent);
    }
    html[data-theme="dark"] .calculator-overlay #calculator-display{
      caret-color:#f8fafc;
      -moz-caret-width:2px;
    }
    .calculator-overlay #calculator-display:focus-visible{
      outline:2px solid color-mix(in srgb,var(--accent) 82%,#fff 18%);
      outline-offset:2px;
      border-radius:6px;
    }
    html[data-theme="dark"] #calculator-display::placeholder{ color:var(--text-muted) !important; }
    html[data-theme="dark"] .calc-display-formatted{ color:var(--text); }
    html[data-theme="dark"] .calc-frac-inline .calc-frac-num,html[data-theme="dark"] .calc-frac-inline .calc-frac-den{ color:var(--text); }
    html[data-theme="dark"] .calc-frac-inline .calc-frac-line{ background:var(--accent); }
    html[data-theme="dark"] .calc-stacked-frac .calc-frac-num,html[data-theme="dark"] .calc-stacked-frac .calc-frac-den{
      color:transparent; background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      background-clip:text; -webkit-background-clip:text;
    }
    html[data-theme="dark"] .calc-stacked-frac .calc-frac-line{ background:linear-gradient(90deg,var(--btn-gradient-start),var(--btn-gradient-end)); }
    html[data-theme="dark"] .calc-btn{ background:var(--accent-subtle); color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .calc-btn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    html[data-theme="dark"] .calc-btn .calc-secondary{ color:var(--text-muted); }
    html[data-theme="dark"] .calc-btn .calc-primary{ color:var(--text); }
    html[data-theme="dark"] .calc-fn{ background:var(--btn-secondary-tint); color:var(--text); border-color:var(--btn-gradient-start); }
    html[data-theme="dark"] .calc-fn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-end); filter:brightness(1.06); }
    html[data-theme="dark"] .calc-equals{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; }
    html[data-theme="dark"] .calc-mode-btn{ background:var(--accent-subtle); color:var(--text-muted); border-color:var(--card-border); }
    html[data-theme="dark"] .calc-mode-btn:hover:not(.active){ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); color:var(--text); }
    html[data-theme="dark"] .calc-mode-btn.active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    html[data-theme="dark"] .calculator-close{ background:var(--accent-subtle); color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .calculator-close:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    html[data-theme="dark"] .calculator-insert-bar{
      background:color-mix(in srgb,var(--card-bg) 92%,var(--btn-gradient-start));
      border-bottom-color:var(--card-border);
    }
    html[data-theme="dark"] .calc-insert-to-answer-btn{
      border-color:var(--btn-gradient-start);
      background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      box-shadow:0 2px 10px rgba(0,0,0,.35);
    }

    .vkb-panel{ position:fixed; bottom:0; left:50%; transform:translateX(-50%); z-index:10600; width:100%; max-width:600px; background:var(--card-bg,#fff); border-top:2px solid var(--card-border,#e5e7eb); box-shadow:0 -4px 20px rgba(0,0,0,.15); transition:transform .25s ease; max-height:42vh; display:flex; flex-direction:column; }
    .vkb-panel.vkb-hidden{ transform:translateX(-50%) translateY(100%); }
    .vkb-header{ display:flex; align-items:center; justify-content:space-between; padding:8px 12px; border-bottom:1px solid var(--card-border,#e5e7eb); flex-shrink:0; }
    .vkb-tabs{ display:flex; gap:6px; align-items:center; }
    .vkb-tab{ display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--card-border,#e5e7eb); border-radius:6px; padding:8px 14px; font-size:0.95rem; font-weight:600; background:rgba(255,255,255,.5); color:var(--text,#1e1b4b); cursor:pointer; touch-action:manipulation; transition:background .15s, color .15s; text-align:center; line-height:1; }
    .vkb-tab:hover{ background:rgba(255,255,255,.8); }
    .vkb-tab.active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    .vkb-close{ display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--card-border); border-radius:6px; padding:0; min-width:36px; min-height:36px; box-sizing:border-box; background:var(--kbd-bg,#f1f5f9); color:var(--text-muted,#64748b); cursor:pointer; font-size:1.1rem; line-height:1; }
    .vkb-close:hover{ background:var(--card-border); color:var(--text); }
    .vkb-pane{ display:none; padding:10px 12px; overflow-y:auto; flex:1; min-height:0; }
    .vkb-pane.active{ display:grid; gap:6px; align-content:start; }
    #vkb-pane-num.active{ display:grid; grid-template-columns:minmax(0,0.6fr) minmax(0,0.72fr) minmax(0,0.24fr); gap:5px; align-items:start; width:100%; min-width:0; }
    #vkb-pane-num .vkb-cell{ display:grid; gap:2px; min-width:0; place-items:center; }
    #vkb-pane-num .vkb-cell-left{ grid-template-columns:repeat(5,1fr); }
    #vkb-pane-num .vkb-cell-center{ grid-template-columns:repeat(6,1fr); }
    #vkb-pane-num .vkb-cell-right{ grid-template-columns:repeat(2,1fr); }
    #vkb-pane-num .vkb-cell .vkb-key{ margin:0; box-sizing:border-box; min-width:0; min-height:0; width:65%; max-width:65%; aspect-ratio:1; padding:2px; font-size:14px; flex:none; }
    #vkb-pane-num .vkb-key-sep{ visibility:hidden; pointer-events:none; }
    #vkb-pane-fx.active{ display:flex; gap:5px; align-items:start; flex-wrap:nowrap; }
    #vkb-pane-fx .vkb-fx-grid{ display:grid; grid-template-columns:repeat(6,1fr); gap:3px; align-content:start; flex:1; min-width:0; }
    #vkb-pane-fx .vkb-fx-col{ display:flex; flex-direction:column; gap:3px; flex-shrink:0; }
    #vkb-pane-fx .vkb-key{ padding:5px 6px; font-size:14px; min-width:0; min-height:38px; }
    #vkb-pane-fx .vkb-key-sep{ visibility:hidden; pointer-events:none; }
    .vkb-cursor-nav{ display:flex; gap:4px; align-items:center; padding:6px 12px; border-bottom:1px solid var(--card-border,#e5e7eb); flex-shrink:0; }
    .vkb-cursor-nav-sep{ flex:1; min-width:8px; }
    #vkb-panel[data-vkb-active="num"] .vkb-nav-lang,#vkb-panel[data-vkb-active="fx"] .vkb-nav-lang{ visibility:hidden; pointer-events:none; }
    #vkb-panel[data-vkb-active="num"] .vkb-cursor-nav-sep,#vkb-panel[data-vkb-active="fx"] .vkb-cursor-nav-sep{ visibility:hidden; }
    .vkb-nav-btn{ display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--card-border,#e5e7eb); border-radius:6px; padding:0; width:36px; height:36px; box-sizing:border-box; font-size:1rem; line-height:1; text-align:center; background:var(--kbd-bg,#f1f5f9); color:var(--text,#1e1b4b); cursor:pointer; touch-action:manipulation; }
    .vkb-nav-btn.vkb-nav-lang{ width:44px; min-width:44px; }
    .vkb-nav-btn .vkb-lang-label{ display:block; text-align:center; }
    .vkb-nav-btn:hover{ background:var(--card-border); }
    html[data-theme="dark"] .vkb-nav-btn{ background:var(--accent-subtle); color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .vkb-nav-btn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    .vkb-row{ display:flex; gap:6px; justify-content:center; align-items:stretch; }
    .vkb-key{ border:1px solid var(--card-border,#e5e7eb); border-radius:6px; padding:10px 8px; font-size:1rem; font-weight:600; background:rgba(255,255,255,.7); color:var(--text,#1e1b4b); cursor:pointer; touch-action:manipulation; min-width:36px; min-height:44px; display:flex; align-items:center; justify-content:center; box-sizing:border-box; transition:background .12s, transform .12s; flex:1; max-width:60px; }
    #vkb-pane-qwerty .vkb-row{ gap:4px; }
    #vkb-pane-qwerty .vkb-key{ padding:6px 5px; font-size:1rem; min-width:28px; min-height:36px; max-width:48px; }
    .vkb-key:hover{ background:rgba(255,255,255,.95); }
    .vkb-key:active{ transform:scale(0.97); }
    .vkb-key-wide{ max-width:120px; flex:2; }
    .vkb-key-fn{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); font-size:0.9rem; }
    .vkb-key-fn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-end); }
    .vkb-key.is-active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    .vkb-toggle-btn{ position:fixed; bottom:16px; right:16px; z-index:10599; width:48px; height:48px; border-radius:50%; border:2px solid var(--card-border); background:var(--card-bg); box-shadow:0 4px 12px rgba(0,0,0,.2); font-size:1.4rem; cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--text); transition:transform .2s, box-shadow .2s; }
    .vkb-toggle-btn:hover{ transform:scale(1.05); box-shadow:0 6px 16px rgba(0,0,0,.25); }
    .vkb-toggle-btn.vkb-open{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    html[data-theme="dark"] .vkb-panel{ background:var(--card-bg); border-top-color:var(--card-border); }
    /* Dark VKB: follow selected accent — no hardcoded indigo */
    html[data-theme="dark"] .vkb-tab:not(.active){ background:var(--accent-subtle); color:var(--text-muted); border-color:var(--card-border); }
    html[data-theme="dark"] .vkb-tab:not(.active):hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); color:var(--text); }
    html[data-theme="dark"] .vkb-tab.active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    html[data-theme="dark"] .vkb-key:not(.vkb-key-fn):not(.is-active){ background:var(--accent-subtle); color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .vkb-key:not(.vkb-key-fn):not(.is-active):hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }
    /* Function keys (Shift, etc.): slightly stronger than letter keys */
    html[data-theme="dark"] .vkb-key-fn{ background:var(--btn-secondary-tint); color:var(--text); border-color:var(--btn-gradient-start); }
    html[data-theme="dark"] .vkb-key-fn:hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-end); filter:brightness(1.06); }
    html[data-theme="dark"] .vkb-key.is-active{ background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end)); color:#fff; border-color:rgba(0,0,0,.15); }
    html[data-theme="dark"] .vkb-toggle-btn:not(.vkb-open){ background:var(--accent-subtle); color:var(--text); border-color:var(--card-border); }
    html[data-theme="dark"] .vkb-toggle-btn:not(.vkb-open):hover{ background:var(--btn-secondary-tint); border-color:var(--btn-gradient-start); }

    /* Desktop-only sizing: make VKB ~20–30% larger with safe caps */
    @media (min-width: 900px){
      .vkb-panel{ max-width:min(780px, 96vw); max-height:50vh; }
      #vkb-pane-qwerty .vkb-key{ min-height:46px; max-width:56px; font-size:1.05rem; padding:8px 7px; }
      .vkb-tab{ padding:10px 16px; font-size:1.02rem; }
      .vkb-nav-btn{ width:42px; height:42px; }
      .vkb-nav-btn.vkb-nav-lang{ width:52px; min-width:52px; }
    }

    .katex { page-break-inside: avoid !important; }
    /* ========== Concept-based learning (Book / Concept mode) ========== */
    .material-mode-toggle{
      display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:12px;
    }
    .material-mode-toggle .material-mode-btn{
      border-radius:9999px; padding:8px 14px; font-weight:600; font-size:0.88rem;
      border:1px solid var(--card-border); background:var(--card-bg); color:var(--text-muted);
      transition:background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
    }
    .material-mode-toggle .material-mode-btn:hover{ color:var(--text); border-color:var(--btn-gradient-start); }
    .material-mode-toggle .material-mode-btn.active{
      background:linear-gradient(135deg,var(--btn-gradient-start),var(--btn-gradient-end));
      color:var(--tab-active-text,#fff); border-color:transparent;
      box-shadow:0 0 0 1px rgba(99,102,241,.25), 0 4px 14px rgba(99,102,241,.15);
    }
    .material-mode-toggle .material-mode-btn:disabled{
      opacity:0.5; cursor:not-allowed; pointer-events:none;
    }
    .library-learning-scope{
      margin-bottom:4px; padding-bottom:2px; border-bottom:1px solid var(--card-border);
    }
    .library-modal-material-toggle{ margin-bottom:10px; }
    .concept-hub-3col{
      display:grid;
      /* Rail column: wide enough for π mast + icons; labels still toggle on rail :hover / :focus-within */
      /* Topics (leaf) vs explanation: 1.8fr : 0.8fr — topics panel dominant */
      grid-template-columns:min(320px,44vw) minmax(0,1.8fr) minmax(0,0.8fr);
      gap:10px;
      align-items:stretch;
      width:100%;
      box-sizing:border-box;
      min-height:0;
      --concept-rail-mast-min:clamp(102px, 17vmin, 120px);
    }
    .concept-hub-3col > *{
      min-height:0;
    }
    .concept-domain-column{
      display:flex;
      flex-direction:column;
      min-height:0;
      width:100%;
      max-width:100%;
      box-sizing:border-box;
      border-radius:14px;
      border:1px solid var(--card-border,rgba(148,163,184,.2));
      background:rgba(15,23,42,.5);
      overflow:hidden;
    }
    .concept-domain-rail-mast{
      flex-shrink:0;
      display:grid;
      place-items:stretch;
      box-sizing:border-box;
      min-height:var(--concept-rail-mast-min);
      max-height:var(--concept-rail-mast-min);
      padding:0;
      overflow:hidden;
      border-bottom:1px solid rgba(148,163,184,.12);
      background:#030712;
    }
    .concept-domain-rail-mast-img{
      display:block;
      width:100%;
      height:100%;
      min-height:0;
      object-fit:cover;
      object-position:50% 26%;
      transform:scale(1.12);
      transform-origin:50% 28%;
      pointer-events:none;
      user-select:none;
    }
    .concept-domain-rail{
      display:flex;
      flex-direction:column;
      flex-wrap:nowrap;
      align-items:stretch;
      justify-content:flex-start;
      gap:0;
      flex:1 1 auto;
      min-height:0;
      padding:1px;
      width:100%;
      min-width:0;
      max-width:100%;
      box-sizing:border-box;
      overflow-x:hidden;
      overflow-y:auto;
      -webkit-overflow-scrolling:touch;
    }
    .concept-domain-rail::-webkit-scrollbar{width:6px}
    .concept-domain-rail::-webkit-scrollbar-track{background:transparent}
    .concept-domain-rail::-webkit-scrollbar-thumb{background:rgba(100,116,139,.4);border-radius:6px}
    .concept-domain-rail{scrollbar-width:thin;scrollbar-color:rgba(100,116,139,.4) transparent}
    .concept-domain-rail-btn{
      display:flex;
      align-items:center;
      justify-content:flex-start;
      gap:4px;
      width:100%;
      min-width:0;
      min-height:0;
      box-sizing:border-box;
      padding:3px 4px;
      border-radius:6px;
      border:1px solid transparent;
      background:transparent;
      color:var(--text);
      cursor:pointer;
      text-align:left;
      font-size:0.84rem;
      flex-shrink:0;
      transition:background .15s ease, border-color .15s ease, box-shadow .15s ease;
    }
    .concept-domain-rail-btn:hover{ background:var(--accent-subtle); border-color:rgba(99,102,241,.25); }
    .concept-domain-rail-btn:focus-visible{
      outline:2px solid var(--btn-gradient-start,#6366f1);
      outline-offset:2px;
    }
    .concept-domain-rail-btn[aria-pressed="true"]{
      border-color:rgba(99,102,241,.45);
      box-shadow:inset 0 0 0 1px rgba(99,102,241,.35);
      background:linear-gradient(135deg, rgba(99,102,241,.18), rgba(139,92,246,.1));
    }
    .concept-domain-icon{
      flex-shrink:0;
      width:26px;
      height:26px;
      display:flex;
      align-items:center;
      justify-content:center;
      font-size:1rem;
      line-height:1;
      border-radius:6px;
      background:transparent;
    }
    .concept-domain-label{
      flex:1;
      min-width:0;
      font-weight:600;
      font-size:0.76rem;
      line-height:1.22;
      white-space:normal;
      word-break:break-word;
      opacity:1;
      overflow:hidden;
    }
    .concept-leaf-panel{
      min-width:0;
      display:flex;
      flex-direction:column;
    }
    .concept-leaf-panel-head{ margin-bottom:6px; }
    .concept-leaf-panel-title{ font-size:0.78rem; font-weight:600; letter-spacing:0.02em; text-transform:uppercase; }
    .library-concept-scope .concept-leaf-panel .concept-leaf-list{
      flex:1;
      min-height:min(44vh,360px);
      max-height:min(54vh,520px);
      width:100%;
      box-sizing:border-box;
    }
    .concept-explain-aside{
      min-width:0;
      padding:10px 12px;
      border-radius:10px;
      border:1px solid var(--card-border);
      background:rgba(15,23,42,.45);
      font-size:0.86rem;
      line-height:1.45;
    }
    .concept-explain-heading{
      margin:0 0 10px;
      font-size:0.82rem;
      font-weight:700;
      color:var(--text-muted);
      text-transform:uppercase;
      letter-spacing:0.04em;
    }
    .concept-detail-title{
      margin:0 0 6px;
      font-size:0.95rem;
      font-weight:700;
      color:var(--text);
      word-break:break-word;
    }
    .concept-detail-path{ margin:0 0 10px; font-size:0.8rem; word-break:break-word; }
    .concept-detail-dl{ margin:0; }
    .concept-detail-dl > div{ margin-bottom:8px; }
    .concept-detail-dl dt{
      font-weight:600;
      color:var(--text-muted);
      font-size:0.78rem;
      margin-bottom:2px;
    }
    .concept-detail-dl dd{ margin:0; color:var(--text); word-break:break-word; }
    @media (max-width:900px){
      .concept-hub-3col{
        grid-template-columns:1fr;
        grid-template-rows:auto auto auto;
        transition:none;
      }
      .concept-domain-rail-mast{
        display:none;
      }
      .concept-domain-rail{
        display:flex;
        flex-direction:row;
        flex-wrap:nowrap;
        overflow-x:auto;
        overflow-y:hidden;
        max-width:100%;
        min-width:0;
        min-height:52px;
        max-height:none;
        padding:6px 8px;
        gap:6px;
        align-self:stretch;
        -webkit-overflow-scrolling:touch;
      }
      .concept-domain-rail:hover,
      .concept-domain-rail:focus-within{
        flex-direction:row;
        flex-wrap:nowrap;
        gap:6px;
        padding:6px 8px;
        align-self:stretch;
        min-width:0;
        max-width:100%;
      }
      .concept-domain-rail:hover .concept-domain-rail-btn,
      .concept-domain-rail:focus-within .concept-domain-rail-btn{
        flex:0 0 auto;
        width:auto;
        max-width:none;
        min-width:44px;
        padding:6px 5px;
        justify-content:flex-start;
        gap:6px;
      }
      .concept-domain-rail .concept-domain-icon{
        width:32px;
        height:32px;
        font-size:1.15rem;
      }
      .concept-domain-rail-btn{ flex:0 0 auto; width:auto; min-width:44px; max-width:none; justify-content:flex-start; gap:6px; padding:6px 5px; }
      .concept-domain-label{
        flex:1;
        opacity:1;
        max-width:140px;
        white-space:normal;
        word-break:break-word;
      }
      .library-concept-scope .concept-leaf-panel .concept-leaf-list{
        max-height:min(36vh,320px);
      }
      .concept-explain-aside{ max-height:min(32vh,280px); overflow-y:auto; }
      .concept-panel-hub-layout{
        flex-direction:column;
        gap:10px;
      }
      .library-concept-scope .concept-hub-cards-rail{
        position:relative;
        top:auto;
        width:100%;
        max-width:none;
        flex:none;
        align-self:stretch;
        z-index:auto;
      }
      .library-concept-scope .concept-hub-cards-grid{
        display:grid;
        grid-template-columns:repeat(3, minmax(0, 1fr));
        align-items:stretch;
        gap:6px;
        padding:4px 0 10px;
        margin:0;
        overflow-x:visible;
        overflow-y:visible;
      }
      .library-concept-scope .concept-hub-cards-grid .concept-hub-card{
        width:100%;
        max-width:100%;
        height:auto;
        aspect-ratio:unset;
        min-height:0;
        min-width:0;
        margin:0;
        align-items:stretch;
        justify-content:flex-start;
        gap:5px;
        padding:7px 5px 9px;
        box-sizing:border-box;
        box-shadow:0 6px 18px rgba(0,0,0,.12);
      }
      .library-concept-scope .concept-hub-card-label{
        font-size:0.58rem;
      }
      .library-concept-scope .concept-hub-cards-grid .concept-hub-card:hover{
        box-shadow:0 0 0 1px rgba(99,102,241,.25), 0 10px 28px rgba(99,102,241,.18);
      }
      .library-concept-scope .concept-hub-cards-grid .concept-hub-card-icon--tile,
      .library-concept-scope .concept-hub-cards-grid .concept-hub-card-icon--hub-radar{
        align-self:stretch;
        width:100%;
        max-width:100%;
        max-height:min(78px, 22vw);
        flex:0 1 auto;
        min-height:0;
        margin-top:0;
      }
      .library-concept-scope .concept-hub-card--grid-span .concept-hub-card-icon--tile,
      .library-concept-scope .concept-hub-card--grid-span .concept-hub-card-icon--hub-radar{
        max-height:min(82px, 24vw);
      }
    }
    .concept-panel{
      margin-bottom:14px; padding:14px 16px; border-radius:var(--card-radius,14px);
      border:1px solid rgba(148,163,184,.2);
      background:rgba(30,41,59,.55); backdrop-filter:blur(10px);
      box-shadow:0 4px 24px rgba(0,0,0,.12);
      animation:conceptPanelIn .28s ease-out;
    }
    @keyframes conceptPanelIn{
      from{ opacity:0; transform:translateY(6px); }
      to{ opacity:1; transform:translateY(0); }
    }
    .concept-panel-head{ font-weight:700; font-size:0.95rem; margin-bottom:10px; color:var(--text); }
    .concept-search{
      width:100%; box-sizing:border-box; padding:10px 12px; border-radius:10px;
      border:1px solid var(--input-border); background:var(--card-bg); color:var(--text);
      font-size:0.92rem; margin-bottom:10px;
    }
    .concept-leaf-list{
      overflow:auto; padding:6px 8px;
      border:1px solid var(--card-border); border-radius:10px; background:rgba(15,23,42,.35);
      width:100%;
      box-sizing:border-box;
      scrollbar-width:thin;
      scrollbar-color:rgba(100,116,139,.45) rgba(15,23,42,.25);
    }
    .concept-leaf-list::-webkit-scrollbar{width:8px}
    .concept-leaf-list::-webkit-scrollbar-track{background:rgba(15,23,42,.25);border-radius:6px}
    .concept-leaf-list::-webkit-scrollbar-thumb{background:rgba(100,116,139,.45);border-radius:6px}
    .library-concept-scope .concept-explain-aside{
      scrollbar-width:thin;
      scrollbar-color:rgba(100,116,139,.45) rgba(15,23,42,.25);
    }
    .library-concept-scope .concept-explain-aside::-webkit-scrollbar{width:8px}
    .library-concept-scope .concept-explain-aside::-webkit-scrollbar-track{background:rgba(15,23,42,.25);border-radius:6px}
    .library-concept-scope .concept-explain-aside::-webkit-scrollbar-thumb{background:rgba(100,116,139,.45);border-radius:6px}
    .concept-leaf-list-row{
      display:flex;
      align-items:flex-start;
      gap:10px;
      padding:8px 8px;
      margin:2px 0;
      border-radius:8px;
      transition:background .15s ease, box-shadow .15s ease;
    }
    .concept-leaf-list-row:hover{ background:var(--accent-subtle); }
    .concept-leaf-list-row.is-selected{
      background:linear-gradient(90deg, rgba(99,102,241,.16), rgba(139,92,246,.08));
      box-shadow:inset 0 0 0 1px rgba(99,102,241,.28);
    }
    .concept-leaf-list-row.is-preview-focus:not(.is-selected){
      box-shadow:inset 0 0 0 1px rgba(34,211,238,.35);
      background:rgba(34,211,238,.06);
    }
    .concept-leaf-preview-btn{
      flex:1;
      min-width:0;
      margin:0;
      padding:0;
      border:none;
      background:transparent;
      color:var(--text);
      font:inherit;
      font-size:0.9rem;
      line-height:1.35;
      text-align:left;
      cursor:pointer;
      word-break:break-word;
    }
    .concept-leaf-preview-btn:hover{ text-decoration:underline; text-underline-offset:3px; }
    .concept-tree-container{
      max-height:min(42vh,360px); overflow:auto; padding:8px 10px;
      border:1px solid var(--card-border); border-radius:10px; background:rgba(15,23,42,.35);
      width:100%;
      box-sizing:border-box;
    }
    .concept-node{ margin:2px 0; }
    .concept-node-inner{
      display:flex; align-items:center; gap:8px; padding:6px 8px 6px calc(8px + var(--depth,0) * 14px);
      border-radius:8px; cursor:pointer; transition:background .15s ease;
    }
    .concept-node-inner:hover{ background:var(--accent-subtle); }
    .concept-node-inner.is-selected{
      background:linear-gradient(90deg, rgba(99,102,241,.2), rgba(139,92,246,.12));
      box-shadow:inset 0 0 0 1px rgba(99,102,241,.35);
    }
    .concept-toggle{
      flex-shrink:0; width:28px; height:28px; border:none; border-radius:6px;
      background:var(--btn-secondary-bg); color:var(--text); cursor:pointer; font-size:0.75rem;
    }
    .concept-node-label{
      font-size:0.9rem; color:var(--text);
      flex:1; min-width:0;
      word-break:break-word; white-space:normal;
    }
    .concept-leaf-dot{
      width:6px; height:6px; border-radius:50%; background:linear-gradient(135deg,#6366f1,#8b5cf6); flex-shrink:0;
    }
    .concept-children{ margin-left:4px; border-left:1px solid var(--card-border); padding-left:4px; }
    .concept-hub-header{ margin-bottom:10px; }
    .concept-hub-title-row{
      display:flex;
      align-items:center;
      gap:4px;
      flex-wrap:wrap;
      margin:0 0 6px;
    }
    .concept-hub-title-row .concept-hub-title{ margin:0; flex:0 1 auto; min-width:0; font-size:1.12rem; font-weight:700; color:var(--text); letter-spacing:-0.01em; }
    .concept-hub-title-help{ flex-shrink:0; margin-top:2px; }
    .concept-hub-help-popover{
      width:min(720px,calc(100vw - 24px));
      max-width:min(720px,calc(100vw - 24px));
      min-width:min(320px,calc(100vw - 24px));
      max-height:min(72vh,560px);
      overflow-y:auto;
      padding:12px 16px;
      font-size:0.86rem;
      line-height:1.5;
    }
    .concept-hub-subtitle{ margin:0 0 4px; font-size:0.88rem; line-height:1.45; max-width:52rem; }
    .concept-hub-count{ margin:0; font-size:0.8rem; font-weight:600; color:var(--text-muted); }
    .concept-selection-chips{ display:flex; flex-wrap:wrap; gap:8px; margin:10px 0 12px; min-height:0; }
    .library-concept-scope .concept-selected-scope-box{
      width:100%;
      box-sizing:border-box;
      margin-top:14px;
      padding:12px 14px 14px;
      border-radius:16px;
      border:1px solid var(--card-border,rgba(148,163,184,.22));
      background:linear-gradient(180deg, rgba(15,23,42,.5), rgba(30,41,59,.42));
      box-shadow:0 6px 20px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.04);
    }
    .concept-selected-scope-box-title{
      margin:0 0 10px;
      font-size:0.84rem;
      font-weight:700;
      color:var(--text);
      letter-spacing:0.01em;
    }
    .library-concept-scope .concept-selection-chips{
      margin:0;
      min-height:40px;
      align-content:flex-start;
      padding:8px 10px;
      border-radius:12px;
      border:1px solid rgba(148,163,184,.18);
      background:rgba(15,23,42,.35);
      max-height:min(28vh,240px);
      overflow-y:auto;
      scrollbar-width:thin;
      scrollbar-color:rgba(100,116,139,.45) rgba(15,23,42,.25);
    }
    .library-concept-scope .concept-selection-chips::-webkit-scrollbar{ width:8px; }
    .library-concept-scope .concept-selection-chips::-webkit-scrollbar-track{ background:rgba(15,23,42,.25); border-radius:6px; }
    .library-concept-scope .concept-selection-chips::-webkit-scrollbar-thumb{ background:rgba(100,116,139,.45); border-radius:6px; }
    .concept-scope-toolbar{
      display:flex; flex-wrap:wrap; gap:8px; align-items:center;
      margin:8px 0 10px;
    }
    .concept-scope-toolbar .concept-scope-toolbar-btn{ padding:4px 10px; font-size:0.78rem; }
    .concept-leaf-section-header{
      display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px;
      margin:12px 0 6px; padding:6px 8px; border-radius:8px;
      background:rgba(99,102,241,.08); border:1px solid rgba(99,102,241,.18);
    }
    .concept-leaf-section-header:first-child{ margin-top:0; }
    .concept-leaf-section-title{ font-size:0.8rem; font-weight:700; color:var(--text); }
    .concept-leaf-section-actions{ display:flex; flex-wrap:wrap; gap:6px; }
    .concept-leaf-section-actions .btn{ padding:3px 8px; font-size:0.72rem; }
    .concept-selection-chip{
      display:inline-flex; align-items:center; gap:6px; padding:4px 6px 4px 10px; border-radius:9999px;
      font-size:0.78rem; background:rgba(99,102,241,.14); border:1px solid rgba(99,102,241,.32); color:var(--text); max-width:100%;
    }
    .concept-chip-text{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:min(280px,42vw); }
    .concept-chip-remove{
      flex-shrink:0; border:none; background:transparent; color:var(--text-muted); cursor:pointer; font-size:1.05rem;
      line-height:1; padding:0 4px; border-radius:4px;
    }
    .concept-chip-remove:hover{ color:var(--text); background:rgba(0,0,0,.12); }
    .concept-hub-tree-card,.concept-hub-focus-card{
      border-radius:16px; border:1px solid var(--card-border,rgba(148,163,184,.2));
      background:var(--card-bg,rgba(30,41,59,.55)); box-shadow:0 8px 24px rgba(0,0,0,.16);
      transition:border-color .2s ease, box-shadow .2s ease;
    }
    .concept-hub-tree-card{ padding:10px 10px 12px; }
    .concept-hub-focus-card{ padding:12px 14px; }
    .concept-hub-tree-card:hover,.concept-hub-focus-card:hover{
      border-color:var(--btn-gradient-start,#6366f1); box-shadow:0 12px 28px rgba(0,0,0,.14);
    }
    .concept-leaf-row{ display:flex; align-items:flex-start; gap:10px; cursor:pointer; flex:1; min-width:0; }
    .concept-leaf-checkbox{
      flex-shrink:0; margin-top:3px; width:16px; height:16px; cursor:pointer;
      accent-color:var(--btn-gradient-start,#6366f1);
    }
    .concept-panel-hub-layout{
      display:flex;
      flex-direction:row;
      align-items:flex-start;
      justify-content:flex-start;
      gap:12px;
      width:100%;
      min-height:0;
      margin-top:8px;
    }
    .concept-panel-hub-main{
      flex:1 1 auto;
      min-width:0;
    }
    .library-concept-scope .concept-hub-cards-rail{
      --hub-tile:min(104px, 28vw);
      flex:0 0 min(100%, calc(var(--hub-tile) * 3 + 16px));
      width:min(100%, calc(var(--hub-tile) * 3 + 16px));
      max-width:min(352px, 100%);
      align-self:flex-start;
      position:sticky;
      top:10px;
      z-index:2;
      box-sizing:border-box;
      display:flex;
      flex-direction:column;
      align-items:stretch;
    }
    .library-concept-scope .concept-hub-cards-grid{
      display:grid;
      grid-template-columns:repeat(3, minmax(0, 1fr));
      align-items:stretch;
      gap:8px;
      width:100%;
      max-width:100%;
      box-sizing:border-box;
      padding:0;
      margin:0;
    }
    .library-concept-scope .concept-hub-cards-grid .concept-hub-card{
      width:100%;
      max-width:100%;
      flex:unset;
      height:auto;
      aspect-ratio:unset;
      margin:0;
      min-height:0;
      box-sizing:border-box;
      display:flex;
      flex-direction:column;
      align-items:stretch;
      justify-content:flex-start;
      gap:6px;
      padding:8px 6px 10px;
      border-radius:8px;
      box-shadow:0 3px 10px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.06);
    }
    .library-concept-scope .concept-hub-card--grid-span{
      grid-column:1 / -1;
      justify-self:center;
      max-width:min(240px, 100%);
    }
    .library-concept-scope .concept-hub-card-label{
      display:block;
      flex:0 0 auto;
      font-size:0.62rem;
      font-weight:600;
      line-height:1.18;
      text-align:center;
      color:var(--text);
      hyphens:auto;
      overflow-wrap:anywhere;
      word-break:break-word;
    }
    .library-concept-scope .concept-hub-cards-grid .concept-hub-card:hover{
      box-shadow:0 0 0 1px rgba(99,102,241,.2), 0 5px 14px rgba(99,102,241,.11);
    }
    .library-concept-scope .concept-hub-cards-grid .concept-hub-card-icon--tile{
      width:100%;
      max-width:100%;
      max-height:min(92px, 24vw);
      margin:0;
      margin-top:0;
      flex:0 1 auto;
      min-height:0;
      aspect-ratio:1 / 1;
      align-self:stretch;
      background-size:300% 200%;
      background-repeat:no-repeat;
      background-origin:content-box;
    }
    .library-concept-scope .concept-hub-card--grid-span .concept-hub-card-icon--tile,
    .library-concept-scope .concept-hub-card--grid-span .concept-hub-card-icon--hub-radar{
      max-height:min(96px, 26vw);
    }
    .library-concept-scope .concept-hub-cards-grid .concept-hub-card-icon--hub-radar{
      max-height:min(92px, 24vw);
    }
    .concept-hub-card{
      width:100%;
      max-width:100%;
      min-width:0;
      min-height:0;
      box-sizing:border-box;
      overflow:hidden;
      display:flex; flex-direction:column; align-items:stretch; justify-content:flex-end;
      margin:0;
      padding:6px;
      border-radius:calc(14px * 0.9);
      cursor:pointer; text-align:center;
      border:1px solid var(--card-border, rgba(148,163,184,.28));
      background:linear-gradient(165deg, rgba(30,41,59,.72), rgba(30,41,59,.42));
      color:var(--text);
      box-shadow:0 6px 18px rgba(0,0,0,.12);
      transition:border-color .2s ease, box-shadow .2s ease, background .2s ease;
      font:inherit;
    }
    .concept-hub-card:hover{
      border-color:var(--btn-gradient-start, #6366f1);
      box-shadow:0 0 0 1px rgba(99,102,241,.25), 0 10px 28px rgba(99,102,241,.18);
    }
    .concept-hub-card:focus-visible{
      outline:2px solid var(--btn-gradient-start, #6366f1);
      outline-offset:2px;
    }
    .concept-hub-card-icon{
      font-size:2rem;
      line-height:1;
    }
    /* 1024×682 sprite: 3×2 grid — one cell per tile; positions at 0/50/100% × top/bottom row */
    .concept-hub-card-icon--tile{
      font-size:0;
      width:100%;
      max-width:100%;
      aspect-ratio:1 / 1;
      margin:0;
      flex:1 1 auto;
      min-height:0;
      flex-shrink:0;
      background-image:url("../images/concept-hub-cards-sprite.png");
      background-repeat:no-repeat;
      background-size:300% 200%;
      background-origin:content-box;
      background-clip:padding-box;
    }
    .concept-hub-card-icon--tile-revision{ background-position-x:0%; background-position-y:0%; }
    .concept-hub-card-icon--tile-structured{ background-position-x:50%; background-position-y:0%; }
    .concept-hub-card-icon--tile-adaptive{ background-position-x:100%; background-position-y:0%; }
    .concept-hub-card-icon--tile-iq{ background-position-x:0%; background-position-y:100%; }
    .concept-hub-card-icon--tile-cogtest{ background-position-x:50%; background-position-y:100%; }
    .concept-hub-card-icon--tile-cogprofile{ background-position-x:100%; background-position-y:100%; }
    /* Lesson plan: reference art (dual card PNG — left half); Greek title in asset masked — label uses i18n */
    .concept-hub-card-icon--tile-lessonplan{
      background-image:url("../images/hub-lesson-plan-art.png");
      background-size:200% auto;
      background-position:0% 36%;
      background-repeat:no-repeat;
      -webkit-mask-image:linear-gradient(to bottom, #000 0%, #000 79%, transparent 100%);
      mask-image:linear-gradient(to bottom, #000 0%, #000 79%, transparent 100%);
    }
    /* Concept library hub: bottom-row sprites use vertical keyword (top row uses global y=0%) */
    .library-concept-scope .concept-hub-card-icon--tile-iq{
      background-position-x:0%;
      background-position-y:bottom;
    }
    .library-concept-scope .concept-hub-card-icon--tile-cogtest{
      background-position-x:50%;
      background-position-y:bottom;
    }
    .library-concept-scope .concept-hub-cards-grid .concept-hub-card-icon--tile-lessonplan{
      background-size:200% auto;
      background-position:0% 34%;
    }
    /* Hide baked-in Greek captions inside sprite cells; hub card label carries translations */
    .library-concept-scope #hub-card-revision .concept-hub-card-icon--tile-revision,
    .library-concept-scope #hub-card-structured .concept-hub-card-icon--tile-structured,
    .library-concept-scope #hub-card-adaptive .concept-hub-card-icon--tile-adaptive{
      -webkit-mask-image:linear-gradient(to bottom, #000 0%, #000 74%, transparent 100%);
      mask-image:linear-gradient(to bottom, #000 0%, #000 74%, transparent 100%);
    }
    .library-concept-scope #hub-card-iq .concept-hub-card-icon--tile-iq{
      -webkit-mask-image:linear-gradient(to bottom, #000 0%, #000 78%, transparent 100%);
      mask-image:linear-gradient(to bottom, #000 0%, #000 78%, transparent 100%);
    }
    .library-concept-scope #hub-card-cognitive-test .concept-hub-card-icon--tile-cogtest{
      -webkit-mask-image:linear-gradient(to bottom, #000 0%, #000 82%, transparent 100%);
      mask-image:linear-gradient(to bottom, #000 0%, #000 82%, transparent 100%);
    }
    .concept-hub-card-icon--hub-radar{
      position:relative;
      display:block;
      font-size:0;
      width:100%;
      max-width:100%;
      aspect-ratio:1 / 1;
      margin:0;
      flex:0 1 auto;
      min-height:0;
      flex-shrink:0;
      background:none !important;
      overflow:visible;
    }
    .concept-hub-card-icon--hub-radar .hub-radar-svg{
      position:absolute;
      left:50%;
      top:48%;
      transform:translate(-50%,-50%);
      width:72%;
      height:72%;
      max-width:76px;
      max-height:76px;
      pointer-events:none;
    }
    .hub-radar-axis{
      position:absolute;
      font-size:clamp(0.38rem, 2.6vw, 0.55rem);
      font-weight:600;
      color:rgba(226,232,240,0.94);
      line-height:1.05;
      pointer-events:none;
    }
    .hub-radar-axis--speed{ left:50%; top:6%; transform:translateX(-50%); max-width:88%; text-align:center; }
    .hub-radar-axis--logical{ right:4%; top:44%; transform:translateY(-50%); max-width:38%; text-align:right; }
    .hub-radar-axis--wm{ left:50%; bottom:16%; transform:translateX(-50%); max-width:88%; text-align:center; }
    .hub-radar-axis--proc{ left:4%; top:44%; transform:translateY(-50%); max-width:36%; text-align:left; }
    .hub-radar-score{
      position:absolute;
      top:8%;
      right:7%;
      width:20px;
      height:20px;
      border-radius:50%;
      border:1px solid rgba(129,140,248,0.65);
      background:rgba(30,41,59,0.9);
      font-size:0.55rem;
      font-weight:700;
      color:#e2e8f0;
      display:flex;
      align-items:center;
      justify-content:center;
      box-shadow:0 0 10px rgba(99,102,241,0.35);
      line-height:1;
    }
    .library-concept-scope #hub-card-revision .concept-hub-card-icon--tile,
    .library-concept-scope #hub-card-structured .concept-hub-card-icon--tile,
    .library-concept-scope #hub-card-adaptive .concept-hub-card-icon--tile{
      padding-bottom:3px;
    }
    .library-concept-scope #hub-card-iq .concept-hub-card-icon--tile,
    .library-concept-scope #hub-card-cognitive-test .concept-hub-card-icon--tile,
    .library-concept-scope #hub-card-cognitive-profile .concept-hub-card-icon--hub-radar{
      padding-bottom:2px;
    }
    .concept-hub-card--placeholder{
      opacity:0.88;
      border-style:dashed;
      border-color:rgba(148,163,184,.42);
      cursor:not-allowed;
    }
    .concept-hub-card--placeholder:hover{
      transform:none;
      border-color:var(--card-border, rgba(148,163,184,.28));
      box-shadow:0 6px 18px rgba(0,0,0,.12);
    }
    html.concept-mode-on #active-material-bar{ display:none !important; }

    @media print{
      .toast, .tool-tabs, .tools-header, .tool-panel, #open-ink-btn, #open-notebook-btn, #open-calculator-btn, .calculator-overlay, .vkb-panel, .vkb-toggle-btn, .verify-float-pill,
      #continue-box,
      #solution-chat-wrap,
      .answer-actions, #status, .edu-note-small, .subtitle, .answer-header-bar { display:none !important; }
      body{background:#fff}
      main{padding:0}
      .card{box-shadow:none;border:0;border-radius:0;margin:0;padding:0}
      #ai-answer{border:0;background:#fff;padding:0}
      .katex { page-break-inside: avoid !important; }
    }
