:root{--shade-1e1e1e70:#1e1e1e70;--shade-151515:#151515;--shade-292929:#292929;--shade-4e4e4e:#4e4e4e;--shade-757575:#757575;--shade-d9d9d9:#d9d9d9;--shade-140707:#140707;--shade-080808:#080808;--shade-101010:#101010;--shade-5d5d5d:#5d5d5d;--shade-f6f6f6:#f6f6f6;--shade-3d3d3d:#3d3d3d;--shade-272727:#272727;--shade-3c3c3c:#3c3c3c;--shade-3b3b3b:#3b3b3b;--shade-21090c:#21090c;--shade-0d0d0d:#0d0d0d;--shade-565656:#565656;--shade-dedede:#dedede;--shade-161616:#161616;--shade-131313:#131313;--shade-5e5e5e:#5e5e5e;--shade-ff4b55:#ff4b55;--shade-404040:#404040;--shade-6b6b6b:#6b6b6b;--shade-ff7e85:#ff7e85;--shade-d7d7d7:#d7d7d7;--shade-1a1a1a:#1a1a1a;--shade-a7a7a7:#a7a7a7;--shade-747474:#747474;--shade-181818:#181818;--shade-242424:#242424;--shade-1f1f1f:#1f1f1f;--shade-5b5b5b:#5b5b5b;--shade-141414:#141414;--shade-371216:#371216;--shade-858585:#858585;--shade-d8d8d8:#d8d8d8;--shade-4a4a4a:#4a4a4a;--shade-8a8a8a:#8a8a8a;--shade-383838:#383838;--shade-b5b5b5:#b5b5b5;--shade-e09090:#e09090;--shade-6f6f6f:#6f6f6f;--shade-4f4f4f:#4f4f4f;--shade-707070:#707070;--shade-5a1920:#5a1920;--shade-232323:#232323;--shade-0c0c0c:#0c0c0c;--shade-343434:#343434;--shade-090909:#090909;--shade-2a2a2a:#2a2a2a;--shade-121212:#121212;--shade-d6d6d6:#d6d6d6;--shade-1e1e1e:#1e1e1e;--shade-191919:#191919;--shade-656565:#656565;--shade-171717:#171717;--shade-1c1c1c:#1c1c1c;--shade-070707:#070707;--shade-cfcfcf:#cfcfcf;--shade-202020:#202020;--shade-0e0e0e:#0e0e0e;--shade-2d2d2d:#2d2d2d;--shade-0b0b0b:#0b0b0b;--shade-0a0a0a:#0a0a0a;--shade-b9b9b9:#b9b9b9;--shade-1b1b1b:#1b1b1b;--shade-7d7d7d:#7d7d7d;--shade-050505:#050505;--shade-616161:#616161;--shade-ff7b82:#ff7b82;--shade-5f5f5f:#5f5f5f;--shade-252525:#252525;--shade-111111:#111;--shade-bbbbbb:#bbb;--shade-cccccc:#ccc;--shade-777777:#777;--shade-ffffff:#fff;--shade-eeeeee:#eee;--shade-666666:#666;--shade-888888:#888;--shade-aaaaaa:#aaa;--shade-000000:#000;--shade-222222:#222;--shade-444444:#444;--shade-555555:#555;--shade-999999:#999;--shade-333333:#333;
--ui-surface:#080808;--ui-editor-bg:#000;--ui-focus:rgba(250,250,250,.9);--ui-hint:#0f0f0f;--ui-focus-shadow:rgba(255,255,255,.04);--ui-word-count:#686868;--ui-caret:#fff}
html[data-theme="light"]{--shade-1e1e1e70:#e4e4e470;--shade-151515:#f1f1f1;--shade-292929:#d0d0d0;--shade-4e4e4e:#8b8b8b;--shade-757575:#5b5b5b;--shade-d9d9d9:#1a1a1a;--shade-140707:#fff1f2;--shade-080808:#fafafa;--shade-101010:#f4f4f4;--shade-5d5d5d:#737373;--shade-f6f6f6:#101010;--shade-3d3d3d:#afafaf;--shade-272727:#d3d3d3;--shade-3c3c3c:#b0b0b0;--shade-3b3b3b:#b2b2b2;--shade-21090c:#ffe7ea;--shade-0d0d0d:#f6f6f6;--shade-565656:#7b7b7b;--shade-dedede:#181818;--shade-161616:#f0f0f0;--shade-131313:#f3f3f3;--shade-5e5e5e:#717171;--shade-ff4b55:#c22c3f;--shade-404040:#aaaaaa;--shade-6b6b6b:#646464;--shade-ff7e85:#ae253b;--shade-d7d7d7:#1a1a1a;--shade-1a1a1a:#eaeaea;--shade-a7a7a7:#333333;--shade-747474:#5c5c5c;--shade-181818:#ededed;--shade-242424:#d7d7d7;--shade-1f1f1f:#e1e1e1;--shade-5b5b5b:#757575;--shade-141414:#f2f2f2;--shade-371216:#ffcbd0;--shade-858585:#4e4e4e;--shade-d8d8d8:#1a1a1a;--shade-4a4a4a:#949494;--shade-8a8a8a:#4a4a4a;--shade-383838:#b6b6b6;--shade-b5b5b5:#2b2b2b;--shade-e09090:#9c3540;--shade-6f6f6f:#606060;--shade-4f4f4f:#898989;--shade-707070:#5f5f5f;--shade-5a1920:#efb4bd;--shade-232323:#d9d9d9;--shade-0c0c0c:#f7f7f7;--shade-343434:#bdbdbd;--shade-090909:#fafafa;--shade-2a2a2a:#cecece;--shade-121212:#f3f3f3;--shade-d6d6d6:#1b1b1b;--shade-1e1e1e:#e4e4e4;--shade-191919:#ececec;--shade-656565:#696969;--shade-171717:#eeeeee;--shade-1c1c1c:#e8e8e8;--shade-070707:#fbfbfb;--shade-cfcfcf:#1e1e1e;--shade-202020:#dfdfdf;--shade-0e0e0e:#f6f6f6;--shade-2d2d2d:#c9c9c9;--shade-0b0b0b:#f8f8f8;--shade-0a0a0a:#f9f9f9;--shade-b9b9b9:#292929;--shade-1b1b1b:#e9e9e9;--shade-7d7d7d:#545454;--shade-050505:#fcfcfc;--shade-616161:#6e6e6e;--shade-ff7b82:#ae253b;--shade-5f5f5f:#707070;--shade-252525:#d6d6d6;--shade-111111:#f4f4f4;--shade-bbbbbb:#282828;--shade-cccccc:#1f1f1f;--shade-777777:#595959;--shade-ffffff:#0d0d0d;--shade-eeeeee:#121212;--shade-666666:#686868;--shade-888888:#4c4c4c;--shade-aaaaaa:#313131;--shade-000000:#ffffff;--shade-222222:#dadada;--shade-444444:#a1a1a1;--shade-555555:#7c7c7c;--shade-999999:#3e3e3e;--shade-333333:#bebebe;
--ui-surface:#fafafa;--ui-editor-bg:#fff;--ui-focus:#252525;--ui-hint:#ffffff;--ui-focus-shadow:rgba(0,0,0,.04);--ui-word-count:#626262;--ui-caret:#111}

/* V3: theme-aware surfaces, controls, editor and accessible writing preferences */
html{color-scheme:dark;scrollbar-color:#242424 #000}
html[data-theme="light"]{color-scheme:light;scrollbar-color:#d5d5d5 #fff}
html[data-theme="light"] .topbar{background:rgba(255,255,255,.94);border-bottom-color:#ebebeb}
html[data-theme="light"] .side-panel{box-shadow:-16px 0 60px rgba(28,28,28,.12)}
html[data-theme="light"] .modal{box-shadow:0 28px 100px rgba(30,30,30,.16)}
html[data-theme="light"] .context-menu,html[data-theme="light"] .math-assist{box-shadow:0 16px 48px rgba(30,30,30,.12)}
html[data-theme="light"] .note-card{box-shadow:0 2px 9px rgba(0,0,0,.025)}
html[data-theme="light"] .note-card:hover{box-shadow:0 10px 22px rgba(0,0,0,.055)}
html[data-theme="light"] .note-body::placeholder{color:#acacac}
html[data-theme="light"] .note-title-input::placeholder{color:#bcbcbc}
html[data-theme="light"] .scan-result textarea,html[data-theme="light"] .feature-input{color:#222}
html[data-theme="light"] .graph-stage{background:#fff}
html[data-theme="light"] .drawing-preview img{background:#111;border-radius:6px}
html[data-theme="light"] .draw-panel canvas{background:#fafafa}
html[data-theme="light"] .secondary-btn:hover{box-shadow:0 0 0 1px rgba(0,0,0,.04)}
html[data-theme="light"] .modal-backdrop{background:rgba(25,25,25,.25)}
html[data-theme="light"] .note-body.grid-paper{background-image:linear-gradient(#d5d5d580 1px,transparent 1px),linear-gradient(90deg,#d5d5d580 1px,transparent 1px)}
/* Editor must never create a white focus rectangle (desktop, touch or keyboard). */
.note-body,.note-body:focus,.note-body:focus-visible,
.note-title-input,.note-title-input:focus,.note-title-input:focus-visible{
  background-color:transparent!important;border:0!important;outline:0!important;
  box-shadow:none!important;-webkit-appearance:none;appearance:none;
  -webkit-tap-highlight-color:transparent;caret-color:var(--ui-caret);
}
.note-body.grid-paper{background-color:transparent!important}
.note-write,.note-write:focus-within{outline:none!important;box-shadow:none!important;border:0!important}
.note-body{line-height:1.74;letter-spacing:-.018em;tab-size:4}
.note-body::selection,.note-title-input::selection{background:rgba(130,130,130,.3)}
.editor-meta-end{margin-left:auto;color:var(--ui-word-count)}
.note-layout{transition:gap .22s var(--ease)}
.editor-tools button:active,.note-card:active,.primary-btn:active,.secondary-btn:active{transform:scale(.985)}
button:focus-visible,input:not(.note-title-input):focus-visible,textarea:not(.note-body):focus-visible,select:focus-visible{outline:2px solid var(--ui-focus);outline-offset:3px}
.appearance-btn{transition:transform .2s var(--ease),background .2s var(--ease)}
.appearance-btn:active{transform:rotate(30deg) scale(.91)}
.settings-modal{width:min(510px,calc(100vw - 30px));max-height:90vh;overflow:auto}
.setting-group{padding:18px 0;border-top:1px solid var(--shade-222222)}
.setting-heading strong{font-size:14px;font-weight:700}
.setting-heading p{font-size:12px;color:var(--shade-777777);line-height:1.6;margin:5px 0 15px}
.setting-segment{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;border:1px solid var(--shade-222222);background:var(--shade-0c0c0c);border-radius:12px;padding:4px}
.setting-segment button{background:none;border:0;border-radius:9px;padding:11px 4px;color:var(--shade-888888);font-size:12px;font-weight:650}
.setting-segment button.active{background:var(--shade-ffffff);color:var(--shade-000000);box-shadow:0 2px 10px rgba(0,0,0,.05)}
.setting-switch{display:flex;align-items:center;justify-content:space-between;gap:20px;position:relative;min-height:66px;padding:12px 0;cursor:pointer}
.setting-switch+ .setting-switch{border-top:1px solid var(--shade-1b1b1b)}
.setting-switch span{display:grid;gap:4px;min-width:0}.setting-switch strong{font-size:13px;font-weight:620}.setting-switch small{font-size:11px;color:var(--shade-777777);line-height:1.4}
.setting-switch input{position:absolute;opacity:0;width:1px;height:1px;right:0}
.setting-switch i{flex:0 0 40px;height:23px;position:relative;border:1px solid var(--shade-333333);border-radius:20px;background:var(--shade-292929);transition:background .2s var(--ease)}
.setting-switch i::before{content:"";position:absolute;left:2px;top:2px;width:17px;height:17px;background:var(--shade-aaaaaa);border-radius:50%;transition:transform .2s var(--ease)}
.setting-switch input:checked+i{background:var(--shade-ffffff);border-color:var(--shade-ffffff)}
.setting-switch input:checked+i::before{background:var(--shade-000000);transform:translateX(17px)}
.setting-switch input:focus-visible+i{outline:2px solid var(--ui-focus);outline-offset:3px}
.settings-footnote{font-size:11px;line-height:1.6;color:var(--shade-777777);padding:5px 0 0}
.correction-hint{position:fixed;right:24px;bottom:22px;z-index:145;background:var(--ui-hint);border:1px solid var(--shade-292929);box-shadow:0 12px 42px rgba(0,0,0,.17);border-radius:11px;display:flex;align-items:center;gap:15px;max-width:calc(100vw - 28px);padding:11px 12px;color:var(--text);font-size:12px;animation:hintIn .18s var(--ease)}
.correction-hint span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.correction-hint button{border:0;border-left:1px solid var(--shade-292929);padding:3px 3px 3px 12px;background:transparent;color:var(--shade-aaaaaa);font-size:12px;font-weight:650}
.correction-hint button:hover{color:var(--text)}
@keyframes hintIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
::selection{background:rgba(120,120,120,.27)}
@media(max-width:620px){.topbar{padding:0 12px}.top-actions .icon-btn{width:34px;height:36px}.appearance-btn{display:grid}.editor-meta-end{margin-left:auto}.correction-hint{right:10px;bottom:10px}.setting-group{padding:14px 0}}
@media print{.settings-modal,.correction-hint{display:none!important}}
/* Print is always ink on paper, regardless of selected display theme. */
@media print {
  body.printing-note,body.printing-note #printSheet {background:#fff!important;color:#111!important}
  body.printing-note #printSheet *{color:#111!important}
  body.printing-note .note-title-input,body.printing-note .note-body{background:transparent!important;color:#111!important}
}
