/* Mandala app mock: mirrors the real dark UI (DESIGN.md tokens, Compact density, Geist 13px). Prefix: .mw */
.mw-host { position: relative; width: 100%; }
.mw { --bg: #121317; --panel: #0e0f12; --surface: #18191d; --raised: #1f2126; --text: #e4e6ea; --heading: #e4e6ea; --muted: #989ca5;
  --border: #2e3138; --soft: #23252b; --strong: #4d515a; --accent: #7c86ff; --accent-bg: #1f2240; --ok: #4ccb85; --run: #91baff; --warn: #e2ac4c; --danger: #f07575;
  --fact: #7ea6f0; --scene: #b394e8; --stable: #e2ac4c;
  position: absolute; left: 0; top: 0; width: 960px; height: 620px; transform-origin: 0 0; display: grid; grid-template-columns: 200px 1fr; gap: 8px; padding: 8px;
  background: var(--panel); color: var(--text); font: 13px/1.5 Geist, 'PingFang SC', 'Noto Sans SC', system-ui, sans-serif; border-radius: 14px; border: 1px solid #2a2d34;
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / .9), 0 0 0 1px rgb(255 255 255 / .02); overflow: hidden; text-align: left; letter-spacing: 0; }
.mw.narrow { width: 560px; grid-template-columns: 1fr; }
.mw.narrow .mw-side { display: none; }
.mw.narrow .mw-ws.split { grid-template-columns: 1fr !important; } .mw.narrow .mw-right { display: none; }
.mw svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:where(.mw button) { all: unset; cursor: pointer; box-sizing: border-box; }
.mw button:focus-visible, .mw input:focus-visible { outline: 2px solid #8a94ff; outline-offset: 1px; border-radius: 6px; }
.mw .mono { font-family: 'Geist Mono', ui-monospace, monospace; }

/* Sidebar */
.mw-side { display: flex; flex-direction: column; gap: 2px; padding: 4px 4px; min-width: 0; }
.mw-brand { display: flex; align-items: center; gap: 8px; padding: 6px 6px 10px; font-weight: 600; }
.mw-brand .mk { width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--mark-svg) center/contain no-repeat; mask: var(--mark-svg) center/contain no-repeat; }
.mw-brand .sp { flex: 1; }
.mw-brand .tg { width: 26px; height: 26px; border-radius: 7px; background: var(--raised); display: grid; place-items: center; color: var(--muted); }
.mw-new { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; font-weight: 500; margin-bottom: 8px; }
.mw-new kbd { margin-left: auto; font: 11px 'Geist Mono', monospace; color: var(--muted); }
.mw-nav { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: 7px; color: var(--text); }
.mw-nav.on { background: var(--raised); }
.mw-nav .mk { width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--mark-svg) center/contain no-repeat; mask: var(--mark-svg) center/contain no-repeat; }
.mw-sec { margin: 16px 8px 6px; font-size: 12px; font-weight: 600; color: var(--heading); }
.mw-search { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.mw-sort { display: flex; align-items: center; gap: 4px; padding: 2px 8px 6px; font-size: 12px; color: var(--muted); }
.mw-conv { display: grid; grid-template-columns: 18px 1fr auto; gap: 2px 8px; align-items: center; padding: 7px 8px; border-radius: 8px; }
.mw-conv.on { background: var(--raised); }
.mw-conv .tt { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-conv .tm { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.mw-conv .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.mw-conv .sb { grid-column: 2 / 4; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-user { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px; font-size: 12px; color: var(--text); text-decoration: none; border-radius: 8px; }
.mw-user:hover { background: var(--raised); }
.mw-user .ua { width: 24px; height: 24px; border-radius: 50%; background: var(--raised); display: grid; place-items: center; font-size: 11px; font-weight: 600; }

/* Workspace */
.mw-ws { position: relative; background: var(--bg); border: 1px solid var(--soft); border-radius: 12px; overflow: hidden; min-width: 0; display: flex; flex-direction: column; }
.mw-ws.split { display: grid; grid-template-columns: 1fr 250px; }
.mw-page { padding: 18px 28px; overflow: hidden; flex: 1; min-height: 0; }
.mw-ph { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.mw-ph h3 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.02em; color: var(--heading); }
.mw-ph .sp { flex: 1; }
.mw-back { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.mw-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--soft); padding-bottom: 8px; margin-bottom: 14px; }
.mw-tab { padding: 4px 10px; border-radius: 7px; color: var(--muted); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.mw-tab.on { background: var(--raised); color: var(--text); }
.mw-tab b { font-weight: 600; color: var(--text); }
.mw-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 8px; font-weight: 500; background: var(--raised); color: var(--text); white-space: nowrap; }
.mw-btn.p { background: var(--accent); color: #000; }
.mw-btn.g { background: none; }
.mw-btn:hover { filter: brightness(1.12); }
.mw-sel { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; min-width: 150px; font-size: 12.5px; }
.mw-sel .i:last-child { margin-left: auto; color: var(--muted); }
.mw-input { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); }
.mw-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.mw-meta span { display: inline-flex; align-items: center; gap: 5px; }
.mw-meta .i { width: 14px; height: 14px; }
.mw-h { font-size: 13.5px; font-weight: 600; color: var(--heading); margin: 16px 0 8px; display: flex; align-items: center; gap: 8px; }
.mw-h small { font-weight: 400; color: var(--muted); font-size: 12px; }
.mw-rule { border-top: 1px solid var(--soft); margin: 14px 0 0; }
.mw-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--soft); }
.mw-row .tx { flex: 1; min-width: 0; }
.mw-row .tt { font-weight: 600; }
.mw-st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.mw-st .i { width: 14px; height: 14px; }
.mw-st.todo { color: var(--muted); } .mw-st.run { color: var(--run); } .mw-st.ok { color: var(--ok); } .mw-st.warn { color: var(--warn); }
.mw code { font: 11.5px 'Geist Mono', monospace; background: var(--raised); padding: 1px 5px; border-radius: 4px; }
.mw ul.ac { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.mw-card { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.mw-card .hd { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--soft); }
.mw-card .ln { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--soft); }
.mw-card .ln:last-child { border-bottom: 0; }
.mw-card .ln .k { font-size: 12px; color: var(--muted); }
.mw-card .ln .tx { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-link { color: #8f98ff; font-weight: 500; }
.mw-av { display: inline-block; flex: none; }

/* Chat */
.mw-chat { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.mw-chat-h { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 12.5px; }
.mw-chat-h .mk { width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--mark-svg) center/contain no-repeat; mask: var(--mark-svg) center/contain no-repeat; }
.mw-chat-h .rt { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.mw-chat-h .rt i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.mw-msgs { flex: 1; overflow: hidden; padding: 6px 22px; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; }
.mw-me { align-self: flex-end; background: #262a52; color: #eef0ff; padding: 8px 14px; border-radius: 18px; max-width: 78%; font-size: 13.5px; }
.mw-bot { font-size: 13.5px; line-height: 1.6; max-width: 92%; }
.mw-turn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mw-composer { margin: 8px 16px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 10px 12px 8px; }
.mw-composer input { all: unset; width: 100%; font-size: 13.5px; color: var(--text); }
.mw-composer input::placeholder { color: var(--muted); }
.mw-composer .bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mw-composer .plus { width: 28px; height: 28px; border-radius: 7px; background: var(--raised); display: grid; place-items: center; }
.mw-composer .send { margin-left: auto; width: 28px; height: 28px; border-radius: 7px; background: #3b3f86; color: #dfe2ff; display: grid; place-items: center; }
.mw-right { border-left: 1px solid var(--soft); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mw-right .rt-tabs { display: flex; gap: 12px; font-size: 13px; color: var(--muted); padding-bottom: 6px; }
.mw-right .rt-tabs .on { color: var(--text); box-shadow: inset 0 -2px var(--accent); padding-bottom: 4px; }
.mw-seg { display: inline-flex; gap: 4px; font-size: 12px; }
.mw-seg span { padding: 3px 8px; border-radius: 6px; color: var(--muted); } .mw-seg .on { background: var(--raised); color: var(--text); }
.mw-ti { padding: 7px 0; border-bottom: 1px solid var(--soft); }
.mw-ti .tt { font-size: 12.5px; font-weight: 600; }
.mw-ti .sb { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.mw-ti .sb .st { margin-left: auto; }
.mw-new-in { animation: mwIn .4s ease; } @keyframes mwIn { from { opacity: 0; transform: translateY(6px); } }

/* Memory */
.mw-mtype { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.mw-mtype .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.mw-mtype .ic .i { width: 14px; height: 14px; }
.mw-mem { padding: 10px 0 10px; border-bottom: 1px solid var(--soft); }
.mw-mem .mbody { margin: 6px 0 6px; font-size: 13.5px; }
.mw-mem .ft { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.mw-mem .ft .sp { flex: 1; }
.mw-mem .ft button { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.mw-mem .ft button:hover { color: var(--text); }
.mw-mem.cand { background: rgb(226 172 76 / .06); border: 1px solid rgb(226 172 76 / .28); border-radius: 10px; padding: 10px 12px; margin-bottom: 4px; }
.mw-chipx { font: 11px 'Geist Mono', monospace; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }

/* Runtimes */
.mw-rtrow { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--soft); }
.mw-rtrow img { width: 20px; height: 20px; object-fit: contain; }
.mw-rtrow img.inv { filter: invert(1); }
.mw-rtrow .nm { font-weight: 600; } .mw-rtrow .cmd { font: 11.5px 'Geist Mono', monospace; color: var(--muted); }
.mw-rtrow .tx { flex: 1; display: grid; gap: 1px; }
.mw-rtrow .uses { font-size: 11.5px; color: var(--muted); }
.mw-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--run); animation: mwSpin .8s linear infinite; }
@keyframes mwSpin { to { transform: rotate(360deg); } }

/* Library */
.mw-lib { display: grid; grid-template-columns: 200px 1fr; gap: 16px; }
.mw-doc { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; font-size: 12.5px; color: var(--muted); }
.mw-doc.on { background: var(--raised); color: var(--text); }
.mw-reader { border: 1px solid var(--soft); border-radius: 10px; background: var(--surface); padding: 14px 18px; font-size: 13.5px; line-height: 1.7; }
.mw-reader h4 { margin: 0 0 2px; font-size: 16px; }
.mw-reader h5 { margin: 12px 0 2px; font-size: 13px; }
.mw-reader p { margin: 0; color: #c9ccd3; }

/* Dropdown */
.mw-dd { position: absolute; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; box-shadow: 0 16px 40px -10px rgb(0 0 0 / .8); min-width: 220px; }
.mw-dd button { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; width: 100%; }
.mw-dd button:hover, .mw-dd button.on { background: var(--raised); }
.mw-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--soft); padding-bottom: 12px; }
.mw-stats > div { padding: 4px 14px; } .mw-stats > div + div { border-left: 1px solid var(--soft); }
.mw-stats .v { display: flex; align-items: center; gap: 8px; font-size: 13px; } .mw-stats .v b { font-weight: 600; }
.mw-stats .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mw-kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--soft); font-size: 13px; }
.mw-kv .k { font-weight: 500; } .mw-kv .k small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.mw-kv .v { color: var(--muted); text-align: right; display: inline-flex; align-items: center; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .mw-new-in, .mw-spin { animation: none; } }

/* Single-line search fields, as in the app */
.mw-search, .mw-input { white-space: nowrap; overflow: hidden; }
.mw-search span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Mandala pet card (top of the Mandala side panel) */
.mw-pet { display: flex; align-items: center; gap: 12px; padding: 12px 4px 12px; border-bottom: 1px solid var(--soft); margin-bottom: 2px; }
.mw-pet .fig { position: relative; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, rgb(124 134 255 / .28), transparent 68%); }
.mw-pet .fig .mk { width: 34px !important; height: 34px !important; flex: none; background: #c9ceff; -webkit-mask: var(--mark-svg) center/contain no-repeat; mask: var(--mark-svg) center/contain no-repeat; animation: mwPet 6s ease-in-out infinite; }
.mw-pet .fig b { position: absolute; right: -2px; top: -2px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--warn); color: #1a1406; font: 600 10px/16px var(--sans, system-ui); text-align: center; }
.mw-pet .nm { font-weight: 600; font-size: 13px; }
.mw-pet .ln { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--warn); margin-top: 2px; }
.mw-pet .ln i { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.mw-pet .pop { margin-left: auto; color: var(--muted); display: inline-flex; }
@keyframes mwPet { 50% { transform: rotate(30deg) scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .mw-pet .fig .mk { animation: none; } }
