/* AVA_LEFT_RAIL_V1_START */
:root{--ava-left-rail-width:280px;--ava-left-rail-closed:48px;--ava-left-rail-transition:180ms}

/* Dark-first guarantee: initial paint is always dark. A visit-only override
   may opt into light after user action by setting data-ava-visit-theme. */
:root,
:root[data-theme="light"],
:root[data-theme="dark"]{
  --bg:#0b111b!important;
  --surface:#111a27!important;
  --surface-raised:#162131!important;
  --border:#283548!important;
  --text:#f3f6fa!important;
  --muted:#9caabd!important;
  --accent:#5aa7e8!important;
  --accent-strong:#77b8ee!important;
  --success:#70b98a!important;
  --warning:#c79b55!important;
  --error:#c97878!important;
  --shadow:0 24px 70px rgba(0,0,0,.42)!important;
  color-scheme:dark!important;
}
:root[data-ava-visit-theme="light"]{
  --bg:#F8FAFC!important;
  --surface:#FFFFFF!important;
  --surface-raised:#F1F5F9!important;
  --border:#D7DEE8!important;
  --text:#172033!important;
  --muted:#526176!important;
  --accent:#5aa7e8!important;
  --accent-strong:#3f8fd2!important;
  --success:#3f7f59!important;
  --warning:#9a6a24!important;
  --error:#a94f4f!important;
  --shadow:0 24px 70px rgba(23,32,51,.18)!important;
  color-scheme:light!important;
}

/* One app shell: 48px collapsed rail, 280px open rail, entire right shell reflows. */
.ava-app-shell{min-height:100dvh;display:grid;grid-template-columns:var(--ava-left-rail-closed) minmax(0,1fr);background:var(--bg);transition:grid-template-columns var(--ava-left-rail-transition) ease}
body.ava-rail-push .ava-app-shell{grid-template-columns:var(--ava-left-rail-width) minmax(0,1fr)}
.ava-app-shell>.shell{min-width:0;width:100%!important;margin:0!important;transition:none!important}

.ava-workspace-rail{position:sticky;top:0;z-index:35;height:100dvh;min-width:0;display:grid;grid-template-rows:auto minmax(0,1fr) auto;background:color-mix(in srgb,var(--surface) 97%,var(--bg));border-right:1px solid var(--border);overflow:hidden;box-shadow:none;visibility:visible!important;transform:none!important}
.ava-rail-header{height:56px;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px;border-bottom:1px solid color-mix(in srgb,var(--border) 62%,transparent)}
.ava-rail-mark{min-width:0;display:flex;align-items:center;gap:8px;overflow:hidden}
.ava-rail-mark-badge{width:28px;height:28px;flex:0 0 28px;display:grid;place-items:center;border-radius:8px;background:var(--surface-raised);color:var(--text);font-size:13px;font-weight:750}
.ava-rail-mark-name{font-size:14px;font-weight:700;white-space:nowrap}
.ava-rail-toggle{width:32px;height:32px;flex:0 0 32px;display:grid;place-items:center;border:1px solid transparent;border-radius:8px;background:transparent;color:var(--muted);font:inherit;font-size:17px;line-height:1;cursor:pointer}
.ava-rail-toggle:hover,.ava-rail-toggle.is-open{background:var(--surface-raised);color:var(--text)}

.ava-rail-scroll{min-height:0;overflow-y:auto;overflow-x:hidden;padding:10px 10px 18px;overscroll-behavior:contain;scrollbar-gutter:stable}
.ava-rail-nav{display:grid;gap:4px;margin-bottom:14px;padding-bottom:14px;border-bottom:1px solid color-mix(in srgb,var(--border) 48%,transparent)}
.ava-rail-new-chat,.ava-rail-destination{width:100%!important;min-height:40px!important;display:flex!important;align-items:center!important;justify-content:flex-start!important;text-align:left!important;padding:8px 10px!important;border:0!important;border-radius:9px!important;background:transparent!important;color:var(--text)!important;font:inherit!important;font-size:14px!important;font-weight:600!important;cursor:pointer!important}
.ava-rail-new-chat{background:var(--surface-raised)!important;margin-bottom:4px}
.ava-rail-new-chat:hover,.ava-rail-destination:hover{background:color-mix(in srgb,var(--surface-raised) 86%,transparent)!important}
.ava-rail-reserved-slot{height:36px;min-height:36px;pointer-events:none}
.ava-history-list{display:grid;gap:6px;margin-top:0!important}
.ava-history-item{width:100%;display:grid;gap:2px;text-align:left;border:0!important;border-radius:9px!important;padding:9px 10px!important;background:transparent!important;color:var(--text)!important}
.ava-history-item:hover{background:var(--surface-raised)!important}
.ava-history-item[aria-current="true"]{background:var(--surface-raised)!important;box-shadow:inset 3px 0 0 var(--accent)}
.ava-history-title{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ava-history-meta{font-size:11px;color:var(--muted)}
.ava-history-empty,.ava-history-note{color:var(--muted);font-size:12px;margin:10px 0 0}
.ava-rail-history-note{padding:0 4px}

.ava-rail-footer{display:grid;gap:4px;padding:10px;border-top:1px solid color-mix(in srgb,var(--border) 50%,transparent);background:color-mix(in srgb,var(--surface) 98%,var(--bg))}
.ava-rail-footer-button,.ava-rail-account{width:100%!important;min-height:38px!important;display:flex!important;align-items:center!important;justify-content:flex-start!important;padding:7px 10px!important;border:0!important;border-radius:9px!important;background:transparent!important;color:var(--muted)!important;font:inherit!important;font-size:13px!important;font-weight:600!important;text-align:left!important}
.ava-rail-footer-button{cursor:pointer!important}
.ava-rail-footer-button:hover{background:var(--surface-raised)!important;color:var(--text)!important}
.ava-rail-account{cursor:default;opacity:.72}

/* Closed desktop rail is a real 48px strip with the toggle only. */
body:not(.ava-rail-open) .ava-workspace-rail{width:var(--ava-left-rail-closed)}
body:not(.ava-rail-open) .ava-rail-header{height:56px;padding:8px;justify-content:center;border-bottom:0}
body:not(.ava-rail-open) .ava-rail-mark,
body:not(.ava-rail-open) .ava-rail-scroll,
body:not(.ava-rail-open) .ava-rail-footer{display:none!important}
body:not(.ava-rail-open) .ava-rail-toggle{display:grid!important}

/* The original destination controls are MOVED, not hidden or duplicated. */
.utility-actions{display:none!important}

/* Clean upper shell: AVA identity/status only. Showcase is parked for now and
   reserves no width or height. Conversation begins directly below the divider. */
.topbar{display:flex!important;align-items:center!important;justify-content:flex-start!important;gap:16px!important;padding:10px clamp(18px,3vw,32px)!important;min-height:78px!important;max-height:78px!important;overflow:hidden!important}
.identity{align-self:center!important}
.identity img{width:56px!important;height:56px!important;border-radius:14px!important}
.identity-copy{display:block!important}
.ava-identity-name-row{display:flex!important;align-items:center!important;gap:8px!important;min-width:0!important}
.identity-name{font-size:20px!important;margin:0!important}
.identity-label{font-size:12px!important;margin-top:2px!important}
.ava-header-status.status{display:inline-flex!important;align-items:center!important;margin:0!important;min-height:0!important;font-size:11px!important;gap:5px!important;white-space:nowrap!important}
.ava-showcase{display:none!important;width:0!important;height:0!important;margin:0!important;padding:0!important}
.workspace{padding-top:18px!important}

/* Secondary Project / Library / Settings surfaces keep their real handlers and
   remain overlays. Only the old Chats overlay is converted into the app rail. */
.drawer{z-index:60}

/* Tablet/mobile: the rail becomes a sheet. Main stays full width. */
@media(max-width:1023px){
  .ava-app-shell{display:block;min-height:100dvh}
  .ava-workspace-rail{position:fixed;left:0;top:0;z-index:70;width:min(var(--ava-left-rail-width),88vw)!important;height:100dvh;transform:translateX(calc(-100% + var(--ava-left-rail-closed)))!important;transition:transform var(--ava-left-rail-transition) ease;box-shadow:10px 0 34px rgba(0,0,0,.22)}
  body.ava-rail-open .ava-workspace-rail{transform:translateX(0)!important}
  body:has(.drawer.open) .ava-workspace-rail{transform:translateX(calc(-100% + var(--ava-left-rail-closed)))!important}
  body:not(.ava-rail-open) .ava-workspace-rail{display:grid!important}
  body:not(.ava-rail-open) .ava-rail-header{justify-content:flex-end}
  body:not(.ava-rail-open) .ava-rail-mark,
  body:not(.ava-rail-open) .ava-rail-scroll,
  body:not(.ava-rail-open) .ava-rail-footer{display:none!important}
  .ava-app-shell>.shell{width:100%!important;margin:0!important}
  .topbar{padding-left:max(56px,env(safe-area-inset-left))!important}
}

@media(max-width:680px){
  .workspace{padding-top:10px!important}
  .ava-workspace-rail{width:min(280px,90vw)!important}
  .topbar{min-height:68px!important;max-height:68px!important;padding-top:7px!important;padding-bottom:7px!important}
  .identity img{width:46px!important;height:46px!important;border-radius:12px!important}
  .identity-name{font-size:18px!important}
  .identity-label{display:none!important}
}

@media(max-width:390px){
  .ava-workspace-rail{width:min(280px,92vw)!important}
  .ava-rail-scroll{padding-bottom:max(18px,env(safe-area-inset-bottom))}
  .composer-wrap{position:sticky!important;bottom:0!important}
}

@media(prefers-reduced-motion:reduce){
  .ava-app-shell,.ava-workspace-rail{transition:none!important}
}
/* AVA_LEFT_RAIL_V1_END */
