:root{--surface:#fafaf7;--surface-raised:#ffffff;--surface-alt:#f3f5ef;--ink:#252925;--ink-soft:#56634e;--ink-muted:#78836f;--border:#dfe4d9;--accent:#246b57;--editor-max-height:88dvh;color-scheme:light}
:root[data-theme=dark]{--surface:#131c1b;--surface-raised:#1e2b29;--surface-alt:#182321;--ink:#edf2ee;--ink-soft:#d1ddd5;--ink-muted:#a3b6aa;--border:#384c43;--accent:#80d1b2;--line:#30423b;--green:#80d1b2;color-scheme:dark}
.header-actions{display:flex;align-items:center;gap:10px;margin-left:auto;flex-shrink:0}.header-actions .avatar{margin-left:0}.header-actions .icon-button{width:40px;height:40px}.install-button{font-size:12px;padding:9px 13px;min-height:40px;gap:7px}.install-button svg{width:17px;height:17px}.breadcrumb img{width:30px;height:30px;flex-shrink:0}.brand{color:#003e3e;gap:10px}.brand>img{width:42px;height:42px}.brand-dot{display:none}.topbar-caption{margin-left:auto}.header-actions+.topbar-caption{display:none}.install-guide{font-size:13px;line-height:1.85}.install-guide>img{display:block;margin-bottom:16px}.install-guide p{color:var(--ink-soft)}
/* Header and toolbar have opaque, separate rows; only the writing area scrolls. */
.editor-dialog{max-height:var(--editor-max-height);overflow:hidden;--editor-bg:#fafaf7;background:var(--editor-bg)!important}
#editor-form{display:flex;flex-direction:column;max-height:calc(var(--editor-max-height) - 2px);overflow:hidden;margin:0}
.editor-scroll{overflow:auto;overscroll-behavior:contain;min-height:0;scroll-padding-block:18px;-webkit-overflow-scrolling:touch}
.editor-top,.editor-footer{flex:0 0 auto;position:relative;background:var(--editor-bg);isolation:isolate}
.editor-top{border-bottom:1px solid #0000000a}.editor-footer{bottom:auto;border-top:1px solid #00000016;box-shadow:0 -5px 18px #182d2010;padding-bottom:max(13px,env(safe-area-inset-bottom))}
.editor-footer .button{flex-shrink:0;min-height:42px}.editor-tools{min-width:0;gap:3px}.editor-tools .icon-button{min-width:32px;min-height:36px}.editor-panel{flex-shrink:0}.editor-block textarea{scroll-margin-block:18px}
/* Each note retains its colour in both themes, with a suitably dark equivalent. */
[data-theme=dark] body{background:var(--surface);color:var(--ink)}
[data-theme=dark] .sidebar,[data-theme=dark] .topbar{background:var(--surface-alt);border-color:var(--border)}
[data-theme=dark] .brand{color:var(--ink)}
[data-theme=dark] :is(.breadcrumb,.topbar-caption,.eyebrow,.page-heading p,.results-meta,.page-footer,.empty-state p,.empty-hint,.section-label,.local-note,.local-note small,.note-section-title,.help,.editor-links-title,.weekday){color:var(--ink-muted)}
[data-theme=dark] :is(.sidebar-link,.icon-button,.view-picker select){color:var(--ink-soft)}
[data-theme=dark] :is(.sidebar-link:hover,.icon-button:hover,.sidebar-link.active){background:#2c4036;color:#98e3c3}
[data-theme=dark] :is(.sidebar-divider,.toolbar-divider){background:var(--border)}
[data-theme=dark] .local-note{border-color:var(--border)}
[data-theme=dark] :is(.search-box,.filters,.view-picker select,.tool-buttons .button,.text-input,.field input,.field select,#hijri-calendar){background:var(--surface-raised);border-color:var(--border);color:var(--ink)}
[data-theme=dark] :is(input,textarea)::placeholder{color:#95a99a}
[data-theme=dark] :is(.search-box input,.label-manager-row input){color:var(--ink)}
[data-theme=dark] :is(.secondary,.color-dot,.detected-links a){border-color:var(--border)}
[data-theme=dark] .secondary:hover{background:#2c4036}
[data-theme=dark] .primary{background:#286e58;color:#fff}
[data-theme=dark] .primary:hover{background:#327e66}
[data-theme=dark] kbd{background:#253b30;color:#b4d9c1;border-color:#405748}
[data-theme=dark] dialog{background:var(--surface-raised);color:var(--ink);border-color:var(--border);box-shadow:0 24px 100px #0006}
[data-theme=dark] dialog::backdrop{background:#020a08a6}
[data-theme=dark] .editor-dialog{--editor-bg:#1e2b29!important}
[data-theme=dark] :is(.editor-top,.editor-footer){border-color:var(--border)}
[data-theme=dark] :is(#note-title,.editor-block textarea){color:var(--ink)}
[data-theme=dark] #save-status{color:var(--ink-muted)}
[data-theme=dark] :is(#note-title::placeholder,.editor-block textarea::placeholder){color:#9cb09f}
[data-theme=dark] .editor-panel{background:#24372e;border-color:var(--border)}
[data-theme=dark] :is(.editor-tools .active,.calendar-day.selected){background:#326448;color:#e2f9e8}
[data-theme=dark] :is(.settings-section,.label-manager-row){border-color:var(--border)}
[data-theme=dark] :is(.settings-section p,.settings-section dl,.setting-switch small,.locked-description,.filter-label,.filter-group label,.field,.calendar-header){color:var(--ink-muted)}
[data-theme=dark] :is(.settings-section dt,.hijri-preview){color:#9ce0bb}
[data-theme=dark] :is(.calendar-day,.detected-links a){background:#283d31;color:#cce9d4}
[data-theme=dark] .calendar-day:hover{background:#38553f}
[data-theme=dark] .note-card,[data-theme=dark] .editor-dialog{--editor-bg:var(--surface-raised)}
[data-theme=dark] [data-color="0"]{--note-dark:#22312d}
[data-theme=dark] [data-color="1"]{--note-dark:#3b3524}
[data-theme=dark] [data-color="2"]{--note-dark:#273b2a}
[data-theme=dark] [data-color="3"]{--note-dark:#24373e}
[data-theme=dark] [data-color="4"]{--note-dark:#332e44}
[data-theme=dark] [data-color="5"]{--note-dark:#402f35}
[data-theme=dark] .note-card{background:var(--note-dark,var(--surface-raised))!important;border-color:#ffffff12}
[data-theme=dark] .editor-dialog{--editor-bg:var(--note-dark,var(--surface-raised))!important}
[data-theme=dark] :is(.card-title,.card-body){color:var(--ink-soft)}
[data-theme=dark] :is(.card-meta,.card-reminder,.card-pin){color:#adc5af;border-color:#ffffff15}
[data-theme=dark] .tag-pill{background:#ffffff0b;color:#c2d7be}
[data-theme=dark] :is(.inline-link,.card-quick-actions .button){color:#9ee0c4}
[data-theme=dark] .card-quick-actions .button{background:#ffffff08}
[data-theme=dark] :is(.empty-paper,.empty-art:before,.empty-art:after){background:#263c30;border-color:var(--border)}
[data-theme=dark] :is(.banner,.diag-log){background:#243c2d;color:#c9ead3;border-color:var(--border)}
[data-theme=dark] .danger,[data-theme=dark] .error-text{color:#ffaaa3}
[data-theme=dark] .toast{background:#365541;color:#f6fff6}
[data-theme=dark] .toast.error{background:#793f3a}
@media(max-width:760px){.topbar{padding-inline:16px;gap:10px}.topbar .breadcrumb{gap:7px;font-size:12px}.topbar .breadcrumb>span{display:none}.header-actions{gap:6px}.header-actions .avatar{width:32px;height:32px}.topbar-caption{display:none}.install-button{padding:8px 10px;gap:6px}.install-button .install-name{display:none}.editor-footer{padding:10px 12px max(10px,env(safe-area-inset-bottom));gap:8px}.editor-tools{flex-wrap:nowrap;overflow-x:auto}.editor-tools .icon-button{width:32px;flex-shrink:0}.editor-footer .button{padding:10px 13px;font-size:12px}.editor-scroll{scrollbar-width:thin}}
@media(max-width:360px){.editor-tools .icon-button{width:29px;min-width:29px}.editor-footer{padding-inline:8px}.editor-footer .button{padding-inline:10px}.header-actions{gap:3px}.topbar{padding-inline:12px}}
@media(max-width:760px){.editor-tools{gap:0}.editor-tools .toolbar-divider{display:none}}
@media(max-width:340px){.editor-footer{flex-wrap:wrap}.editor-tools{width:100%;justify-content:space-between}.editor-footer>.button{margin-left:auto}}

@media (max-width: 760px) {
  .editor-dialog {
    position: fixed;
    inset: var(--editor-viewport-top, 0px) 0 auto;
    width: 100%;
    max-width: none;
    height: var(--editor-viewport-height, 100dvh);
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  #editor-form {
    height: 100%;
    max-height: none;
  }

  .editor-scroll {
    flex: 1;
  }

  .editor-content {
    padding: 10px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left));
  }

  .editor-block textarea {
    font-size: 16px;
  }

  .editor-top {
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  }

  .editor-footer {
    padding-block: 8px max(8px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
}

.settings-button svg{width:22px;height:22px;stroke-width:1.65}

.editor-insert{display:flex;align-items:center;flex-wrap:wrap;gap:8px 14px}
#preview-toggle{color:var(--accent)}
.editor-image-row{display:flex;align-items:flex-start;gap:8px;margin:12px 0}
.editor-image-row .icon-button{flex-shrink:0}
.note-image{display:block;max-width:100%;max-height:430px;object-fit:contain;border-radius:9px}
.editor-image-row .note-image{max-width:calc(100% - 42px)}
.note-image-compact{max-height:128px;margin:6px 0}
.large-grid .note-image-compact{max-height:260px}
#note-preview{color:var(--ink);font-size:15px;line-height:1.8;overflow-wrap:anywhere;white-space:pre-wrap}
#note-preview h3{font-size:23px;line-height:1.4;margin:12px 0}
#note-preview p{margin:0 0 10px}
#note-preview .note-image{margin:12px 0}
