/* Final chat composer overrides.
   This file is loaded last so the ask bar stays stable even with older
   refinement styles still in the bundle. */

#p-chat.panel.on{
  display:block !important;
  height:100%;
  min-height:0;
}

.main,
.workspace,
.panel.on{
  min-height:0;
}

.workspace{
  flex:1 1 auto;
}

#p-screen.panel.on,
#p-tasks.panel.on,
#p-comm.panel.on,
#p-settings.panel.on{
  display:flex !important;
  flex-direction:column;
  height:100%;
  min-height:0;
}

#p-chat .chat-layout{
  display:grid;
  grid-template-columns:minmax(248px,300px) minmax(0,1fr);
  gap:18px;
  height:100%;
  min-height:0;
}

#p-chat .chat-history-head-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

#p-chat .chat-history-collapse{
  width:40px;
  height:40px;
  border-radius:14px;
  border:1px solid rgba(61,48,33,.08);
  background:rgba(255,255,255,.78);
  color:var(--ink-soft);
  font-size:16px;
  cursor:pointer;
  transition:.18s ease;
}

#p-chat .chat-history-collapse:hover{
  transform:translateY(-1px);
}

body.chat-history-collapsed #p-chat .chat-layout{
  grid-template-columns:minmax(0,1fr);
  gap:0;
}

body.chat-history-collapsed #p-chat .chat-history-shell{
  display:none;
}

body.chat-history-collapsed #p-chat .chat-main{
  height:100%;
  min-height:0;
}

body.chat-history-collapsed #p-chat .cb{
  height:100%;
  min-height:0;
}

body.chat-history-collapsed #p-chat .iw,
body.chat-history-collapsed #p-chat .chat-approvals,
body.chat-history-collapsed #p-chat .tr,
body.chat-history-collapsed #p-chat .mr2,
body.chat-history-collapsed #p-chat #dbg{
  width:100% !important;
  max-width:none !important;
  margin-inline:0 !important;
}

body.chat-history-collapsed #p-chat .cf{
  width:100%;
}

#p-chat .chat-history-fab{
  position:absolute;
  top:18px;
  left:0;
  transform:translateX(-14px);
  width:34px;
  height:40px;
  border-radius:14px;
  border:1px solid rgba(61,48,33,.12);
  background:rgba(255,255,255,.92);
  color:var(--ink-soft);
  font-size:16px;
  cursor:pointer;
  transition:.18s ease;
  z-index:30;
}

#p-chat .chat-history-fab:hover{
  transform:translateX(-14px) translateY(-1px);
}

#p-chat .chat-layout{
  position:relative;
}

body.chat-history-collapsed #p-chat .chat-history-fab{
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

#p-chat .chat-history-shell{
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:18px;
  border:1px solid rgba(61,48,33,.08);
  border-radius:28px;
  background:rgba(255,252,248,.72);
  box-shadow:0 18px 44px rgba(55,39,18,.06);
  backdrop-filter:blur(16px);
}

.chat-history-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.chat-history-kicker{
  color:var(--accent);
  font-family:'IBM Plex Mono',monospace;
  font-size:10px;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.chat-history-head h2{
  margin-top:8px;
  font-family:'Cormorant Garamond',serif;
  font-size:30px;
  line-height:.96;
  letter-spacing:-.02em;
}

.chat-new-btn,
.chat-history-toggle,
.chat-conversation-action{
  border:none;
  cursor:pointer;
  transition:.18s ease;
}

.chat-new-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  align-self:flex-start;
  width:36px;
  height:36px;
  padding:0;
  border-radius:16px;
  background:#17120d;
  color:#fffaf4;
  font-family:'IBM Plex Mono',monospace;
  font-size:18px;
  line-height:1;
}

.chat-new-btn:hover,
.chat-history-toggle:hover,
.chat-conversation-action:hover{
  transform:translateY(-1px);
}

.chat-history-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:2px 2px 0;
}

.chat-history-count,
.chat-history-archived-head{
  color:var(--ink-soft);
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
  letter-spacing:.05em;
  text-transform:uppercase;
}

.chat-history-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  background:rgba(247,242,235,.96);
  color:var(--ink-soft);
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
}

.chat-history-list{
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  overflow:auto;
  padding-right:2px;
}

.chat-history-archived{
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding-top:4px;
  border-top:1px solid rgba(61,48,33,.08);
}

.chat-history-empty{
  padding:14px 16px;
  border:1px dashed rgba(61,48,33,.12);
  border-radius:18px;
  background:rgba(255,255,255,.58);
  color:var(--ink-soft);
  font-size:13px;
  line-height:1.65;
}

.chat-conversation-card{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border:1px solid rgba(61,48,33,.08);
  border-radius:20px;
  background:rgba(255,255,255,.76);
}

.chat-conversation-card.active{
  border-color:rgba(140,102,64,.22);
  background:linear-gradient(180deg,rgba(255,253,249,.96),rgba(248,241,232,.94));
  box-shadow:0 16px 28px rgba(55,39,18,.06);
}

.chat-conversation-open{
  display:flex;
  flex-direction:column;
  gap:0;
  padding:0;
  border:none;
  background:transparent;
  text-align:left;
  cursor:pointer;
  color:inherit;
  min-width:0;
}

.chat-conversation-top,
.chat-conversation-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.chat-conversation-title{
  font-size:14px;
  font-weight:600;
  line-height:1.35;
  color:var(--ink);
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
}

.chat-conversation-recency{
  color:var(--muted);
  font-family:'IBM Plex Mono',monospace;
  font-size:10px;
  line-height:1.4;
}

.chat-conversation-time,
.chat-conversation-meta{
  color:var(--muted);
  font-family:'IBM Plex Mono',monospace;
  font-size:10px;
}

.chat-conversation-preview{
  color:var(--ink-soft);
  font-size:12px;
  line-height:1.65;
}

.chat-conversation-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:4px;
}

.chat-conversation-action{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:28px;
  height:28px;
  padding:0;
  border:1px solid rgba(61,48,33,.08);
  border-radius:10px;
  background:transparent;
  color:var(--ink-soft);
  cursor:pointer;
}

.chat-conversation-action svg{
  width:15px;
  height:15px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.7;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.chat-conversation-action.danger{
  background:transparent;
  color:#7b3428;
}

#p-chat .chat-main{
  min-height:0;
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
}

#p-chat .cb{
  height:100%;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:auto;
}

#p-screen .sp,
#p-tasks .tp,
#p-comm .cp,
#p-settings .cp{
  flex:1 1 auto;
  min-height:0;
  height:100%;
  overflow:auto !important;
  -webkit-overflow-scrolling:touch;
}

#p-chat .cf{
  position:relative !important;
  left:auto !important;
  right:auto !important;
  bottom:auto !important;
  z-index:24 !important;
  width:100%;
  display:flex;
  flex-direction:column;
  flex:0 0 auto;
  gap:12px;
  margin-top:0;
  padding:16px 24px 24px;
  background:linear-gradient(180deg,rgba(243,237,228,0),rgba(243,237,228,.9) 22%,rgba(243,237,228,.98) 100%);
}

body:not(.chat-empty) #p-chat .cb::before{
  content:none !important;
}

#p-chat .iw{
  display:flex;
  align-items:flex-end;
  gap:14px;
  width:min(100%,860px);
  margin:0 auto;
  padding:10px 10px 10px 18px;
  border:1px solid rgba(61,48,33,.1);
  border-radius:30px;
  background:rgba(255,255,255,.94);
  box-shadow:0 18px 48px rgba(55,39,18,.08);
}

#p-chat .ifw{
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  border:none;
  border-radius:0;
  background:transparent;
  box-shadow:none;
}

#p-chat .ifw:focus-within{
  border:none;
  box-shadow:none;
}

textarea#inp{
  width:100%;
  min-height:56px;
  max-height:180px;
  resize:none;
  border:none;
  outline:none;
  background:transparent;
  padding:10px 4px 6px;
  color:var(--ink);
  font-family:'Sora',sans-serif;
  font-size:17px;
  line-height:1.55;
}

textarea#inp::placeholder{
  color:#988b7a;
}

.composer-meta{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  padding:4px 0 0;
}

.composer-select-wrap{
  display:inline-flex;
  align-items:center;
  gap:8px;
  height:34px;
  padding:0 12px;
  border:1px solid rgba(61,48,33,.1);
  border-radius:999px;
  background:rgba(247,242,235,.96);
}

.composer-select-label{
  color:var(--muted);
  font-family:'IBM Plex Mono',monospace;
  font-size:10px;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.composer-select{
  border:none;
  background:transparent;
  color:var(--ink);
  font-family:'Sora',sans-serif;
  font-size:12px;
  outline:none;
  cursor:pointer;
}

.composer-model-hint{
  color:var(--muted);
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
}

.composer-model-hint[hidden]{
  display:none;
}

.composer-status{
  margin-left:auto;
  display:inline-flex;
  align-items:center;
  gap:8px;
  height:34px;
  padding:0 12px;
  border:1px solid rgba(61,48,33,.1);
  border-radius:999px;
  background:rgba(247,242,235,.96);
  color:var(--ink-soft);
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
}

.sb{
  width:52px;
  height:52px;
  flex:0 0 auto;
  border-radius:18px;
  background:#17120d;
  color:#fffaf4;
  font-size:18px;
  box-shadow:none;
}

.sb:hover{
  background:#2a2119;
}

#p-chat .chat-approvals,
#p-chat .tr,
#p-chat .mr2{
  width:min(100%,860px);
  margin-inline:auto;
}

#p-chat .chat-approvals{
  margin-bottom:0;
}

#p-chat .tr{
  display:none;
  align-items:center;
  gap:12px;
  padding:0;
}

#p-chat .tr.on{
  display:flex;
}

#p-chat .td{
  padding:12px 14px;
}

#p-chat .thinking-indicator{
  display:inline-flex;
  align-items:center;
  gap:10px;
  border-radius:16px;
  border:1px solid rgba(61,48,33,.12);
  background:rgba(255,255,255,.88);
  box-shadow:0 10px 24px rgba(55,39,18,.06);
}

#p-chat .thinking-label{
  font-family:'IBM Plex Mono',monospace;
  font-size:11px;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--ink-soft);
}

#p-chat .thinking-dots{
  display:inline-flex;
  align-items:flex-end;
  gap:5px;
}

#p-chat .thinking-dots span{
  width:7px;
  height:7px;
  border-radius:50%;
  background:var(--accent);
  animation:thinkingDotBounce 1.1s ease-in-out infinite;
  opacity:.8;
}

#p-chat .thinking-dots span:nth-child(2){
  animation-delay:.14s;
}

#p-chat .thinking-dots span:nth-child(3){
  animation-delay:.28s;
}

@keyframes thinkingDotBounce{
  0%,80%,100%{transform:translateY(0) scale(.95);opacity:.45}
  40%{transform:translateY(-5px) scale(1);opacity:1}
}

body.chat-empty #p-chat.panel.on .cf{
  width:100%;
  margin-top:auto;
  padding:16px 24px 24px;
  background:linear-gradient(180deg,rgba(243,237,228,0),rgba(243,237,228,.9) 22%,rgba(243,237,228,.98) 100%);
}

body.chat-empty #p-chat.panel.on .iw{
  width:min(100%,860px);
  margin:0 auto;
}

body.chat-empty #p-chat.panel.on{
  display:block !important;
}

body.chat-empty #p-chat.panel.on .cb{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding:24px 24px 12px;
  overflow:auto;
}

body.chat-empty #p-chat.panel.on #starter{
  width:min(100%,860px);
  margin:0 auto 18px;
  padding:0 12px;
}

@media (max-width:980px){
  #p-chat .chat-layout{
    grid-template-columns:1fr;
    grid-template-rows:auto minmax(0,1fr);
  }

  body.chat-history-collapsed #p-chat .chat-layout{
    grid-template-rows:minmax(0,1fr);
  }

  #p-chat .chat-history-shell{
    padding:16px;
  }

  .chat-history-head h2{
    font-size:26px;
  }

  #p-chat .cf{
    padding:14px 16px 18px;
  }

  #p-chat .iw{
    width:100%;
  }
}

@media (max-width:640px){
  #p-chat .chat-history-shell{
    padding:14px;
    border-radius:24px;
  }

  .chat-history-head{
    flex-direction:column;
    align-items:flex-start;
  }

  .chat-new-btn{
    width:100%;
    justify-content:center;
  }

  .chat-history-toolbar{
    flex-direction:column;
    align-items:stretch;
  }

  .chat-conversation-top,
  .chat-conversation-meta,
  .chat-conversation-actions{
    flex-wrap:wrap;
  }

  #p-chat .cf{
    padding:12px 12px 14px;
  }

  #p-chat .iw{
    gap:10px;
    padding:8px 8px 8px 14px;
    border-radius:24px;
  }

  textarea#inp{
    font-size:16px;
    min-height:48px;
  }

  .composer-meta{
    gap:8px;
  }

  .composer-status{
    margin-left:0;
  }

  .sb{
    width:46px;
    height:46px;
    border-radius:16px;
  }

  body.chat-empty #p-chat.panel.on .cb{
    padding:12px 12px 8px;
  }

  body.chat-empty #p-chat.panel.on #starter{
    width:100%;
    padding:0;
  }
}

/* Late-loaded Observe overrides must stay after chat/mobile rules. */
#p-screen .sp{padding:16px;}
#p-screen .observe-shell{gap:12px;}
#p-screen .observe-head{gap:12px;padding:16px;border-radius:18px;}
#p-screen .observe-head-row{align-items:center;gap:14px;}
#p-screen .observe-title{font-size:22px;line-height:1.15;letter-spacing:0;}
#p-screen .observe-summary{max-width:760px;margin-top:4px;font-size:12px;line-height:1.55;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
#p-screen .observe-mark{width:42px;height:42px;border-radius:12px;}
#p-screen .work-stats{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;}
#p-screen .work-stat{min-height:76px;padding:10px 12px;border-radius:12px;}
#p-screen .metric-value{margin-top:5px;font-size:16px;line-height:1.25;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
#p-screen .metric-sub{display:block;margin-top:4px;font-size:10px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
#p-screen .observe-grid{grid-template-columns:repeat(12,minmax(0,1fr));gap:12px;}
#p-screen .section-card{border-radius:16px;padding:14px;}
#p-screen .section-head{min-height:32px;margin-bottom:8px;}
#p-screen .work-list{gap:8px;}
#p-screen .work-item{padding:12px;border-radius:12px;}
#p-screen .work-item:hover{transform:none;box-shadow:none;}
#p-screen .work-item-copy{font-size:12px;line-height:1.55;}
#p-screen .work-item-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
#p-screen .current-card,
#p-screen .observe-share-card{grid-column:span 5;}
#p-screen .observe-grid > .span-7{grid-column:span 7;}
#p-screen .observe-grid > .span-6{grid-column:span 6;}
#p-screen .observe-share{display:grid;grid-template-columns:minmax(0,1fr) minmax(260px,360px);grid-template-areas:"copy preview" "actions preview";gap:12px;align-items:start;}
#p-screen .observe-share-copy{grid-area:copy;font-size:12px;color:var(--ink-soft);line-height:1.6;}
#p-screen .observe-preview-wrap{grid-area:preview;min-height:126px;max-height:180px;border:1px solid rgba(61,48,33,.08);border-radius:12px;background:rgba(255,255,255,.58);overflow:hidden;}
#p-screen .observe-preview{width:100%;height:100%;min-height:126px;max-height:180px;display:block;object-fit:contain;background:transparent;}
#p-screen .observe-share-actions{grid-area:actions;margin-top:0;}

@media (max-width:980px){
  #p-screen .work-stats{grid-template-columns:repeat(2,minmax(0,1fr));}
  #p-screen .current-card,
  #p-screen .observe-share-card,
  #p-screen .observe-grid > .span-7,
  #p-screen .observe-grid > .span-6{grid-column:1 / -1;}
  #p-screen .observe-share{grid-template-columns:1fr;grid-template-areas:"copy" "preview" "actions";}
}

@media (max-width:640px){
  #p-screen .sp{padding:12px;}
  #p-screen .observe-head-row{align-items:flex-start;flex-direction:column;}
  #p-screen .observe-actions,
  #p-screen .observe-actions .btn{width:100%;}
  #p-screen .work-stats{grid-template-columns:1fr;}
  #p-screen .comm-title-wrap{align-items:flex-start;}
}
