*{box-sizing:border-box} :root{color-scheme:dark;--bg:#0d111b;--surface:#1a2230;--line:#30394b;--ink:#f4f5fa;--muted:#a5b0c6;--accent:#b9a4ff} body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.5 system-ui,-apple-system,sans-serif} main{max-width:580px;margin:auto;padding:20px 18px 112px;padding-top:max(20px,env(safe-area-inset-top))} header,.brand,.line{display:flex;align-items:center;justify-content:space-between;gap:12px}.brand{justify-content:flex-start}.logo{display:grid;place-items:center;width:46px;height:46px;background:#29243f;color:var(--accent);font-size:28px;border-radius:15px}h1{font-size:20px;margin:0;letter-spacing:.04em}h2{font-size:24px;line-height:1.25;margin:24px 0 6px}small,.muted,footer{color:var(--muted)}.tag{background:#29243f;color:#e0d6ff;border-radius:30px;padding:5px 12px;font-size:12px;font-weight:700}#status{font-size:13px;color:var(--muted);min-height:20px}.hero{border:1px solid #51436d;background:linear-gradient(135deg,#29243f,#1b2034);padding:22px;border-radius:23px;margin:18px 0}.eyebrow{font-size:11px;font-weight:700;letter-spacing:.1em;color:#dacdff}.metric{font-size:40px;line-height:1.2;font-weight:750;margin:10px 0 0;font-variant-numeric:tabular-nums}.hero p{margin:4px 0 12px}.hero small{display:block;margin-top:8px}progress{width:100%;height:7px;accent-color:#ae93ff;border:0;background:#39334f;border-radius:9px;overflow:hidden}progress::-webkit-progress-bar{background:#39334f;border-radius:9px}progress::-webkit-progress-value{background:#ae93ff;border-radius:9px}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}button{font:inherit;cursor:pointer;color:inherit;border:1px solid var(--line);background:var(--surface);border-radius:15px;min-height:44px}button:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.tile{text-align:left;padding:15px;display:grid;gap:5px;min-height:116px}.tile span{color:var(--accent);font-size:25px}.tile strong{font-size:15px}.tile small{font-size:12px}.panel{border-radius:20px;border:1px solid var(--line);background:var(--surface);padding:8px 16px;margin:18px 0}.line{padding:13px 0;border-bottom:1px solid var(--line)}.line:last-child{border:0}.line strong{text-align:right;overflow-wrap:anywhere}.primary,.secondary{width:100%;padding:12px;margin:8px 0}.primary{background:#b9a4ff;color:#161124;font-weight:700}.secondary{color:var(--accent)}nav{position:fixed;bottom:0;left:0;right:0;background:#131a27;border-top:1px solid var(--line);display:flex;justify-content:center;gap:5px;padding:8px 12px max(10px,env(safe-area-inset-bottom))}nav button{flex:1;max-width:136px;border:0;background:transparent;font-size:11px;color:var(--muted);display:grid;gap:2px;place-items:center;padding:4px}nav span{font-size:22px;line-height:1.1}nav .selected{color:var(--accent);background:#25213a}footer{text-align:center;font-size:11px;margin:30px 0 0}[hidden]{display:none!important}
/* 5.1 compact mobile layout */
:root{--nav:#131a27;--hero:#29243f;--hero-end:#1b2034;--hero-ink:#dacdff;--selected:#25213a;--primary:#b9a4ff;--primary-ink:#161124}
:root[data-theme=light]{color-scheme:light;--bg:#f4f5fa;--surface:#fff;--line:#d9dce7;--ink:#21243a;--muted:#60697d;--accent:#6545b5;--nav:#fff;--hero:#eee8ff;--hero-end:#f5f0ff;--hero-ink:#55378f;--selected:#eee8ff;--primary:#6545b5;--primary-ink:#fff}
main{padding:14px 16px 112px;padding-top:max(14px,env(safe-area-inset-top))}h2{font-size:23px;margin:16px 0 8px}h3{font-size:16px;margin:18px 0 9px}.logo,.tag{background:var(--selected);color:var(--accent)}#status{font-size:12px;margin:9px 0;overflow-wrap:anywhere}.hero{background:linear-gradient(135deg,var(--hero),var(--hero-end));padding:14px 16px;margin:12px 0;border-color:var(--line);border-radius:19px}.hero .line{padding:0 0 8px;border:0}.eyebrow{color:var(--hero-ink);font-size:10px}.metric{font-size:32px;margin:0;white-space:nowrap}.hero small{margin:3px 0 0}.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.stats button{padding:11px 4px;display:grid;gap:3px;place-items:center}.stats strong{font-size:22px}.stats small{font-size:10px}.grid{gap:9px}.tile{min-height:88px;padding:11px;gap:3px}.tile span{font-size:21px}.tile small{font-size:11px}.panel{margin:10px 0;padding:9px 13px}.primary{background:var(--primary);color:var(--primary-ink)}nav{background:var(--nav)}nav .selected{background:var(--selected)}.settings label{display:grid;gap:5px;margin:8px 0;color:var(--muted);font-size:13px}input,select,textarea{font:inherit;min-width:0;width:100%;min-height:44px;padding:10px;color:var(--ink);background:var(--bg);border:1px solid var(--line);border-radius:10px}textarea{resize:vertical}.entry{padding:11px 0;border-bottom:1px solid var(--line);overflow-wrap:anywhere;white-space:pre-wrap}.entry:last-child{border:0}.entry small{display:block}.entry-actions{display:flex;gap:8px;margin-top:8px}.entry-actions button{padding:5px 10px;font-size:12px}.done{opacity:.65}.calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;text-align:center}.calendar-grid button{min-height:40px;border-radius:9px;font-size:13px}.calendar-grid .marked{border-color:var(--accent);font-weight:700}.calendar-grid .chosen{background:var(--primary);color:var(--primary-ink)}.calendar-grid small{font-size:11px;padding:6px 0}.bar-row{padding:8px 0}.bar-row progress{display:block;margin-top:6px}.bar-row .line{padding:0;border:0;font-size:13px}.page{animation:appear .16s ease-out}@keyframes appear{from{opacity:.65;transform:translateY(3px)}to{opacity:1;transform:none}}@media(prefers-reduced-motion:reduce){.page{animation:none}}button:disabled,input:disabled,select:disabled,textarea:disabled{opacity:.55;cursor:default}footer{margin-top:18px}

/* iOS WebView: inputs must be at least 16 CSS px to avoid focus zoom. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;max-width:100%}body{max-width:100%;overflow-wrap:anywhere}main{width:100%;min-width:0}header,.brand,.line,.panel,.settings,.settings label,.page{min-width:0;max-width:100%}.brand{flex:1}.brand>div{min-width:0}.logo,.tag{flex-shrink:0}.settings label{grid-template-columns:minmax(0,1fr)}input,textarea,select{font-size:16px;max-width:100%;min-width:0;box-sizing:border-box}input[type=datetime-local]{display:block;width:100%;-webkit-appearance:none;appearance:none;min-inline-size:0}input::-webkit-date-and-time-value{text-align:left;min-width:0}.form-status{font-size:13px;margin:4px 0 8px;color:var(--muted);overflow-wrap:anywhere}.form-status:empty{display:none}.form-status[data-state=error]{color:#fda4af}:root[data-theme=light] .form-status[data-state=error]{color:#b42318}.form-status[data-state=ok]{color:var(--accent)}.entry-actions{flex-wrap:wrap}nav button{min-width:0}@media(max-width:360px){.brand small{font-size:11px}.tag{padding:4px 7px}.logo{width:38px;height:38px}.metric{font-size:26px}}

/* Text chat. Keep the composer in normal document flow for iOS keyboards. */
.chat-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.chat-heading h2{margin-bottom:2px}.chat-heading button{min-width:44px;font-size:23px}.chat-hint{font-size:12px;margin:10px 0}.chat-messages{display:flex;flex-direction:column;gap:13px;margin:14px 0;min-height:160px;max-height:52dvh;overflow-y:auto;overscroll-behavior:contain;padding:3px 2px}.chat-bubble{max-width:100%;min-width:0;overflow-wrap:anywhere;line-height:1.55;font-size:15px}.chat-bubble.user{align-self:flex-end;background:var(--selected);border:1px solid var(--line);border-radius:17px 17px 5px 17px;padding:10px 13px;max-width:88%;white-space:pre-wrap}.chat-bubble.assistant{align-self:stretch;background:var(--surface);border:1px solid var(--line);border-radius:5px 17px 17px 17px;padding:13px}.chat-bubble small{display:block;font-weight:700;color:var(--accent);margin-bottom:7px}.chat-bubble p{white-space:pre-wrap;margin:0 0 8px}.chat-bubble p:last-child{margin:0}.chat-bubble h4{font-size:16px;margin:10px 0 5px}.chat-bubble pre{white-space:pre-wrap;overflow-wrap:anywhere;background:var(--bg);padding:9px;border-radius:9px;font:13px/1.5 monospace}.chat-bubble .copy-reply{margin-top:9px;min-height:34px;font-size:12px;padding:4px 9px}.chat-composer{display:grid;grid-template-columns:minmax(0,1fr) 46px;align-items:end;gap:8px;padding:9px;background:var(--surface);border:1px solid var(--line);border-radius:18px}.chat-composer textarea{font-size:16px;min-height:48px;max-height:180px;resize:vertical}.chat-composer button{background:var(--primary);color:var(--primary-ink);font-weight:750;font-size:24px;height:46px}.chat-composer .form-status{grid-column:1/-1}.chat-tools{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}.chat-tools button{flex:1;font-size:12px;padding:6px}.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

/* Finance journal */
.finance-month{display:grid;grid-template-columns:44px minmax(0,1fr) 44px;gap:8px;align-items:center;margin:12px 0}.finance-month input{min-width:0;width:100%;font-size:16px;-webkit-appearance:none;appearance:none}.finance-month button{font-size:24px}.finance-balance{background:linear-gradient(135deg,var(--hero),var(--hero-end));padding:17px}.finance-balance>strong{display:block;font-size:30px;line-height:1.25;margin:5px 0 13px;overflow-wrap:anywhere}.finance-totals{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.finance-totals>div{min-width:0}.finance-totals strong{display:block;font-size:17px;overflow-wrap:anywhere}.finance-totals>div:first-child strong{color:#3da977}.finance-totals>div:last-child strong{color:#e87987}.finance-item-top{display:flex;justify-content:space-between;align-items:start;gap:8px}.finance-item-top strong{min-width:0;overflow-wrap:anywhere}.finance-item-top .money{flex-shrink:0;font-variant-numeric:tabular-nums}.finance-item-top .income{color:#3da977}.finance-item-top .expense{color:#e87987}:root[data-theme=light] .finance-item-top .income,:root[data-theme=light] .finance-totals>div:first-child strong{color:#166534}:root[data-theme=light] .finance-item-top .expense,:root[data-theme=light] .finance-totals>div:last-child strong{color:#b42318}

/* v5.4: single-tap targets and stable chat layout, even on iOS. */
button,[data-page],input,select,textarea{touch-action:manipulation;-webkit-tap-highlight-color:transparent}button:active{opacity:.85}nav{z-index:20}nav button{position:relative;min-height:48px;touch-action:manipulation}.page{animation:none}.chat-bubble{flex-shrink:0}.chat-messages{scrollbar-width:thin;max-height:45dvh;overflow-anchor:none}.chat-heading{scroll-margin-top:16px}.chat-composer{grid-template-columns:44px minmax(0,1fr) 46px;align-items:end}.chat-composer #chat-attach,.chat-composer #chat-remove{background:var(--surface);color:var(--accent);border:1px solid var(--line)}.chat-attachment{grid-column:1/-1;grid-row:1;display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;overflow-wrap:anywhere}.chat-attachment span{min-width:0}.chat-attachment button{flex:0 0 44px}.chat-bubble.pending{opacity:.7}.chat-composer textarea{font-size:16px;min-height:48px;max-height:140px}body.chat-active main>header,body.chat-active main>#status{display:none}body.chat-active main{padding-top:max(12px,env(safe-area-inset-top),var(--tg-content-safe-area-inset-top,0px))}body.chat-active footer{display:none}body.chat-active .chat-heading h2{margin-top:4px}.chat-tools{margin-bottom:14px}.chat-bubble.assistant pre{max-width:100%;overflow-x:auto;white-space:pre}.chat-composer .form-status{grid-column:1/-1}

.transcript{white-space:pre-wrap;overflow-wrap:anywhere;user-select:text}.voice-hero+.secondary{margin-top:0}#voice-file{font-size:16px;width:100%;min-width:0}#voice-file::file-selector-button{font:inherit;max-width:100%;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--ink);padding:8px}

/* 6.0 Beta — unified mobile product design */
:root{--shadow:rgba(0,0,0,.16)}
main{padding-inline:16px;padding-bottom:calc(112px + env(safe-area-inset-bottom,0px))}
header{padding:6px 0 10px}.logo{width:42px;height:42px;font-size:25px}.day-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.day-heading h2{font-size:26px;margin:2px 0 10px}.day-heading button,.chat-heading>button{min-width:44px;padding:7px 10px}.day-overview{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.day-overview .tile{background:linear-gradient(145deg,var(--hero),var(--hero-end));border-color:var(--line)}.day-plan .line{padding:6px 0}.day-plan button{padding:4px 10px;font-size:12px}.day-plan .entry{font-size:14px}.finance-home{width:100%;display:grid;grid-template-columns:34px minmax(0,1fr);min-height:70px;align-items:center;text-align:left}.finance-home span{grid-row:1/3;font-size:26px}.finance-home small{font-size:17px;font-weight:700;color:var(--ink)}.service-grid .tile{min-height:97px}.tile,.panel,.hero{box-shadow:0 4px 18px var(--shadow)}.tile strong,.tile small{overflow-wrap:anywhere}.quick-prompts{margin:4px 0 8px}.quick-prompts button{font-size:12px;min-height:38px}.inline-form{display:grid;grid-template-columns:minmax(0,1fr) 44px;gap:8px;padding:10px}.inline-form button{color:var(--primary-ink);background:var(--primary);font-weight:700;font-size:20px}.habit-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;margin:10px 0}.habit-day{border:1px solid var(--line);border-radius:9px;text-align:center;padding:4px 1px;font-size:15px}.habit-day small{font-size:10px}.habit-day.checked{background:var(--selected);color:var(--accent);border-color:var(--accent)}#studio-result-body{max-height:60dvh;overflow:auto;user-select:text}#studio-result-body p{margin:5px 0}#studio-result-body pre{white-space:pre-wrap;overflow-wrap:anywhere}#library-image,#image-preview{display:block;width:100%;max-height:65dvh;object-fit:contain;border-radius:13px}#search-results .entry p{font-size:14px;color:var(--muted);margin:6px 0}#search-results button,#memory-list button{font-size:13px;padding:5px 10px}#voice-preview{width:100%;margin:10px 0}.record-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.record-actions button{font-size:13px;padding:7px}.recording{color:#f28c9b}

/* 6.1 Workspace: mobile first, desktop sidebar */
:root{--bg:#111216;--surface:#1b1d23;--line:#30333d;--ink:#f2f3f6;--muted:#a4a9b7;--accent:#a6c5ff;--nav:#15171c;--hero:#202d43;--hero-end:#1c202b;--hero-ink:#c2d6ff;--selected:#26354e;--primary:#a6c5ff;--primary-ink:#111b30;--shadow:transparent}
:root[data-theme=light]{--bg:#f3f5f8;--surface:#fff;--line:#dce1e9;--ink:#222734;--muted:#596477;--accent:#305fae;--nav:#fff;--hero:#e5edff;--hero-end:#f2f6ff;--hero-ink:#315698;--selected:#e3ecff;--primary:#315fae;--primary-ink:#fff}
body{font-size:15px}main{max-width:680px;padding-inline:18px}header{padding-bottom:12px;border-bottom:1px solid var(--line)}h1{font-size:18px;letter-spacing:.02em}h2{font-size:27px;font-weight:700;letter-spacing:-.035em;margin:14px 0 8px}h3{font-size:17px;letter-spacing:-.01em}.logo{border-radius:12px}.panel,.tile,.hero,.stats button{border-radius:14px;box-shadow:none}.panel{padding:16px;margin:14px 0}.tile{padding:14px;min-height:102px}.tile span{font-size:24px}.tile strong{font-size:15px}.tile small{font-size:12px}.grid,.day-overview,.stats{gap:10px}.primary,.secondary{border-radius:11px}.primary{border-color:transparent}.settings label{margin:12px 0}input,select,textarea{border-radius:10px}.settings input:focus,.settings select:focus,.settings textarea:focus,.chat-composer textarea:focus{outline:2px solid var(--accent);outline-offset:1px}.home-subtitle{margin:3px 0 12px}.home-intro{border:1px solid var(--line);border-radius:18px;background:linear-gradient(125deg,var(--hero),var(--hero-end));padding:20px;margin:10px 0 14px}.home-intro h3{font-size:25px;margin:10px 0 2px;letter-spacing:-.035em}.home-intro p{color:var(--muted);margin:7px 0 15px}.home-intro .primary{width:auto;margin:0;padding-inline:18px}.desktop-brand,.desktop-label,nav .desktop-only{display:none}.chat-bubble.assistant{border:0;background:transparent;padding:12px 2px}.chat-bubble.user{border-radius:18px 18px 4px 18px}.chat-messages{max-height:48dvh;min-height:170px;padding:4px 0}.chat-composer{border-radius:18px;gap:8px}.chat-bubble h4{font-size:18px;margin:16px 0 8px}.chat-bubble p{margin-bottom:10px}.chat-bubble ul,.chat-bubble ol{padding-left:24px;margin:8px 0 14px}.chat-bubble li{padding:3px 0}.chat-bubble code{font:.9em ui-monospace,monospace;background:var(--surface);padding:2px 4px;border-radius:4px}.chat-bubble pre{border:1px solid var(--line);padding:14px}.reply-table{overflow-x:auto;margin:12px 0}.reply-table table{border-collapse:collapse;width:100%;font-size:14px}.reply-table th,.reply-table td{padding:9px 12px;border:1px solid var(--line);text-align:left;vertical-align:top}.reply-table th{background:var(--surface)}.tool-card{border-color:var(--accent)}.tool-card p{margin:8px 0}.tool-card button{padding:8px 12px}.chat-bubble .copy-reply{background:transparent;color:var(--muted)}.form-status[data-state=pending]{color:var(--accent)}#status[data-state=error]{color:#fda4af}:root[data-theme=light] #status[data-state=error]{color:#b42318}.chat-composer textarea{resize:none}.chat-tools button{flex:0 1 auto;min-width:90px}.chat-tools{gap:6px}nav button{border-radius:12px}
@media(hover:hover){button:not(:disabled):hover{border-color:var(--accent)}nav button:hover{background:var(--selected);color:var(--ink)}}
@media(min-width:800px){
body{padding-left:224px}main{max-width:1250px;margin:0 auto;padding:24px 32px 36px}
nav{left:0;right:auto;top:0;bottom:0;width:224px;border-top:0;border-right:1px solid var(--line);padding:20px 12px;display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:3px;overflow-y:auto}
.desktop-brand{display:flex;align-items:center;gap:11px;padding:6px 8px 22px}.desktop-brand strong{display:block;font-size:20px;letter-spacing:.07em}.desktop-brand small{display:block;font-size:10px}.desktop-label{display:block;color:var(--muted);font-size:10px;font-weight:700;letter-spacing:.08em;padding:15px 12px 4px}
nav button,nav .desktop-only{display:flex;flex:0 0 auto;align-items:center;justify-content:flex-start;gap:12px;text-align:left;max-width:none;width:100%;min-height:40px;padding:8px 12px;font-size:14px}nav button span{font-size:19px;width:22px;text-align:center}nav .selected{font-weight:650}
header{padding-bottom:16px}h2{font-size:33px}.home-intro{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:26px 30px}.home-intro h3{font-size:34px}.home-intro p{margin-bottom:0}.home-intro .primary{flex-shrink:0}.day-overview .tile{min-height:118px}.grid.service-grid,#home>.grid{grid-template-columns:repeat(3,minmax(0,1fr))}.tile{min-height:105px}
#home:not([hidden]){display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;align-items:start}#home>.day-heading,#home>.home-intro,#home>.day-overview,#home>.stats,#home>h3,#home>.grid{grid-column:1/-1}#home>.hero,#home>.panel,#home>.finance-home,#home>.secondary{margin:0;height:100%}#home>.day-plan,#home>.finance-home{min-height:120px}
#ai{max-width:920px;margin:0 auto}body.chat-active main{padding:20px 32px 28px}body.chat-active main>header,body.chat-active main>#status{display:flex}.chat-messages{max-height:calc(100dvh - 340px);min-height:220px;margin:12px 0}.chat-bubble.assistant{padding:14px 10px}.chat-bubble.user{max-width:75%}.chat-composer{padding:12px}.chat-tools{margin:8px 0}
#studio-page,#image-page,#voice-page,#tasks-page,#calendar,#notes-page,#profile,#memory-page,#search-page,#life-page,#finance,#library-page,#tariffs,#chat-limits{max-width:960px;margin-inline:auto}#studio-form,#image-form,#voice-form,#finance-form,#task-form,#note-form{padding:22px}#studio-prompt,#image-prompt{min-height:150px}.calendar-grid button{min-height:62px}.finance-balance>strong{font-size:42px}.finance-totals strong{font-size:24px}
}
@media(min-width:1200px){body{padding-left:248px}nav{width:248px}main{padding-inline:44px}#home>.grid,.grid.service-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-width:380px){main{padding-inline:12px}h2{font-size:24px}.home-intro{padding:16px}.home-intro h3{font-size:22px}.tile{padding:10px}.chat-tools button{min-width:70px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;scroll-behavior:auto!important;transition:none!important}}

/* 6.2: one chat, inline artifacts, compact composer */
.chat-artifact{border:1px solid var(--line);border-radius:15px;background:var(--surface);padding:14px;max-width:560px;margin:10px 0;min-width:0}
.artifact-heading{display:flex;align-items:center;gap:12px;margin-bottom:6px}.artifact-icon{display:grid;place-items:center;flex:0 0 44px;height:44px;border-radius:10px;background:var(--selected);color:var(--accent);font-size:24px}.artifact-name{font-weight:650;min-width:0;overflow-wrap:anywhere}.chat-artifact img{display:block;width:100%;max-height:420px;object-fit:contain;border-radius:10px;margin-top:10px}.chat-artifact .entry-actions button{padding:8px 12px;min-height:40px}.chat-working{color:var(--muted);padding:10px 2px;font-size:14px;align-self:flex-start}.chat-working::before{content:"✦";color:var(--accent);margin-right:8px}.chat-shortcuts{margin:6px 0;gap:5px}.chat-shortcuts button{min-height:34px;min-width:0;padding:5px 10px;font-size:12px}.chat-composer{position:relative;box-shadow:0 5px 20px #00000012}.chat-composer #chat-input{border:0;background:transparent}.chat-messages{max-height:54dvh;min-height:160px}.chat-bubble{overflow-wrap:anywhere}.chat-bubble pre,.reply-table{max-width:100%;overflow-x:auto}.chat-bubble .copy-reply{min-height:36px}.chat-composer .form-status[data-state=pending]{color:var(--accent)}
@media(min-width:800px){.chat-messages{max-height:calc(100dvh - 270px);min-height:180px}.chat-shortcuts{justify-content:center}body.chat-active main>header,body.chat-active main>#status{display:none}#ai{max-width:900px}}
@media(max-width:799px){.chat-messages{max-height:48dvh}.chat-shortcuts button{flex:0 1 auto}.chat-artifact .entry-actions button{flex:1 1 auto}.chat-heading h2{font-size:23px}}

/* 6.2.2: visual viewport chat layout, no navigation over the composer */
.chat-header-actions{display:flex;gap:6px;align-items:center;flex-shrink:0}
.chat-header-actions #chat-done{font-size:13px;padding:6px 10px;color:var(--accent)}
@media(max-width:799px){
  body.chat-active{overflow:hidden;overscroll-behavior:none}
  body.chat-active main{position:fixed;top:var(--chat-view-top,0px);left:0;right:0;height:calc(var(--chat-view-height,100dvh) - var(--chat-nav-height,76px));max-width:680px;min-height:0;display:flex;flex-direction:column;overflow:hidden;padding: max(16px,env(safe-area-inset-top,0px),var(--tg-content-safe-area-inset-top,0px)) 14px 8px}
  body.chat-active #ai:not([hidden]){display:flex;flex-direction:column;flex:1 1 auto;min-height:0;min-width:0;width:100%;margin:0;overflow:hidden}
  body.chat-active #ai>.chat-heading{flex:0 0 auto;min-height:44px}
  body.chat-active #ai>.chat-heading h2{font-size:21px;line-height:1.25;margin:0 0 2px}
  body.chat-active #ai>.chat-hint{flex:0 0 auto;margin:4px 0;font-size:12px}
  body.chat-active #ai>.chat-tools{flex:0 0 auto;margin:5px 0;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
  body.chat-active #ai>.chat-tools button{flex:0 0 auto;min-height:34px;min-width:0;white-space:nowrap;padding:4px 10px}
  body.chat-active #chat-messages{flex:1 1 0;min-height:0;max-height:none;overflow-y:auto;overflow-x:hidden;margin:6px 0;padding:4px 0;overscroll-behavior:contain}
  body.chat-active #chat-form{flex:0 0 auto;margin:0;min-width:0;max-width:100%;grid-template-columns:40px minmax(0,1fr) 44px;padding:7px;gap:6px}
  body.chat-active #chat-input{font-size:16px;min-height:44px;max-height:96px;padding:9px 5px}
  body.chat-active #chat-status{max-height:54px;overflow-y:auto;margin:0;line-height:1.35}
  body.chat-active #chat-attachment{min-width:0;max-height:52px;overflow:hidden}
  body.chat-active nav{top:calc(var(--chat-view-top,0px) + var(--chat-view-height,100dvh) - var(--chat-nav-height,76px));bottom:auto}
  body.chat-active.chat-keyboard nav{display:none}
  body.chat-active.chat-keyboard main{height:var(--chat-view-height,100dvh);padding-bottom:8px}
  body.chat-active.chat-keyboard #ai>.chat-hint,body.chat-active.chat-keyboard #ai>.chat-tools{display:none}
  body.chat-active.chat-keyboard #chat-messages{margin:4px 0}
  body.chat-active.chat-keyboard #chat-form{background:var(--surface);border-color:var(--line)}
}

/* 6.2.3: keep readable column widths and scroll wide tables inside the reply. */
.reply-table{width:100%;max-width:100%;min-width:0;overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
.reply-table table{width:max-content;min-width:100%;max-width:none;table-layout:auto}
.reply-table th,.reply-table td{min-width:132px;max-width:340px;word-break:normal;overflow-wrap:break-word;white-space:normal}
.reply-source{color:var(--accent);text-decoration:underline;overflow-wrap:anywhere}
.chat-composer #chat-library{grid-column:1/-1;height:auto;min-height:36px;font-size:13px;padding:7px;color:var(--accent);background:var(--surface);border:1px solid var(--line)}
.chat-artifact .entry-actions{flex-wrap:wrap}
@media(max-width:799px){.reply-table th,.reply-table td{min-width:132px;max-width:240px;font-size:14px;padding:8px 10px}.chat-bubble .reply-table{overflow-x:auto}.chat-artifact .entry-actions button{flex:1 1 auto}}

/* 6.3 independent conversations and compact composer */
.chat-title{min-width:0;flex:1}.chat-title h2{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dialog-panel{position:absolute;inset:0 auto 0 0;width:min(320px,90%);z-index:30;background:var(--surface);border:1px solid var(--line);border-radius:16px;display:flex;flex-direction:column;gap:10px;padding:14px;box-shadow:0 8px 40px #0004;min-height:0}
.dialog-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}.dialog-heading button{width:40px}.dialog-panel .primary{margin:0}.dialog-list{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:5px}.dialog-entry{width:100%;text-align:left;padding:10px 12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0;border:0;background:transparent}.dialog-entry.selected{background:var(--selected);color:var(--accent)}.dialog-footer{display:grid;grid-template-columns:1fr 1fr;gap:6px}.dialog-footer button{font-size:12px;padding:6px}.dialog-footer #chat-feedback{grid-column:1/-1}#dialog-status{font-size:12px;margin:0;overflow-wrap:anywhere}.chat-header-actions #dialog-toggle{font-size:20px}.chat-shortcuts{padding:8px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}.chat-bubble.user .copy-reply{display:block;margin-left:auto;background:transparent}.chat-bubble .copy-reply+.copy-reply{margin-left:6px}
#ai{position:relative;min-width:0}#chat-messages{min-width:0}body.chat-active #ai>.chat-tools:not([hidden]){display:flex;flex-wrap:wrap;overflow:visible}
@media(max-width:799px){body.chat-active #ai>.dialog-panel{inset:0 0 0 0;width:100%;border-radius:14px}body.chat-active.chat-keyboard #ai>.dialog-panel{display:none}body.chat-active.chat-keyboard #ai>.chat-tools:not([hidden]){display:none}body.chat-active #ai>.chat-heading h2{font-size:19px}.chat-header-actions{gap:4px}.chat-header-actions button{min-width:38px}.chat-header-actions #chat-done{min-width:0}}
@media(min-width:800px){#ai{max-width:1100px}body.chat-active main{height:100dvh;display:flex;flex-direction:column;overflow:hidden}body.chat-active #ai:not([hidden]){display:flex;flex-direction:column;flex:1;min-height:0;width:100%;overflow:hidden}body.chat-active #chat-messages{flex:1;min-height:0;max-height:none}body.chat-active #chat-form{flex:0 0 auto}body.chat-active #ai>.chat-heading{flex:0 0 auto}body.chat-active.dialogs-open #ai{padding-left:260px}body.chat-active #ai>.dialog-panel{width:244px;box-shadow:none}.chat-shortcuts{flex:0 0 auto}}

/* Experience 6.5 */
.experience-tabs,.experience-groups{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
.experience-tabs button{flex:1}
.experience-tabs [aria-pressed=true],.experience-chip[aria-pressed=true]{background:var(--selected);color:var(--accent)}
.experience-chip{max-width:100%;overflow-wrap:anywhere;font-size:14px}
.experience-item{display:flex;align-items:center;gap:10px;padding:12px 0;border-bottom:1px solid var(--line)}
.experience-item:last-child{border-bottom:0}
.experience-item span{flex:1;min-width:0;overflow-wrap:anywhere;white-space:pre-wrap}
.experience-item input[type=checkbox],.experience-switch input[type=checkbox]{width:20px;height:20px;flex:0 0 20px;accent-color:var(--accent)}
.experience-delete{flex:0 0 40px;min-height:40px}
.experience-done{text-decoration:line-through;opacity:.7}
#ws-progress{display:flex;align-items:center;gap:12px;margin:12px 0}#ws-progress[hidden]{display:none}
#ws-progress progress{flex:1;min-width:0}
.experience-switch{display:flex!important;flex-direction:row!important;align-items:center;justify-content:space-between;gap:12px}
.experience-switch small{display:block;margin-top:4px}
#dialog-search,#ws-name,#ws-body{font-size:16px;min-width:0}
#dialog-search{width:100%}

/* MIKRO 7.0 — accessible, compact navigation and discoverability */
.ux-nav{display:flex;align-items:center;gap:8px;margin:8px 0 14px;min-width:0}
.ux-nav button{padding:6px 10px;flex-shrink:0;font-size:13px}
#ux-location{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:13px}
.ux-quick{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0}
.ux-quick .tile{min-height:94px;align-content:start;padding:14px;border-radius:18px}
.ux-start,.ux-filters{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.ux-start button,.ux-filters button{flex:1 1 auto;padding:8px 12px}
.ux-filters [aria-pressed=true]{background:var(--selected);color:var(--accent);border-color:var(--accent)}
.ux-extra{margin:16px 0}.ux-extra summary{min-height:44px;cursor:pointer;padding:10px 0;color:var(--accent);font-weight:600}
.ux-extra[open] summary{margin-bottom:8px}
#ux-search{width:100%;font-size:16px;min-height:44px}
.ux-template-list{display:grid;gap:10px;margin:16px 0}
.ux-template-list button{padding:14px;text-align:left;display:grid;gap:5px;min-height:64px;overflow-wrap:anywhere}
.ux-template-list small{font-size:13px;color:var(--muted)}
.ux-access h3{margin:6px 0 12px}
#home .home-intro{margin-top:12px;border-radius:22px}
#home .home-intro h3{font-size:22px;line-height:1.25;margin:8px 0}
#home .home-intro .primary{min-height:48px}
#home .voice-hero{margin-top:18px}
#home .home-intro p,.tile small{overflow-wrap:anywhere}
:root[data-font=large] body{font-size:18px;line-height:1.55}
:root[data-font=large] :is(button,input,select,textarea){font-size:17px}
:root[data-font=large] :is(small,.muted,.form-status,.tile small){font-size:14px}
:root[data-font=large] :is(.chat-bubble,.chat-bubble p,.chat-bubble li){font-size:17px}
:root[data-font=large] nav button{font-size:13px}
:root[data-contrast=high]{--muted:#d4dbea;--line:#778399;--accent:#dacdff;--selected:#343050}
:root[data-theme=light][data-contrast=high]{--muted:#353b4b;--line:#757c90;--accent:#42218e;--selected:#e3d9ff}
:root[data-motion=reduced] *, :root[data-motion=reduced] *::before,:root[data-motion=reduced] *::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
:where(button,input,select,textarea,summary):focus-visible{outline:2px solid var(--accent);outline-offset:3px}
@media(max-width:360px){.ux-nav button{font-size:12px;padding:6px}.ux-quick .tile{padding:10px}.ux-start button{flex-basis:100%}}
@media(min-width:800px){.ux-quick{grid-template-columns:repeat(4,minmax(0,1fr))}.ux-template-list{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Membership 2.0 preview */
#membership-root{display:grid;gap:10px}
#membership-root .panel{margin:0;min-width:0}
.membership-wallet{background:linear-gradient(140deg,var(--hero),var(--hero-end));border:1px solid var(--line)}
.membership-wallet h3,.membership-details h3{margin:7px 0}
.membership-notice{margin:0;color:var(--muted);font-size:13px}
.membership-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:8px 0}
.membership-choice{min-width:0;min-height:44px;font-size:14px;overflow-wrap:anywhere;text-align:center}
.membership-choice.selected{background:var(--selected);border-color:var(--accent);color:var(--ink)}
.membership-choice:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.membership-savings{font-weight:700;color:var(--accent)}
#membership-root .line{gap:8px}
#membership-root .line strong{text-align:right;overflow-wrap:anywhere}
@media(max-width:340px){.membership-grid{grid-template-columns:1fr}}

/* Mini App 7: touch targets and readable composer */
#chat-input{font-size:16px;line-height:1.45;min-height:44px;resize:none}
#chat-tools-menu button{min-height:44px;white-space:normal;overflow-wrap:anywhere}
#chat-send,#chat-attach{min-width:44px;min-height:44px}
#chat-status{overflow-wrap:anywhere}
