/* Shared finish layer. Existing account palettes remain the source of color. */
:root{--chat-font-size:16px}
html:not([data-palette]){--fg-2:#69635b}
html[data-theme="dark"]:not([data-palette]){--fg-2:#b6afa3}
button,input,select,textarea,summary{font:inherit}
button{touch-action:manipulation}
:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
input::placeholder,textarea::placeholder{color:var(--fg-2);opacity:1}
.sidebar-header{min-height:64px;padding:12px 16px;border-bottom:0}
.sidebar-header .logo{font-size:18px;font-weight:700;letter-spacing:-.02em}
.sidebar-header .icon-btn{width:34px;height:36px;font-size:14px}
.new-chat{min-height:44px;margin:0 12px 10px;border-radius:10px;font-size:14px;font-weight:600}
.sidebar-footer{gap:4px;padding:8px 12px}
.sidebar-footer button{min-height:40px;justify-content:flex-start;padding-inline:12px;color:var(--fg)}
.account-bar{padding:14px 16px 10px;font-size:12px}
.sync-button{padding:6px 0;text-align:left;line-height:1.5}
.account-actions{flex-wrap:wrap;gap:4px}
.account-actions .btn{font-size:12px;min-height:36px;padding:6px 8px}
.top-bar{min-height:64px;padding:10px 24px;gap:12px}
.top-bar .title{font-size:15px;font-weight:600}
.top-bar select{min-height:38px;max-width:min(38vw,360px);font-size:13px;border-radius:9px;background:var(--bg-2)}
.top-bar .btn{font-size:13px;min-height:38px;border-radius:8px}
.messages{padding:28px 0 16px;scrollbar-gutter:stable}
.msg-wrap{max-width:900px;padding:0 28px}
.msg{gap:14px;margin-bottom:28px}
.msg .avatar{width:32px;height:32px}
.msg .role{font-size:12px;font-weight:600;margin-bottom:8px;min-height:20px}
.msg .role .msg-time{opacity:1;font-weight:400;font-size:11px}
.msg .content{font-size:var(--chat-font-size);line-height:1.8}
.msg .content h1,.msg .content h2,.msg .content h3{line-height:1.4;text-wrap:balance;margin-top:1.1em}
.msg .content p{margin:.6em 0;text-wrap:pretty}
.msg .content table{font-size:.94em;max-width:100%;display:block;overflow-x:auto}
.msg .content pre{font-size:13px;line-height:1.65;padding:16px}
.msg .msg-actions{justify-content:flex-start;gap:8px;margin-top:9px;opacity:.8}
.msg .msg-actions .act,.msg .msg-actions .copy{min-height:32px;border-radius:6px;padding:5px 8px;font-size:12px}
.msg .msg-actions button:hover,.msg .msg-actions button:focus-visible{background:var(--bg-2);color:var(--fg)}
.msg:focus-within .msg-actions,.msg:hover .msg-actions{opacity:1}
.msg .content pre:focus-within .copy-code{opacity:1}
.composer-wrap{padding:2px max(20px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left))}
.composer,.composer-resize-bar{max-width:860px}
.composer{border-radius:14px;padding:10px 12px 8px;gap:6px}
.composer:focus-within{border-color:var(--accent)}
.composer textarea:focus,.composer textarea:focus-visible{outline:none;border:0;box-shadow:none}
.composer textarea{padding:6px 4px;font-size:16px;line-height:1.6}
.composer-options{padding:0 2px;gap:6px;display:flex;flex-wrap:wrap}
.web-search-toggle{font-size:12px;padding:7px 10px;border-radius:8px;min-height:34px}
.composer-actions{padding:0;flex-wrap:nowrap;gap:5px}
.composer-actions .icon-btn{width:38px;height:38px;color:var(--fg-2)}
.composer-actions .icon-btn:hover{color:var(--fg);background:var(--bg-3)}
.composer-actions svg{width:19px;height:19px}
.composer-actions .hint{font-size:12px;max-width:45%}
.send-btn{width:40px;height:40px;flex:none;border-radius:10px}
.composer-resize-handle{min-height:18px}
.composer-resize-handle .resize-label{font-size:10px}
.composer-meta{display:flex;justify-content:space-between;gap:12px;color:var(--fg-2);font-size:11px;line-height:1.5;min-height:17px;padding:0 3px}
.composer-meta [hidden]{display:none}
.modal{width:min(800px,100%)}
.modal-header{padding:18px 24px}.modal-header h3{font-size:19px;font-weight:650}
.modal-body{padding:0 24px 24px;scrollbar-gutter:stable}
.tabs{position:sticky;top:0;z-index:1;background:var(--bg);padding-top:12px;gap:6px}
.tab{font-size:14px;min-height:44px;padding:10px 15px}
.form-row{margin-bottom:20px;gap:8px}
.form-row>label{font-size:14px;font-weight:550;line-height:1.5}
.form-row input:not([type=checkbox]):not([type=color]),.form-row select{min-height:44px}
.form-row input[type=checkbox]{width:18px!important;height:18px;vertical-align:middle;accent-color:var(--accent)}
.form-row .hint{font-size:12px;line-height:1.65;color:var(--fg-2)}
.settings-common{padding-top:10px}
.settings-section-heading{font-size:15px;margin:8px 0 20px;font-weight:650}
.settings-advanced{border-top:1px solid var(--border);margin-top:8px;padding-top:4px}
.settings-advanced>summary{cursor:pointer;min-height:50px;padding:14px 0;color:var(--fg);font-size:14px;font-weight:600}
.settings-advanced[open]>summary{margin-bottom:10px}
.provider-block{padding:18px;border-radius:12px}
.modal-footer{padding:14px 24px;gap:10px}.modal-footer .btn{min-height:42px;padding-inline:22px;font-size:14px}
.empty-state{max-width:580px;margin:auto;padding:48px 24px}
.empty-state h2{font-size:26px;letter-spacing:-.02em;font-weight:650}
.empty-state p{font-size:14px;line-height:1.7;color:var(--fg-2)}
.empty-state .prompts{gap:10px;justify-content:center}
.empty-state .prompts button{font-size:13px;border-radius:9px;padding:11px 14px;min-height:42px}
.simple-dialog{background:var(--bg);color:var(--fg);border:1px solid var(--border);border-radius:14px;padding:24px;width:min(460px,calc(100vw - 28px));max-height:calc(100dvh - 40px);overflow:auto}
.simple-dialog::backdrop{background:rgba(0,0,0,.4)}
.simple-dialog h2{font-size:20px;margin:0 0 12px}.simple-dialog p{font-size:13px;color:var(--fg-2);line-height:1.7}
.export-options{display:flex;flex-direction:column;gap:10px;margin:20px 0}
.export-options button{min-height:48px;padding:12px 16px;text-align:left;border:1px solid var(--border);border-radius:9px;background:var(--bg-2);font-size:14px}
.export-options button:hover{background:var(--bg-3)}
.dialog-end{display:flex;justify-content:flex-end}.dialog-end .btn{min-height:40px;padding:8px 16px}
.mobile-sidebar-close{display:none!important}
.chat-item:focus-within .actions{display:flex}
.chat-item{min-height:46px;gap:8px;padding:9px 10px}
.chat-item .actions .icon-btn{width:30px;height:32px;font-size:14px}
.chat-item .title{font-size:13px;line-height:1.5}
.chat-item .title:focus-visible{outline-offset:1px}
@media(max-width:1024px){
 .sidebar:not(.open){visibility:hidden}.sidebar.open{visibility:visible}
 .mobile-sidebar-close{display:inline-flex!important}
 .sidebar-header{padding:10px 12px;gap:5px}
 .top-bar{padding:8px 14px;gap:8px;min-height:60px}
 .top-bar select{font-size:16px;max-width:100%;min-height:40px}
 .msg-wrap{padding:0 22px}.messages{padding-top:24px}
 .composer-wrap{padding-inline:14px}
 .chat-item .actions{display:flex}.chat-item .actions .icon-btn{min-width:34px;height:36px}
}
@media(max-width:600px){
 .top-bar{display:grid;grid-template-columns:38px minmax(0,1fr) auto;padding:8px 12px;gap:6px}
 .top-bar .title{font-size:14px;width:100%}.top-bar #thinkingToggle{grid-row:2;grid-column:3;font-size:11px;padding:5px 8px;min-height:38px}
 .top-bar select{grid-row:2;grid-column:1 / 3;width:100%;min-width:0;padding:8px;font-size:13px}
 .top-bar .btn{padding:6px 8px;font-size:12px}
 .managed-account .top-bar{grid-template-columns:38px minmax(0,1fr) auto}
 .messages{padding-top:18px}.msg-wrap{padding:0 14px}.msg{gap:10px;margin-bottom:24px}
 .msg .avatar{width:28px;height:28px}.msg .role{margin-bottom:6px}
 .msg .content{font-size:var(--chat-font-size)}.msg .msg-actions{gap:2px}.msg .msg-actions .act,.msg .msg-actions .copy{padding:5px 6px;min-height:38px;font-size:11px}
 .composer-wrap{padding-inline:8px;padding-bottom:max(8px,env(safe-area-inset-bottom))}.composer{padding:8px 9px 6px;border-radius:12px}
 .composer-resize-handle .resize-label{display:none}.web-search-toggle{font-size:11px;min-height:36px;padding:6px 9px}
 .composer-actions .icon-btn{width:40px;height:40px}.send-btn{width:42px;height:42px}
 .composer-meta{font-size:10px}.composer-meta #sendShortcutHint{display:none}
 .composer-actions .hint{display:block;max-width:36%;font-size:10px}
 .modal-header{padding:14px 16px}.modal-body{padding:0 16px 20px}.modal-footer{padding:12px 16px max(12px,env(safe-area-inset-bottom))}
 .provider-block{padding:14px}.tab{padding-inline:12px}.row-2{grid-template-columns:1fr}
 .empty-state{padding:36px 18px}.empty-state h2{font-size:24px}
}
@media(any-pointer:coarse){
 .composer-actions .icon-btn,.send-btn{min-width:44px;min-height:44px}
 .web-search-toggle{min-height:40px}.msg .msg-actions .act,.msg .msg-actions .copy{min-height:40px}
 .chat-item .actions{display:flex}.chat-item .actions .icon-btn{min-width:36px;min-height:40px}
 .msg .content pre .copy-code{opacity:1;min-height:36px}
}
@media(max-height:540px){
 .top-bar{min-height:44px;padding-block:4px}.composer{gap:2px;padding-block:4px}.composer-wrap{padding-bottom:4px}
 .composer-meta{display:none}.web-search-toggle{min-height:30px;padding-block:4px}.composer-actions .icon-btn,.send-btn{min-height:34px;height:34px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
.workflow-search{position:relative;margin:0 12px 10px;flex:none}
.workflow-search input{width:100%;font-size:13px;height:40px;padding:8px 34px 8px 12px;background:var(--bg);border-radius:9px}
.workflow-search input::-webkit-search-cancel-button{display:none}
.workflow-search button{position:absolute;right:2px;top:2px;width:36px;height:36px;font-size:20px;border-radius:7px}
.workflow-search button[hidden]{display:none}
.workflow-search-status{font-size:11px;color:var(--fg-2);padding:0 16px 8px}
.workflow-chat-copy{display:flex;flex:1;min-width:0;flex-direction:column;gap:3px}
.workflow-search-preview{font-size:11px;line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--fg-2)}
.workflow-draft-indicator{font-size:10px;color:var(--accent)}
.workflow-draft-indicator[hidden]{display:none}
.workflow-no-results{padding:8px 10px;font-size:13px;line-height:1.7;color:var(--fg-2)}
.workflow-pin[aria-pressed=true]{color:var(--accent);background:var(--bg-3)}
.chat-item.pinned>.workflow-chat-copy>.title::before{content:'·';color:var(--accent);font-weight:800;margin-right:5px}
@media(max-width:1024px){.workflow-search input{font-size:16px;height:44px}.workflow-search button{height:40px}}

.sidebar-footer{grid-template-columns:1fr}.sidebar-footer button{justify-content:flex-start}

[data-panel="account"] .account-bar{border:0;padding:20px 0 12px;font-size:15px}
[data-panel="account"] .account-bar>div:first-child{font-size:16px}
[data-panel="account"] .sync-button{font-size:13px;margin-top:12px;min-height:40px}
[data-panel="account"] .account-actions{justify-content:flex-start;gap:10px;margin-top:22px}
[data-panel="account"] .account-actions .btn{font-size:14px;min-height:44px;padding:10px 16px;background:var(--bg-2);border-radius:8px}
[data-panel="account"] .account-actions .btn:hover{background:var(--bg-3)}
.tabs{flex-wrap:nowrap;overflow-x:auto;flex-shrink:0}.tabs .tab{flex-shrink:0}


/* GPT-iPad-style desktop sidebar collapse */
.desktop-sidebar-collapse{display:none}
html.sidebar-collapsed .desktop-sidebar-collapse{display:none}
@media (min-width:1025px){
  .desktop-sidebar-collapse{display:inline-flex}
  html.sidebar-collapsed .sidebar{
    width:0!important;min-width:0!important;max-width:0!important;
    overflow:hidden;border-right-width:0;opacity:0;pointer-events:none;
    transition:width .2s ease,opacity .15s ease,border-color .15s ease;
  }
  html:not(.sidebar-collapsed) .sidebar{
    transition:width .2s ease,opacity .15s ease;
  }
  html.sidebar-collapsed .menu-btn{display:inline-flex!important}
  html.sidebar-collapsed .desktop-sidebar-collapse{display:none!important}
  /* Keep chat column centered when sidebar is gone (ChatGPT-like ~768px) */
  html.sidebar-collapsed .msg-wrap,
  html.sidebar-collapsed .composer,
  html.sidebar-collapsed .composer-resize-bar,
  html.sidebar-collapsed .welcome-suggestions{
    max-width:768px;
  }
  html.sidebar-collapsed .msg .content{max-width:72ch}
}
@media (max-width:1024px){
  /* Narrow screens keep existing off-canvas drawer; ignore desktop collapse layout */
  html.sidebar-collapsed .sidebar{
    width:min(320px,86vw)!important;min-width:0;max-width:320px;opacity:1;pointer-events:auto;
  }
  html.sidebar-collapsed .desktop-sidebar-collapse{display:none!important}
}
@media (prefers-reduced-motion:reduce){
  html.sidebar-collapsed .sidebar,html:not(.sidebar-collapsed) .sidebar{transition:none!important}
}
