/* Settings replace the main navigation; chat state and controls stay mounted. */
:root .app-shell .nav-body155 {grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden}
#sidebar-return171 {grid-row:1}
#home-navigation171,#settings-navigation171 {grid-row:2;min-width:0;min-height:0}
#home-navigation171 {overflow:hidden}
#settings-navigation171 {overflow:auto}
#home-navigation171 {display:grid;grid-template-rows:auto auto auto minmax(0,1fr);gap:8px}
#settings-navigation171 {display:none}
:root .app-shell .nav-body155>.sidebar-footer {grid-row:3}
/* Only chat titles scroll. Commands, search, caption and footer stay outside
   the flexible list on both desktop and phone, including an empty list. */
:root .app-shell[data-nav155="drawer"] #home-navigation171 {display:flex;flex-direction:column;gap:calc(8px * .7 * 2 / 3);overflow:hidden}
/* Compact only the phone's main menu. Preserve label/answer typography and
   the shared viewport: scale the space around each label, not the text. */
:root .app-shell[data-nav155="drawer"] #home-navigation171>.sidebar-heading {display:none}
:root .app-shell[data-nav155="drawer"] #section-nav {--menu-row-height:42px;--menu-row-padding:9px;gap:calc(3px * .7);padding-bottom:calc(14px * .7)}
:root .app-shell[data-nav155="drawer"] #section-nav .sidebar-shortcut {min-height:calc(1.4em + (var(--menu-row-height) - 1.4em) * .7);padding-block:calc(var(--menu-row-padding) * .7)}
@media (max-height:660px) {
  :root .app-shell[data-nav155="drawer"] #section-nav {--menu-row-height:34px;--menu-row-padding:5px;gap:0;padding-bottom:calc(8px * .7)}
}
/* A short landscape viewport still leaves a reachable chat row. Compact
   only button padding; labels, command order and fixed footer are retained. */
@media (max-height:450px) {
  :root .app-shell[data-nav155="drawer"] #section-nav {--menu-row-height:22.4px;--menu-row-padding:0px;padding-bottom:0}
}
:root .app-shell[data-nav155="drawer"] #home-navigation171>:not(.chat-section) {flex:0 0 auto}
:root .app-shell[data-nav155="drawer"] #home-navigation171 .chat-section {display:flex;flex-direction:column;flex:1 1 0;min-height:0;overflow:hidden}
:root .app-shell[data-nav155="drawer"] #home-navigation171 .section-caption {flex:0 0 auto}
:root .app-shell[data-nav155="drawer"] #home-navigation171 .chat-list {flex:1 1 0;min-height:0;max-height:none;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain}
/* Visible gaps include the Archive button's padding and the text line boxes,
   not just the space between containers. Compact the caption row itself.
   Keep the search-to-caption outer gap and the gaps between chat rows intact. */
:root .app-shell[data-nav155="drawer"] #home-navigation171 .section-caption {padding-top:calc(.25rem - (8px * .7 * 2 / 3 + .25rem + .35rem) / 3 + .175rem);padding-bottom:calc(.25rem - (.25rem + .35rem) / 3)}
:root .app-shell[data-nav155="drawer"] #home-navigation171 #show-archived {padding-block:.175rem}
:root .app-shell[data-nav155="drawer"] .nav-body155>.sidebar-footer {padding-bottom:max(8px,env(safe-area-inset-bottom));margin:0;flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%}
:root .app-shell[data-nav155="drawer"][data-view171="chat-view"] .nav-body155>.sidebar-footer {background:var(--canvas155)}
:root .app-shell[data-nav155="drawer"] .sidebar {display:block;height:calc(var(--app-height,100dvh) - 28px);bottom:0}
:root .app-shell[data-nav155="drawer"] .nav-rail155 {display:none}
/* Definite drawer insets own height. The body has two fixed ends and one
   flexible navigation region; content cannot create implicit grid tracks. */
:root .app-shell[data-nav155="drawer"] .nav-body155 {position:absolute;inset:0;height:auto;display:flex;flex-direction:column;overflow:hidden}
:root .app-shell[data-nav155="drawer"] :is(#home-navigation171,#settings-navigation171) {flex:1 1 0;min-height:0;align-self:stretch}
:root .app-shell[data-nav155="drawer"] #sidebar-return171 {flex:0 0 auto}
:root .app-shell[data-nav155="drawer"] .sidebar-footer .settings-button {display:grid;place-items:center;width:42px;min-width:42px;height:42px;padding:0;border:0;background:transparent;color:var(--ink)}
:root .app-shell[data-nav155="drawer"] .nav-body155 :is(.brand strong,.sidebar-shortcut,.section-caption) {font-size:16px}
:root .app-shell[data-nav155="drawer"] .search-box input {height:calc(40px * 2 / 3);min-height:0;padding-block:2px;line-height:1.2}
:root .app-shell[data-view171="settings-view"] #home-navigation171 {display:none}
:root .app-shell[data-view171="settings-view"] #settings-navigation171 {display:block}
:root .app-shell .return-chat171 {display:flex;align-items:center;gap:12px;width:100%;min-height:44px;padding:8px 12px;border:0;border-radius:10px;background:transparent;color:var(--ink);font:inherit;font-size:var(--desktop-navigation-size,18px);line-height:1.3;text-align:left}
.return-chat171 svg {width:22px;height:22px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
:root .app-shell .return-chat171:hover {background:var(--sidebar)}
.return-chat171:focus-visible {outline:2px solid var(--blue);outline-offset:-2px}
:root .app-shell[data-view171="chat-view"] #sidebar-return171 {display:none}
:root .app-shell[data-nav155="drawer"] .sidebar #sidebar-return171 {display:none}
.section-return171 {display:none}
:root .app-shell:not([data-view171="chat-view"]) .topbar {display:none}
:root .app-shell:not([data-view171="chat-view"]) .main-column {grid-template-rows:minmax(0,1fr)}
#settings-navigation171 h2 {margin:16px 16px 24px;font-size:var(--desktop-navigation-size,22px);line-height:1.3;font-weight:650}
:root .app-shell .settings-search171 {display:flex;align-items:center;gap:8px;margin:0 8px 24px;padding:10px 14px;background:var(--sidebar);border-radius:28px;font-size:var(--desktop-navigation-size,18px)}
.settings-search171 input {min-width:0;width:100%;padding:0;border:0;border-radius:0;background:transparent;font:inherit}
#settings-navigation171 .settings-nav {display:grid;grid-template-columns:minmax(0,1fr);gap:4px;position:static}
:root .app-shell #settings-navigation171 .settings-nav button {min-width:0;min-height:48px;padding:12px 16px;font-size:var(--desktop-navigation-size,18px);line-height:1.4;font-weight:400}
:root .app-shell #settings-navigation171 .settings-nav button {background:transparent;box-shadow:none}
:root .app-shell #settings-view {padding:40px max(24px,4vw)}
:root .app-shell #settings-view .settings-layout {display:block;width:min(100%,calc(1080px / var(--desktop-ui-scale,1)));max-width:none;margin-inline:auto}
:root .app-shell #settings-view .settings-content {width:100%;container-type:inline-size}
:root .app-shell #settings-view .settings-content>section>h3 {font-size:calc(30px / var(--desktop-ui-scale,1));line-height:1.3;font-weight:600;margin:0 0 48px}
:root .app-shell #settings-view .settings-content>section>h4 {font-size:calc(22px / var(--desktop-ui-scale,1));font-weight:600;line-height:1.4;margin:32px 0 16px}
.settings-card171 {padding:4px 24px;border:1px solid var(--line);border-radius:20px;background:var(--panel)}
:root .app-shell #settings-view .setting-row {display:grid;grid-template-columns:minmax(0,1fr) minmax(180px,32%);gap:24px;min-width:0;padding:22px 0;line-height:1.4}
:root .app-shell #settings-view .setting-row>span {min-width:0}
:root .app-shell #settings-view .setting-row small {max-width:none;font-size:.8em;line-height:1.5;margin-top:5px}
:root .app-shell #settings-view .setting-row>:is(select,input) {width:100%;min-width:0;max-width:none;border-radius:14px;padding:10px 14px;background:var(--sidebar)}
.settings-card171>.setting-row:last-of-type {border-bottom:0}
.settings-save171 {display:flex;gap:16px;align-items:center;justify-content:space-between;padding:12px 0;border-top:1px solid var(--line)}
:root .app-shell #settings-view .settings-save171 .help {margin:0;font-size:calc(16px / var(--desktop-ui-scale,1));line-height:1.5}
:root .app-shell #settings-view .settings-save171 button {margin:0;flex:none;border-radius:14px}
#style-saved:empty {display:none}
@container (max-width:650px) {
  :root .app-shell #settings-view .setting-row {grid-template-columns:minmax(0,1fr);gap:12px}
  .settings-save171 {align-items:stretch;flex-direction:column}
}
:root .app-shell[data-nav155="drawer"]:not([data-view171="chat-view"]) .main-column {grid-template-rows:auto minmax(0,1fr)}
:root .app-shell[data-nav155="drawer"]:not([data-view171="chat-view"]) .section-return171 {display:block;padding:2px 8px;border-bottom:1px solid var(--line);background:var(--canvas155)}
:root .app-shell[data-nav155="drawer"] .return-chat171 {min-height:40px;font-size:16px}
:root .app-shell[data-nav155="drawer"] #sidebar-return171 {height:calc(40px * 2 / 3);min-height:0;padding-block:2px}
:root .app-shell[data-nav155="drawer"] #settings-view {padding:24px 16px}
:root .app-shell[data-nav155="drawer"] #settings-view .settings-content>section>h3 {font-size:26px;margin-bottom:28px}
:root .app-shell[data-nav155="drawer"] #settings-view .settings-content>section>h4 {font-size:20px;margin-top:24px}
:root .app-shell[data-nav155="drawer"] #settings-view .settings-save171 .help {font-size:15px}
:root .app-shell[data-nav155="drawer"] .settings-card171 {padding-inline:16px;border-radius:16px}
.settings-account {margin:4px 8px 12px;}
:root .app-shell .settings-account-button {width:100%;display:flex;align-items:center;gap:12px;padding:12px;border:0;border-radius:14px;background:transparent;color:var(--ink);font:inherit;text-align:left;box-shadow:none;}
.account-avatar {display:grid;place-items:center;flex:none;width:36px;height:36px;border-radius:50%;background:#f3a000;color:#181818;font-size:14px;}
.account-caption {display:flex;flex:1;flex-direction:column;gap:1px;min-width:0;}
#account-plan-name {color:var(--muted);font-size:.85em;}
.settings-accounts {position:fixed;z-index:100;overflow:auto;box-sizing:border-box;padding:8px;margin:0;border:1px solid var(--line);border-radius:14px;background:var(--panel);}
.settings-accounts .help {margin:6px 8px 12px;overflow-wrap:anywhere;}
:root .app-shell .settings-accounts button {width:100%;min-height:44px;padding:10px 8px;text-align:left;border:0;border-radius:10px;background:transparent;box-shadow:none;color:var(--ink);font:inherit;}
#subscription-account-current span {float:right;}
:root .app-shell .settings-sign-out {display:flex;align-items:center;gap:16px;width:calc(100% - 16px);margin:18px 8px 6px;padding:12px 16px;min-height:48px;border:0;border-radius:12px;background:transparent;color:var(--ink);font:inherit;text-align:left;box-shadow:none;}
.settings-sign-out svg {width:22px;height:22px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;}
@media (hover:hover) and (pointer:fine) {
  :root .app-shell :is(.settings-account-button,.settings-accounts button,.settings-sign-out,.settings-nav button):hover {box-shadow:var(--menu-shadow175);background:var(--sidebar);}
}

/* The phone keeps account and exit visible; only the eight sections scroll. */
:root .app-shell[data-nav155="drawer"][data-view171="settings-view"] #settings-navigation171 {display:flex;flex-direction:column;overflow:hidden}
:root .app-shell[data-nav155="drawer"] #settings-navigation171>.settings-account {flex:0 0 auto;margin-bottom:4px}
:root .app-shell[data-nav155="drawer"] .settings-navigation-scroll {flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}
:root .app-shell[data-nav155="drawer"] #settings-sign-out {flex:0 0 auto;margin-top:8px}

:root .app-shell[data-view171="settings-view"] #settings-navigation171 {display:flex;flex-direction:column;overflow:hidden}
#settings-navigation171 .settings-navigation-scroll {flex:1 1 auto;min-height:0;overflow:auto}
#settings-navigation171>.settings-account {flex:0 0 auto;margin:2px 8px}
#settings-navigation171>#subscription-account-signin {flex:0 0 auto;margin-top:2px}
:root .app-shell .nav-rail155 {flex-direction:column;align-items:center;justify-content:flex-end}
:root .app-shell .usage-ring214 {width:32px;height:32px;min-height:32px;min-width:32px;display:grid;place-items:center;padding:0;border:0;border-radius:50%;background:var(--line);color:var(--muted);box-shadow:none}
:root .app-shell .usage-ring214[data-known="true"] {background:conic-gradient(var(--ink) 0 var(--used214),var(--line) var(--used214) 360deg)}
.usage-ring214 span {background:var(--panel);border-radius:50%;display:grid;place-items:center;width:25px;height:25px;font-size:10px}
:root .app-shell[data-nav155="drawer"] .nav-body155>.sidebar-footer {display:grid;grid-template-columns:42px 1fr;grid-template-rows:32px 42px;gap:1px 10px}
:root .app-shell[data-nav155="drawer"] #usage-ring214 {grid-area:1/1;justify-self:center}
:root .app-shell[data-nav155="drawer"] #d1-menu-toggle {grid-area:2/1}
:root .app-shell[data-nav155="drawer"] .sidebar-build {grid-area:2/2;justify-self:end}
.usage-tip214 {position:fixed;z-index:140;max-width:min(310px,85vw);padding:8px 12px;background:var(--panel);border:1px solid var(--line);border-radius:9px;color:var(--ink);pointer-events:none;font-size:14px}
@media (max-height:450px) and (orientation:landscape) {
  :root .app-shell[data-nav155="drawer"] #section-nav {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-content:start}
  :root .app-shell[data-nav155="drawer"] #section-nav .sidebar-shortcut {min-width:0}
}
@media (max-height:450px) and (orientation:landscape) {
  :root .app-shell[data-nav155="drawer"] #home-navigation171 {gap:1px}
  :root .app-shell[data-nav155="drawer"] #section-nav .sidebar-shortcut {font-size:14px;white-space:nowrap;height:24px;min-height:24px;padding-block:0}
}
