/* Compact reading and editing, with optional metadata out of the main flow. */
#page-memory-space {
    --ms-bg:var(--bg,#f6f5f2); --ms-paper:var(--card,#fff);
    --ms-line:var(--border,#e6e3dd); --ms-ink:var(--text,#383630); --ms-muted:var(--text3,#8c887f);
    --ms-wash:color-mix(in srgb,var(--ms-ink) 4%,var(--ms-bg));
    display:flex; flex-direction:column; overflow:hidden; background:var(--ms-bg); color:var(--ms-ink);
}
#page-memory-space [hidden] { display:none!important; }
#page-memory-space button,#page-memory-space input,#page-memory-space select,#page-memory-space textarea { font:inherit; color:inherit; }
#page-memory-space button { cursor:pointer; }
#page-memory-space button:disabled { opacity:.3; cursor:default; }
.memory-space-accessible-label,.memory-space-note-title > span,.memory-space-note-content > span { position:absolute; width:1px; height:1px; clip-path:inset(50%); overflow:hidden; white-space:nowrap; }
.memory-space-header { display:flex; align-items:center; gap:4px; flex:none; min-height:calc(60px + var(--safe-top)); padding:calc(6px + var(--safe-top)) 14px 6px; }
.memory-space-header h1 { flex:1; font-size:17px; font-weight:550; }
.memory-space-header > button,.memory-space-options > summary { display:grid; place-items:center; width:44px; height:44px; border:0; border-radius:6px; background:transparent; list-style:none; }
.memory-space-header svg { width:22px; height:22px; }
.memory-space-header > button:active,.memory-space-options[open] > summary { background:var(--ms-wash); }
.memory-space-options { position:relative; z-index:5; }
.memory-space-options > summary { cursor:pointer; }
.memory-space-options > summary::-webkit-details-marker { display:none; }
.memory-space-options-panel { position:absolute; right:0; top:46px; width:244px; max-width:calc(100vw - 40px); padding:6px; border:1px solid var(--ms-line); border-radius:12px; background:var(--ms-paper); box-shadow:0 6px 24px rgb(0 0 0 / .08); }
.memory-space-options-panel label,.memory-space-options-panel button { display:flex; align-items:center; gap:10px; width:100%; min-height:44px; padding:10px; font-size:13px; text-align:left; }
.memory-space-options-panel input { width:18px; height:18px; accent-color:var(--ms-ink); }
.memory-space-toolbar { display:flex; align-items:center; justify-content:space-between; gap:16px; flex:none; padding:0 24px; }
#memory-space-assistant { min-width:0; max-width:50%; min-height:44px; padding:8px 20px 8px 0; border:0; border-radius:0; background:transparent; font-size:14px; text-overflow:ellipsis; }
.memory-space-tabs { display:flex; gap:20px; flex:none; }
.memory-space-tabs button { min-height:44px; padding:10px 0; border-bottom:2px solid transparent; color:var(--ms-muted)!important; font-size:13px; }
.memory-space-tabs button[aria-current="page"] { border-color:var(--ms-ink); color:var(--ms-ink)!important; }
.memory-space-content { flex:1; min-height:0; overflow-y:auto; padding:12px 24px calc(24px + var(--safe-bottom)); overscroll-behavior:contain; }
.memory-space-search { display:flex; align-items:center; gap:8px; min-height:44px; margin-bottom:10px; padding:0 11px; border-radius:9px; background:var(--ms-wash); color:var(--ms-muted); }
.memory-space-search svg { width:17px; height:17px; flex:none; }
#memory-space-search { width:100%; min-width:0; min-height:44px; padding:8px 0; border:0; background:transparent; font-size:16px; }
.memory-space-letters { display:block; }
.memory-letter { min-width:0; border-bottom:1px solid var(--ms-line); }
.memory-letter:last-child { border-bottom:0; }
.memory-letter-read { position:relative; display:block; align-content:start; width:100%; min-height:72px; padding:14px 24px 14px 0; text-align:left; background:transparent; border:0; }
.memory-letter-read:active { opacity:.6; }
.memory-letter-read > small { display:block; margin-bottom:4px; color:var(--ms-muted); font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.memory-letter-read strong { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; margin-bottom:4px; font-weight:550; font-size:16px; line-height:1.45; overflow-wrap:anywhere; }
.memory-letter-read strong:empty { display:none; }
.memory-letter-text { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; overflow:hidden; font-size:15px; line-height:1.65; overflow-wrap:anywhere; white-space:pre-wrap; }
.memory-letter-meta { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-top:6px; color:var(--ms-muted); font-size:11px; line-height:1.5; }
.memory-letter-chevron { position:absolute; right:0; top:calc(50% - 8px); width:16px; height:16px; color:var(--ms-muted); }
.memory-space-empty { padding:40px 16px; text-align:center; color:var(--ms-muted); font-size:13px; }
.memory-space-pagination { display:flex; align-items:center; justify-content:center; gap:18px; margin-top:16px; color:var(--ms-muted); font-size:11px; }
.memory-space-pagination button { width:44px; height:44px; font-size:22px!important; }
.memory-space-sheet { position:absolute; inset:0; z-index:8; display:flex; align-items:flex-end; justify-content:center; padding:calc(12px + var(--safe-top)) 0 0; background:rgb(0 0 0 / .2); backdrop-filter:blur(3px); }
.memory-space-sheet form { width:min(640px,100%); max-height:100%; overflow-y:auto; padding:12px 24px max(16px,var(--safe-bottom)); border-radius:18px 18px 0 0; background:var(--ms-paper); box-shadow:0 -6px 28px rgb(0 0 0 / .06); overscroll-behavior:contain; }
.memory-space-sheet form > header { position:sticky; top:-12px; z-index:2; display:flex; align-items:center; gap:8px; min-height:52px; margin:0 -8px 12px; background:var(--ms-paper); }
.memory-space-sheet h2 { flex:1; font-size:14px; font-weight:500; text-align:center; }
.memory-space-sheet header button { display:grid; place-items:center; min-width:44px; height:44px; padding:0 8px; background:transparent; font-size:14px; font-weight:550; }
.memory-space-sheet svg { width:21px; height:21px; }
.memory-space-sheet label { display:flex; flex-direction:column; gap:6px; min-width:0; margin-bottom:12px; color:var(--ms-muted); font-size:12px; }
.memory-space-sheet input,.memory-space-sheet textarea,.memory-space-sheet select,#memory-space-preview-conversation { width:100%; min-width:0; min-height:44px; padding:10px 0; border:0; border-bottom:1px solid var(--ms-line); border-radius:0; background:transparent; color:var(--ms-ink)!important; font-size:16px!important; }
.memory-space-sheet .memory-space-note-title input { border:0; padding:4px 0 8px; font-size:20px!important; font-weight:550; }
.memory-space-sheet .memory-space-note-content textarea { min-height:220px; padding:4px 0; border:0; font-size:16px; line-height:1.8; resize:vertical; }
.memory-space-editor-options { border-top:1px solid var(--ms-line); }
.memory-space-editor-options > summary { min-height:44px; padding:13px 0; color:var(--ms-muted); font-size:12px; cursor:pointer; }
.memory-space-fields { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.memory-space-sheet .memory-space-check { flex-direction:row; align-items:center; gap:10px; min-height:44px; }
.memory-space-check input { width:18px; min-height:18px; height:18px; flex:none; padding:0; accent-color:var(--ms-ink); }
.memory-space-sheet footer { display:flex; padding:4px 0; }
#memory-space-delete { display:grid; place-items:center; width:44px; height:44px; margin-left:-8px; border:0; background:transparent; color:#c74646; }
#memory-space-preview-close { display:block; min-height:44px; margin-bottom:8px; font-size:13px; }
#memory-splice-preview { margin-top:12px; padding:14px; border-radius:9px; background:var(--ms-paper); font:12px/1.8 ui-monospace,SFMono-Regular,monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
#page-memory-space :focus-visible { outline:2px solid var(--ms-muted); outline-offset:3px; }
#page-memory-space .memory-space-note-title input:focus-visible,#page-memory-space .memory-space-note-content textarea:focus-visible { outline:none; box-shadow:inset 0 -1px 0 var(--ms-muted); }
@media(max-width:340px){.memory-space-content { padding-inline:20px; }.memory-space-toolbar { padding-inline:20px; }.memory-space-sheet form { padding-inline:20px; }}
@media(min-width:700px){.memory-space-content,.memory-space-toolbar { width:min(800px,100%); margin-inline:auto; }.memory-space-header { width:min(820px,100%); margin-inline:auto; }.memory-space-sheet { align-items:center; padding:calc(24px + var(--safe-top)) 24px max(24px,var(--safe-bottom)); }.memory-space-sheet form { border-radius:16px; }}
@media(prefers-reduced-motion:reduce){#page-memory-space * { scroll-behavior:auto!important; transition:none!important; }}
