/* Chat layout: one scrollable conversation between the header and composer. */
:root { --sidebar: 264px; --chat-width: 800px; --muted: #aaa9a5; --dim: #94938d; --app-height: 100dvh; }
[hidden] { display: none !important; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid #ffc44c; outline-offset: 3px; }
button:disabled { cursor: default; opacity: .45; }
.sr-only, .history-search-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-chat { position: fixed; left: 12px; top: -100px; z-index: 200; padding: 12px; background: #ffc44c; color: #111; border-radius: 8px; }
.skip-chat:focus { top: 12px; }
.app-shell { position: fixed; top: var(--viewport-top, 0px); left: 0; right: 0; height: var(--app-height); transition: none; }
.sidebar { padding: 20px 14px 14px; background: #101111; border-right: 1px solid #252525; }
.sidebar-head { margin: 0 0 18px; grid-template-columns: minmax(0,1fr) 32px; }
.brand { gap: 10px; }
.brand small { color: #a4a39c; }
.sidebar-toggle { position: static; width: 32px; height: 36px; }
.new-chat { flex: 0 0 auto; display: flex; align-items: center; min-height: 44px; gap: 10px; margin: 0 0 20px; padding: 0 13px; border: 1px solid #645020; border-radius: 12px; background: #242014; font-size: 14px; color: #ffdf96; }
.new-chat:hover { background: #30291a; }
.history-section { display: flex; flex-direction: column; min-height: 60px; flex: 1; margin: 0 0 12px; overflow: hidden; }
#historySearch { width: 100%; flex: 0 0 auto; min-height: 40px; padding: 8px 12px; border: 1px solid #303131; border-radius: 9px; color: #f5f3ed; background: #181a1a; font: inherit; font-size: 13px; }
#historySearch::placeholder { color: #969893; }
.history-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 18px 4px 8px; }
.history-heading h2 { margin: 0; font-size: 12px; letter-spacing: .03em; color: #b8b9b1; font-weight: 600; }
#historyArchiveToggle { min-height: 32px; padding: 4px 6px; font-size: 11px; color: #b4b5ae; border: 0; background: transparent; }
.history-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; max-height: none; scrollbar-width: thin; scrollbar-color: #424340 transparent; }
.history-row { display: flex; align-items: center; gap: 2px; border-radius: 9px; flex: 0 0 auto; }
.history-row.is-active { background: #292921; }
.history-row:hover { background: #252626; }
.history-list .history-open { display: block; width: auto; flex: 1; min-width: 0; height: auto; min-height: 40px; padding: 10px; color: #d6d6cf; font-size: 13px; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: transparent; border: 0; }
.history-list .history-open::before { display: none; }
.history-list .history-archive { display: block; flex: 0 0 30px; width: 30px; min-height: 36px; padding: 0; background: transparent; border: 0; border-radius: 8px; color: #b6b6af; font-size: 20px; opacity: 0; }
.history-row:hover .history-archive, .history-row:focus-within .history-archive { opacity: 1; }
.history-empty { font-size: 12px; color: #b1b1aa; margin: 12px; }
.sidebar-links { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid #2c2c2a; }
.sidebar-links a, .sidebar-links button { display: block; padding: 8px 9px; border: 0; background: transparent; color: #c0c0b8; text-align: left; font-size: 12px; border-radius: 8px; }
.sidebar-links a:hover, .sidebar-links button:hover { background: #252626; color: #fff; }
.plan-box { display: grid; gap: 8px; margin: 0; padding: 12px 8px; border-top: 1px solid #2c2c2a; }
.plan-box div { display: grid; gap: 5px; }
.plan-box strong { font-size: 13px; }
.plan-box span { max-width: none; color: #b3b3aa; font-size: 11px; line-height: 1.55; }
.plan-box a { justify-self: start; color: #ffcf69; font-size: 12px; }
.history-privacy { flex: 0 0 auto; padding: 0 8px; color: #969890; font-size: 10px; line-height: 1.45; }
.history-privacy p { margin: 0 0 4px; }
.history-privacy button, .history-privacy a { padding: 0; margin-right: 8px; border: 0; background: transparent; color: #b3b4ad; text-decoration: underline; font: inherit; }
.chat-area { height: var(--app-height); display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: 64px minmax(0,1fr) auto; overflow: hidden; background: radial-gradient(ellipse at 50% 32%,rgba(165,121,28,.035),transparent 48%),#080909; }
.chat-area > * { min-width: 0; }
.topbar { position: relative; min-height: 64px; padding: 0 28px; display: flex; gap: 12px; align-items: center; background: #0b0c0c; border-bottom: 1px solid #202222; pointer-events: auto; }
.chat-title-group { display: flex; align-items: center; min-width: 0; gap: 4px; flex: 1; }
.topbar .chat-title { display: block; margin: 0; min-width: 0; color: #e6e6de; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#renameConversation { flex: 0 0 32px; width: 32px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #a5a69e; font-size: 19px; }
.site-home-link { flex: 0 0 auto; min-height: 38px; padding: 0 12px; border: 1px solid #4c4025; border-radius: 10px; font-size: 12px; background: #1d1b13; }
.chat-body { position: relative; min-height: 0; overflow: hidden; }
.workspace { position: absolute; inset: 0; display: block; width: 100%; height: 100%; padding: 0; overflow: clip; }
.conversation { position: absolute; inset: 0; width: min(800px,calc(100% - 64px)); height: 100%; padding: 32px 0 28px; margin: 0 auto; overflow: auto; scroll-behavior: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a3c37 transparent; }
.conversation::-webkit-scrollbar { display: block; width: 5px; }
.conversation::-webkit-scrollbar-thumb { background: #3a3c37; border-radius: 8px; }
.starter { inset: 0; width: min(660px,calc(100% - 56px)); padding: 20px 4px; align-content: safe center; justify-items: center; overflow: auto; gap: 0; pointer-events: auto; animation: none; scrollbar-width: thin; scrollbar-color: #3a3c37 transparent; }
.starter-logo { width: 48px; height: 48px; margin: 0 auto 12px; box-shadow: 0 0 32px rgba(255,176,0,.08); }
.starter p.starter-eyebrow { margin: 0 0 10px; color: #cbb889; font-size: 11px; letter-spacing: .18em; }
.starter h1 { font-size: clamp(28px,3.3vw,40px); line-height: 1.16; font-weight: 620; letter-spacing: -.03em; }
.starter p:not(.starter-eyebrow) { max-width: 445px; margin: 14px auto 0; color: #aeb0a6; font-size: 14px; line-height: 1.6; }
.chat-mode-tabs { display: flex; gap: 6px; margin-top: 24px; padding: 4px; border: 1px solid #2d2e29; border-radius: 999px; background: #121413; }
.chat-mode-tabs button { padding: 8px 16px; min-height: 36px; border: 0; border-radius: 999px; background: transparent; color: #b0b3a9; font-size: 12px; }
.chat-mode-tabs button.active { background: #3c3320; color: #ffdf9b; }
.starter-grid { width: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 24px; }
.starter-card { display: flex; align-items: flex-start; gap: 12px; min-height: 94px; padding: 17px 16px; border: 1px solid #2b2e28; border-radius: 14px; background: #141615; box-shadow: none; }
.starter-card::before { display: none; }
.starter-card:hover { background: #1d201a; transform: translateY(-1px); border-color: #68552a; box-shadow: none; }
.starter-card .starter-symbol { display: block; flex: 0 0 24px; font-size: 21px; line-height: 1.3; color: #c5a45d; }
.starter-card .starter-copy { display: block; min-width: 0; }
.starter-card strong { display: block; color: #e2e5da; font-size: 13px; line-height: 1.4; margin: 0 0 6px; }
.starter-card .starter-copy > span { color: #a1a79c; font-size: 12px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.starter p.starter-about { font-size: 11px; color: #a6ad9f; margin-top: 16px; }
.starter-about a { color: #c9cbbf; text-decoration: underline; text-underline-offset: 3px; }
.composer, body.sidebar-collapsed .composer { position: relative; inset: auto; width: min(820px,calc(100% - 56px)); padding: 8px 0 max(12px,env(safe-area-inset-bottom)); margin: 0 auto; background: #080909; z-index: 30; }
.input-row { display: block; min-height: 0; padding: 12px 14px 8px; border: 1px solid #4b4633; border-radius: 20px; background: #1b1e1b; box-shadow: 0 8px 32px rgba(0,0,0,.13); }
.input-row:focus-within { border-color: #c3953c; box-shadow: 0 0 0 2px rgba(255,176,0,.06); }
.input-row textarea { display: block; width: 100%; min-height: 44px; max-height: 160px; padding: 8px 3px; margin: 0; border: 0; background: transparent; color: #f1f2e9; font-size: 16px; line-height: 1.5; resize: none; outline: 0; overflow: auto; }
.input-row textarea::placeholder { color: #a1a99b; }
.composer-toolbar { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.attach-btn { flex: 0 0 36px; width: 36px; height: 36px; min-height: 36px; background: transparent; border: 0; color: #c1c9ba; font-size: 24px; padding: 0; }
.composer-options-trigger { width: auto; height: 34px; min-height: 34px; padding: 0 11px; border: 1px solid #3b4237; border-radius: 999px; background: #242a23; color: #c6cebd; font-size: 11px; white-space: nowrap; }
.character-count { margin-left: auto; color: #b4b8aa; font-size: 10px; }
.send-btn, .stop-btn { flex: 0 0 36px; width: 36px; height: 36px; min-height: 36px; margin-left: auto; display: grid; place-items: center; padding: 0; border-radius: 12px; border: 0; background: #edcf8a; color: #171d13; font-size: 23px; box-shadow: none; }
.stop-btn { font-size: 15px; }
.send-btn:disabled { background: #343b2f; color: #798271; opacity: 1; }
.composer-hint { margin: 8px 0 0; text-align: center; color: #a1a99b; font-size: 10px; line-height: 1.5; }
.composer-hint a { margin-left: 5px; color: #c5cbbd; text-decoration: underline; }
.request-status { min-height: 0; color: #ccb67f; font-size: 12px; line-height: 1.4; padding: 0 10px; }
.request-status:not(:empty) { padding-bottom: 10px; }
.attach-menu, .composer-options-menu { position: absolute; left: 0; right: auto; top: auto; bottom: calc(100% - 8px); width: min(380px,100%); max-width: 100%; max-height: min(450px,calc(var(--app-height) - var(--composer-height) - 80px)); overflow: auto; overscroll-behavior: contain; border: 1px solid #4b4938; border-radius: 16px; padding: 12px; background: #191c18; box-shadow: 0 12px 40px #0008; }
.attach-menu button { min-height: 42px; color: #d4d9cd; font-size: 13px; }
.attach-menu { width: min(310px,100%); padding: 7px; }
.attach-menu button[data-attach-kind] { min-height: 64px; padding: 10px 12px; gap: 13px; }
.attach-menu svg { flex: 0 0 23px; width: 23px; height: 23px; fill: none; stroke: #d6bc80; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.attach-menu .attach-option-copy { display: grid; justify-items: start; gap: 4px; width: auto; height: auto; flex: 1; border: 0; border-radius: 0; color: #edece4; font-weight: 400; }
.attach-option-copy strong { font-size: 14px; font-weight: 600; }
.attach-option-copy small { color: #a5aa9e; font-size: 11px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 146px; overflow: auto; padding: 2px 0 10px; scrollbar-width: thin; }
.attachment-card { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; width: 232px; padding: 8px; border: 1px solid #3e4538; border-radius: 12px; background: #252b22; }
.attachment-card img { flex: 0 0 42px; width: 42px; height: 42px; object-fit: cover; border-radius: 7px; }
.attachment-file-icon { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 7px; background: #36392c; color: #dfc88e; font-size: 10px; font-weight: 650; }
.attachment-copy { display: grid; min-width: 0; flex: 1; gap: 3px; }
.attachment-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; color: #e1e5d8; }
.attachment-copy small { color: #b0b7a5; font-size: 10px; line-height: 1.4; }
.attachment-card button { display: grid; place-items: center; flex: 0 0 32px; min-height: 36px; padding: 0; border: 0; border-radius: 8px; color: #d7decf; background: transparent; font-size: 21px; }
.attachment-card button:hover { background: #404735; }
.attachment-status { margin: 4px 2px; font-size: 12px; color: #d8c594; }
.message.user .attachment-card { margin: 0 0 10px; width: 270px; background: #2a3124; }
.message.user .attachment-card img { width: 56px; height: 56px; flex-basis: 56px; }
.composer-options-menu { display: none; gap: 12px; }
.composer-options-menu.open { display: grid; }
.composer-options-menu > div { display: flex; flex-wrap: wrap; gap: 6px; }
.composer-options-menu strong { width: 100%; margin: 0 0 3px; color: #afb9a4; font-size: 11px; }
.composer-options-menu button { min-height: 36px; padding: 7px 12px; color: #d2d9c9; border: 1px solid #394330; border-radius: 9px; background: #222b1d; font-size: 12px; }
.composer-options-menu button.active { border-color: #b19450; background: #473c22; color: #ffe3a4; }
.language-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: #c6d0ba; }
.language-setting select { min-height: 40px; border: 1px solid #4c5841; border-radius: 9px; background: #222b1d; color: #e1e8d7; padding: 6px 9px; font-size: 14px; }
.message, .message.user { display: grid; grid-template-columns: 26px minmax(0,1fr); gap: 12px; margin: 0 0 28px; animation: none; }
.message.user { grid-template-columns: minmax(0,1fr); padding-left: 40px; }
.message.user .avatar { display: none; }
.message.user .message-content { justify-self: end; width: auto; max-width: 100%; }
.message-content { min-width: 0; }
.avatar { width: 26px; height: 26px; font-size: 9px; animation: none !important; box-shadow: none; }
.avatar::after { display: none; }
.bubble { font-size: 15px; line-height: 1.75; overflow-wrap: anywhere; }
.message.user .bubble { padding: 12px 18px; border: 1px solid #363c2f; border-radius: 18px 18px 5px 18px; background: #21271d; color: #e1e6d8; }
.user-text { white-space: pre-wrap; margin: 0; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble a { color: #f0d18a; text-decoration: underline; text-underline-offset: 3px; }
.bubble pre { padding: 16px; overflow: auto; border: 1px solid #353b2e; border-radius: 12px; background: #131711; line-height: 1.55; font-size: 13px; }
.bubble pre code { white-space: pre; background: transparent; padding: 0; }
.table-scroll { width: 100%; overflow: auto; margin: 18px 0; border: 1px solid #3d4435; border-radius: 10px; }
.bubble table { border-collapse: collapse; min-width: 100%; font-size: 13px; }
.bubble th, .bubble td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #343b2d; vertical-align: top; }
.bubble th { color: #ede2c1; background: #262d20; white-space: nowrap; }
.message-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; opacity: 1; }
.message-actions button, .image-download { min-height: 36px; border: 1px solid transparent; padding: 6px 9px; border-radius: 7px; background: transparent; color: #b9c2ad; font-size: 12px; }
.message-actions button:hover { color: #f2e0af; border-color: #4d513f; background: #222a1d; }
.generated-image { display: block; max-width: 100%; max-height: 520px; height: auto; object-fit: contain; border-radius: 16px; }
.image-download { display: inline-block; color: #e9ce8b; text-decoration: underline; margin-top: 8px; }
.is-pending .bubble { color: #c4b382; }
.is-pending .avatar { opacity: .65; }
.is-error .bubble { padding: 12px; border: 1px solid #61483a; border-radius: 12px; background: #2a211b; color: #e7cabc; }
.is-limit .upgrade-cta { width: min(100%,580px); margin: 0; padding: 20px; gap: 10px; border: 1px solid #494232; border-radius: 16px; background: #191b17; box-shadow: none; }
.is-limit .upgrade-cta strong { color: #ece6d6; font-size: 16px; line-height: 1.4; }
.is-limit .upgrade-cta p { margin: 0; color: #b8b9ad; font-size: 14px; line-height: 1.6; }
.is-limit .upgrade-cta a { min-height: 40px; margin-top: 4px; gap: 10px; padding: 0 14px; border: 1px solid #74603a; border-radius: 10px; background: #322b1d; color: #eed49c; font-size: 13px; font-weight: 600; }
.is-limit .upgrade-cta a:hover { background: #453920; border-color: #b79550; }
.is-limit .upgrade-cta a span { color: inherit; font-size: 16px; }
.scroll-latest { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 15; min-height: 36px; padding: 7px 12px; border-radius: 99px; border: 1px solid #5b5c46; background: #2b3123; color: #e4e8d7; font-size: 12px; }
.chat-notice { position: fixed; top: 76px; left: calc(var(--sidebar) + (100% - var(--sidebar))/2); transform: translateX(-50%); max-width: min(580px,calc(100vw - 32px)); width: max-content; padding: 14px 18px; border: 1px solid #807044; border-radius: 12px; background: #292a20; color: #ede2bd; z-index: 180; font-size: 13px; line-height: 1.5; box-shadow: 0 12px 44px #0008; }
.chat-dialog { width: min(420px,calc(100vw - 32px)); padding: 24px; border: 1px solid #5a593e; border-radius: 18px; color: #eee8d5; background: #1d2218; }
.chat-dialog::backdrop { background: #000a; }
.chat-notice { pointer-events: none; }
.chat-dialog h2 { margin: 0 0 20px; font-size: 20px; }
.chat-dialog label { display: block; margin-bottom: 8px; font-size: 13px; }
.chat-dialog input { width: 100%; min-height: 44px; padding: 10px; border: 1px solid #60664b; border-radius: 10px; background: #13190f; color: #eee; font: inherit; }
.chat-dialog form > div { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.chat-dialog button { min-height: 40px; padding: 8px 14px; border: 1px solid #6d6847; border-radius: 9px; color: #e8dfc3; background: #363923; }
body.sidebar-collapsed { --sidebar: 64px; }
@media (min-width:981px) {
  body.sidebar-collapsed .sidebar { width: 64px; padding: 16px 8px; }
  body.sidebar-collapsed .sidebar-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; width: 100%; }
  body.sidebar-collapsed .brand { display: flex; order: 0; margin: 0; width: 36px; height: 36px; }
  body.sidebar-collapsed .sidebar-toggle { position: static; order: 1; margin: 0; width: 36px; }
  body.sidebar-collapsed .brand span:last-child, body.sidebar-collapsed .new-chat span:last-child,
  body.sidebar-collapsed .history-section, body.sidebar-collapsed .sidebar-links, body.sidebar-collapsed .history-privacy, body.sidebar-collapsed .plan-box { display: none !important; }
  body.sidebar-collapsed .new-chat { display: flex; justify-content: center; width: 44px; min-height: 44px; margin: 0; padding: 0; }
}
@media (max-width:980px) {
  :root, body.sidebar-collapsed { --sidebar: 0px; }
  .sidebar, body.sidebar-collapsed .sidebar { width: min(306px,86vw); height: var(--app-height); padding: 20px 14px 14px; z-index: 100; }
  .mobile-menu-btn, body.sidebar-open .mobile-menu-btn { display: grid; place-items: center; position: static; flex: 0 0 38px; width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 10px; opacity: 1; color: #d2d7c9; background: #171c13; border-color: #353d2d; box-shadow: none; }
  .sidebar-backdrop { z-index: 90; top: var(--viewport-top,0px); height: var(--app-height); }
  .topbar { padding: 0 16px; gap: 10px; }
  .history-list .history-archive { opacity: 1; }
  .chat-notice { left: 50%; }
}
@media (max-width:680px) {
  .chat-area { grid-template-rows: 60px minmax(0,1fr) auto; }
  .topbar { min-height: 60px; padding: 0 12px; gap: 8px; }
  .topbar .chat-title { font-size: 13px; }
  .site-home-link { min-height: 36px; padding: 0 10px; font-size: 11px; }
  .site-home-link span { font-size: 14px; }
  #renameConversation { flex-basis: 26px; width: 26px; font-size: 17px; }
  .starter { width: calc(100% - 32px); padding: 28px 0; }
  .starter-logo { width: 42px; height: 42px; margin-bottom: 10px; }
  .starter h1 { font-size: 30px; }
  .starter p.starter-eyebrow { font-size: 10px; margin-bottom: 10px; }
  .starter p:not(.starter-eyebrow) { max-width: 310px; font-size: 13px; margin-top: 12px; line-height: 1.6; }
  .chat-mode-tabs { margin-top: 20px; }
  .chat-mode-tabs button { padding: 7px 14px; font-size: 12px; }
  .starter-grid { gap: 8px; margin-top: 18px; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .starter-card { display: block; min-height: 100px; padding: 12px; border-radius: 12px; }
  .starter-card .starter-symbol { font-size: 19px; margin-bottom: 7px; }
  .starter-card strong { font-size: 12px; }
  .starter-card .starter-copy > span { font-size: 11px; -webkit-line-clamp: 2; }
  .starter p.starter-about { font-size: 11px; }
  .conversation { width: calc(100% - 28px); padding: 24px 0; }
  .message { grid-template-columns: 22px minmax(0,1fr); gap: 9px; }
  .message.user { padding-left: 24px; }
  .avatar { width: 22px; height: 22px; }
  .bubble { font-size: 14px; line-height: 1.7; }
  .message.user .bubble { padding: 10px 14px; }
  .composer, body.sidebar-collapsed .composer { width: calc(100% - 24px); padding: 6px 0 max(8px,env(safe-area-inset-bottom)); }
  .input-row { padding: 8px 10px; border-radius: 18px; }
  .composer-toolbar { gap: 6px; }
  .input-row textarea { min-height: 44px; font-size: 16px; padding: 7px 3px; }
  .composer-hint { font-size: 9px; margin-top: 6px; }
  .composer-options-trigger { font-size: 11px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
  .character-count { position: absolute; top: -14px; right: 8px; font-size: 9px; }
  .request-status { font-size: 11px; }
  .attach-menu, .composer-options-menu { max-height: max(140px,calc(var(--app-height) - var(--composer-height) - 80px)); }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
