
:root{--green:#059669;--light:#ecfdf5;--border:#e2e8f0;--muted:#64748b;--sidebar:#f8fafc;--paper:#fff;--text:#1e293b;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Meiryo,sans-serif;font-size:14px;color:var(--text);line-height:1.5}body{overflow:hidden;background:#f1f5f9}.appbar{height:48px;display:flex;align-items:center;justify-content:space-between;padding:0 16px;gap:16px;background:var(--paper);border-bottom:1px solid var(--border)}.appbar-left,.appbar-right{display:flex;align-items:center;gap:12px}.appbar .brand{margin:0;font-size:18px;color:var(--green);gap:8px}.appbar .brand-mark{background:none;color:var(--green);width:24px;height:24px;font:700 22px/1 system-ui}.preview-label{font-size:11px;color:#047857;background:#d1fae5;padding:2px 7px;border-radius:4px}.appbar .search-box{width:270px;border:0;background:#f1f5f9;height:30px}.search-box input{font-size:13px;padding:4px 0}.search-box kbd{display:none}.appbar-right>button{padding:5px 7px;color:var(--muted)}.workspace{height:calc(100dvh - 48px);grid-template-columns:256px 320px minmax(0,1fr)}.sidebar{padding:12px 8px;gap:0}.new-note{width:calc(100% - 8px);margin:0 4px 16px;padding:8px 12px;justify-content:center;border-radius:8px;font-weight:500}.new-note kbd{display:none}.primary:hover{background:#047857}.quick-label,.section-label{color:#94a3b8;font-size:12px;letter-spacing:.035em;font-weight:600;padding:0 8px;margin:0 0 5px}.section-label{margin:18px 0 5px;padding:0 8px}.section-label button{font-size:16px}.nav-item{font-size:14px;line-height:20px;padding:6px 10px;gap:8px;border-radius:6px;color:#334155}.nav-item.active{background:#ecfdf5;color:#059669}.nav-item[data-view=favorite]{color:#a16207}.nav-item[data-view=pinned]{color:#e11d48}.nav-item[data-view=recent]{color:#2563eb}.book-row button{padding:6px 10px;line-height:20px;font-size:14px;color:#475569}.tag-search{display:none}.tag-list{margin:5px 8px;gap:4px}.tag-chip{border:0;border-radius:999px;background:#e2e8f0;color:#475569;font-size:12px;padding:2px 8px}.sidebar-bottom{margin-top:20px;padding-top:0}.sidebar-bottom .nav-item{font-size:14px}.account{margin-top:24px;color:#94a3b8}.list-header{padding:12px 12px 0}.list-heading h1{font-size:14px;font-weight:600;margin:0;line-height:22px}.list-controls{padding:8px 0;font-size:12px}.list-controls select{margin-left:auto;background:#f1f5f9;border-radius:4px;padding:4px 6px}.list-controls button{padding:4px}.list-controls #note-count{font-size:12px;color:#94a3b8}#bulk-bar{padding-bottom:6px;font-size:11px}#bulk-bar button{font-size:11px;padding:3px}.note-card{padding:12px;border-left:4px solid transparent}.note-card.selected{background:#ecfdf599;border-left-color:#10b981;box-shadow:none}.card-top{gap:6px}.card-top input{display:none}.card-top h2{font-size:14px;line-height:20px;margin-bottom:4px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.card-flags{color:#f59e0b}.note-card p{font-size:12px;line-height:18px;margin:0 0 6px;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.card-meta{font-size:11px;line-height:16px;color:#94a3b8}.card-tags{margin-top:5px;gap:4px}.card-tags span{font-size:11px;background:#f1f5f9;color:#64748b;padding:0 4px;border-radius:3px}.pagination{padding:3px;font-size:11px}.pagination button{padding:5px 12px}.editor-pane{overflow:hidden}#note-editor{height:100%;display:flex;flex-direction:column;min-height:0}.editor-header{padding:8px 12px 2px;min-height:36px;border:0;gap:4px;flex-shrink:0}.editor-header select{font-size:12px;padding:3px 0;max-width:150px}.editor-header #save-state{margin-left:10px;font-size:11px;font-style:italic;color:#94a3b8}.editor-header #favorite{margin-left:auto}.editor-header button{padding:4px 7px;font-size:13px}.document-meta{padding:6px 12px 10px;flex-shrink:0}#note-title{font-size:24px;line-height:32px;letter-spacing:0;font-weight:700;margin:0 0 8px}#note-dates{display:none}.note-tags{margin:0;gap:4px}.note-tags .tag-chip{font-size:12px;background:#f1f5f9}.text-button{color:var(--green);font-size:12px;padding:2px 6px}.toolbar{background:#f8fafc;padding:5px 12px;gap:1px;position:static;flex-shrink:0}.toolbar button{font-size:12px;padding:4px 5px;min-width:25px;line-height:18px}.toolbar select{font-size:12px;padding:3px;max-width:110px;background:transparent}.toolbar-sep{height:18px;margin:0 4px}.color-tool{font-size:11px;margin:0 3px}.color-tool input{height:12px;width:20px}.writing-area{display:flex;flex:1;min-height:0;overflow:hidden}#body.rich-content{min-height:0;flex:1;min-width:0;padding:24px;overflow:auto;font-size:16px;line-height:1.5}.rich-content h1{font-size:28px;line-height:1.3;font-weight:700;margin:16px 0 8px}.rich-content h2{font-size:22.4px;line-height:1.35;font-weight:600;margin:13.6px 0 6.4px}.rich-content h3{font-size:18.4px;line-height:1.4;margin:12px 0 4.8px}.rich-content p{margin:0 0 8px}.rich-content ul,.rich-content ol{margin:0 0 8px;padding-left:24px}.rich-content blockquote{border-left:4px solid #10b981;background:transparent;padding:0 0 0 16px;margin:8px 0;color:#64748b;font-style:italic}.rich-content input[type=checkbox]{width:16px;height:16px;vertical-align:middle}.outline{width:192px;flex-shrink:0;background:#f8fafc;border-left:1px solid var(--border);padding:12px;overflow:auto}.outline-title{font-size:12px;font-weight:600;color:#94a3b8;margin-bottom:8px}.outline #toc{display:block;margin:0;padding:0;background:none}.outline #toc a{font-size:12px;line-height:18px;padding:2px 0;color:#64748b;text-decoration:none}.outline #toc a:hover{color:#059669}.attachments-section{padding:8px 12px 10px;background:#f8fafc;flex-shrink:0}.attachment-heading h2{font-size:12px;margin:0;color:#64748b}.attachment-heading button{font-size:12px;color:#059669;padding:3px 0}.attachments-section>.muted{font-size:11px;margin:3px 0 0;color:#94a3b8}.editor-footer{padding:4px 12px;min-height:28px;font-size:11px;flex-shrink:0}.editor-footer button{font-size:11px;padding:2px 6px}#internal-links{display:none}body.dark{--paper:#0f172a;--sidebar:#1e293b;--border:#334155;--text:#f1f5f9;--muted:#94a3b8;background:#0f172a}.dark .toolbar,.dark .outline,.dark .attachments-section{background:#1e293b}.dark .nav-item,.dark .book-row button{color:#cbd5e1}.dark .note-card.selected,.dark .nav-item.active{background:#334155}.dark .search-box,.dark .card-tags span,.dark .tag-chip,.dark .note-tags .tag-chip,.dark .list-controls select{background:#334155;color:#cbd5e1}.dark .appbar input{color:#f1f5f9}.dark .outline #toc a{color:#cbd5e1}@media(max-width:1200px){.workspace{grid-template-columns:220px 290px minmax(0,1fr)}.outline{width:160px}#body.rich-content{padding:20px}}@media(max-width:1050px){.outline{display:none}}@media(min-width:851px){.appbar .mobile-only{display:none}}@media(max-width:850px){.workspace{grid-template-columns:285px minmax(0,1fr)}.workspace[data-mobile=nav] .sidebar{top:48px}.appbar .search-box{width:220px}.preview-label{display:none}.editor-header{flex-wrap:nowrap}.list-heading h1{margin:0}.list-heading button{margin-bottom:0}.appbar-left{gap:5px}}@media(max-width:600px){.appbar{padding:0 8px;gap:6px}.appbar-right{gap:1px}.appbar .search-box{width:135px}.appbar .brand{font-size:16px}.appbar .brand-mark{display:none}.workspace{display:block}.note-list,.editor-pane{height:calc(100dvh - 48px)}.document-meta{padding:6px 14px 10px}#note-title{font-size:22px;line-height:30px}.toolbar{padding:5px 8px}.toolbar button{min-height:28px}#body.rich-content{padding:20px 16px}.editor-header{padding:6px 8px}.editor-header #save-state{margin-left:0;font-size:10px}.editor-header select{max-width:70px}.editor-header button{min-width:25px;padding:4px;font-size:12px}.appbar-right button{padding:5px}.appbar [data-action=settings]{display:none}}

@media(min-width:851px){:root{font-family:Meiryo,"メイリオ","Yu Gothic UI",sans-serif}}
body{color-scheme:light}body.dark{color-scheme:dark;--green:#34d399;--light:#233c37;--danger:#fda4af}
#theme-preview{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:30px;font-size:12px;white-space:nowrap;border:1px solid var(--border);border-radius:6px}
.dark .primary{background:#059669;border-color:#059669;color:#fff}.dark .primary:hover{background:#047857}
.dark .preview-label{background:#064e3b;color:#a7f3d0}.dark .appbar .brand{color:#34d399}
.dark .nav-item.active{background:#163c33;color:#6ee7b7}.dark .note-card.selected{background:#16332d;border-left-color:#34d399}
.dark .card-tags span,.dark .tag-chip{color:#cbd5e1}.dark .card-meta,.dark .quick-label,.dark .section-label,.dark .outline-title,.dark .account,.dark .attachments-section>.muted,.dark .editor-header #save-state{color:#94a3b8}
.dark .rich-content blockquote{color:#cbd5e1;border-left-color:#34d399}.dark .text-button,.dark .attachment-heading button,.dark a{color:#6ee7b7}
.dark .outline #toc a:hover{color:#6ee7b7}.dark .editor-header button.on{color:#6ee7b7;background:#164e3b}
.dark .rich-content td,.dark .rich-content th{border-color:#475569}.dark #toast{background:#d1fae5;color:#064e3b}
@media(max-width:600px){#theme-preview{padding:5px;min-width:32px}.theme-label{display:none}}

/* Keep live application controls and long attachment lists usable. */
[hidden]{display:none!important}.tag-search{display:block}.card-top input{display:inline-block}#internal-links{display:block;max-height:65px;overflow:auto}#note-dates{display:block;font-size:11px;margin-bottom:5px}.attachments-section{max-height:24vh;overflow:auto}.list-header{max-height:65vh;overflow:auto}body:not([data-logged-in="1"]){overflow:auto}.auth{max-width:460px}.dark .modal,.dark dialog{background:var(--paper);color:var(--text)}.outline #toc{display:block}.rich-content#body{min-height:0;padding:24px}.appbar .mobile-only{margin:0}.dark input,.dark select,.dark textarea{color-scheme:dark}@media(max-width:600px){.rich-content#body{padding:20px 16px}.appbar .mobile-only{min-width:28px;min-height:30px}.attachments-section{max-height:22vh}}
body.dark .primary{color:#fff}body.dark .nav-item.active{background:#163c33;color:#6ee7b7}body.dark .note-card.selected{background:#16332d}.outline #toc{font-size:12px;line-height:1.5;color:var(--muted)}

/* Explicit native popup colors: transparent select backgrounds can yield white popups. */
body .toolbar select{background-color:var(--paper);color:var(--text);color-scheme:light}
body .toolbar select option,body .toolbar select optgroup{background-color:var(--paper);color:var(--text)}
body.dark .toolbar select{background-color:#1e293b;color:#f1f5f9;color-scheme:dark}
body.dark .toolbar select option,body.dark .toolbar select optgroup{background-color:#1e293b;color:#f1f5f9}

/* Keep the note attachment header visible; scroll the cards independently. */
.workspace>.editor-pane{min-height:0}.writing-area{min-height:0;flex:1 1 0}
#note-editor>.attachments-section{display:flex;flex-direction:column;overflow:hidden;max-height:32dvh;min-height:100px;flex:0 0 auto}
.attachments-section .attachment-heading{flex:0 0 auto;flex-wrap:wrap;gap:4px 10px}
.attachments-section .attachment-heading h2{margin-right:auto;white-space:nowrap}
.attachments-section>.muted{flex:0 0 auto}
#attachments{min-height:0;overflow-y:scroll;overflow-x:hidden;scrollbar-gutter:stable;flex:1 1 auto}
#attachments .attachment-card{min-height:58px;margin:5px 0;padding:7px}
#attachments .file-info{min-width:0}#attachments .file-info strong{overflow-wrap:anywhere}
#note-attachments-all{border:1px solid var(--border);border-radius:4px;padding:3px 7px}
@media(max-width:600px){#note-editor>.attachments-section{max-height:30dvh;min-height:104px}.attachment-heading h2{font-size:12px}}
@media(max-height:550px){#note-editor>.attachments-section{max-height:35dvh;min-height:85px}}

/* Explicit height chain prevents intrinsic image size from growing the grid row. */
@media screen {
 .workspace{height:calc(100dvh - 48px);min-height:0;grid-template-rows:minmax(0,1fr);overflow:hidden}
 .workspace>.sidebar,.workspace>.note-list,.workspace>.editor-pane{min-height:0;max-height:100%}
 .workspace>.editor-pane{height:100%;overflow:auto}
 #note-editor{height:100%;max-height:100%;min-height:0;overflow:auto}
 #note-editor>.writing-area{height:0;min-height:80px;flex:1 1 0;overflow:hidden}
 .writing-area>#body.rich-content{height:100%;max-height:100%;min-height:0;overflow-y:scroll;overflow-x:auto;scrollbar-gutter:stable;overscroll-behavior:contain}
 .writing-area>.outline{height:100%;min-height:0;overflow-y:auto}
 #body::-webkit-scrollbar{width:14px;height:14px}
 #body::-webkit-scrollbar-track{background:#e2e8f0;border-left:1px solid #cbd5e1}
 #body::-webkit-scrollbar-thumb{background:#64748b;border:3px solid #e2e8f0;border-radius:9px;min-height:32px}
 #body::-webkit-scrollbar-thumb:hover{background:#334155}
 body.dark #body::-webkit-scrollbar-track{background:#1e293b;border-color:#475569}
 body.dark #body::-webkit-scrollbar-thumb{background:#94a3b8;border-color:#1e293b}
 body.dark #body::-webkit-scrollbar-thumb:hover{background:#cbd5e1}
}

/* Persistent desktop scrollbar, independent of OS overlay preferences. */
.body-scrollbar{display:none}
@media(min-width:851px){
 .body-scrollbar{display:block;position:relative;flex:0 0 18px;align-self:stretch;background:#e2e8f0;border:1px solid #cbd5e1;touch-action:none;cursor:pointer}
 .body-scrollbar:focus-visible{outline:2px solid var(--green);outline-offset:-2px}
 .body-scrollbar-thumb{position:absolute;left:3px;right:3px;top:0;min-height:28px;background:#64748b;border-radius:8px;pointer-events:none}
 .body-scrollbar[aria-disabled=true] .body-scrollbar-thumb{opacity:.3}
 .dark .body-scrollbar{background:#1e293b;border-color:#475569}
 .dark .body-scrollbar-thumb{background:#cbd5e1}
 .writing-area.has-scrollbar>#body{scrollbar-width:none}
 .writing-area.has-scrollbar>#body::-webkit-scrollbar{width:0}
}
#body a[href]{text-decoration:underline;cursor:pointer;overflow-wrap:anywhere}

/* Collapsible attachments on all screens; compact tools on phones. */
.mobile-fold-controls{display:none}
#attachments-toggle{display:block;flex:0 0 auto;width:100%;text-align:left;color:var(--text);font:inherit;font-size:13px;padding:8px 0;min-height:36px}
#note-editor>.attachments-section.is-collapsed{min-height:0;max-height:none;padding:0 12px;flex:0 0 auto}
#note-editor>.attachments-section.is-collapsed>:not(#attachments-toggle){display:none!important}
.attachments-section:not(.is-collapsed) #attachments-toggle{padding:0;min-height:32px}
@media(max-width:600px){
 .mobile-fold-controls{display:flex;gap:8px;padding:0 12px 4px;flex-shrink:0;border-bottom:1px solid var(--border)}
 .mobile-fold-controls button{padding:6px 10px;min-height:36px;font-size:13px;background:var(--sidebar);border:1px solid var(--border);border-radius:5px}
 #note-editor:not(.format-expanded)>#note-format-panel{display:none}
 #note-editor:not(.detail-expanded) #note-detail-panel{display:none}
 #note-editor .document-meta{padding:4px 12px 2px}
 #note-editor #note-title{font-size:20px;line-height:28px;margin-bottom:4px}
 #note-editor #note-format-panel{max-height:28dvh;overflow-y:auto}
 #note-detail-panel{max-height:22dvh;overflow-y:auto}
 #note-editor #note-dates{white-space:normal;overflow-wrap:anywhere}
 #note-editor .rich-content#body{padding:14px 16px}
 #attachments-toggle{min-height:40px}
}
