/* DIE2HARD Studio 1.21 — part 1: the assistant and the forms.
   Loaded after studio-fit.css. Markdown in answers, numbered sources, folded technical notes, a compact composer, field errors,
   and a dialog that stays above the on-screen keyboard. */

/* =================================================================== assistant answers */
#chatLog .chat-message .ui-plain{display:block;white-space:pre-wrap;overflow-wrap:anywhere}
#chatLog .chat-message .ui-md{display:grid;gap:var(--ui-2);white-space:normal;font-size:14.5px;line-height:1.55;overflow-wrap:anywhere}
#chatLog .chat-message .ui-md>*{margin:0;min-width:0}
#chatLog .chat-message .ui-md strong{font-weight:700;color:#f6f1ea}
#chatLog .chat-message .ui-md em{font-style:italic}
#chatLog .chat-message .ui-md h4{margin:var(--ui-2) 0 0;font:700 14.5px/1.3 var(--sans);color:#f6f1ea}
#chatLog .chat-message .ui-md ul,#chatLog .chat-message .ui-md ol{padding-left:1.3em;display:grid;gap:5px}
#chatLog .chat-message .ui-md li{padding-left:2px}
#chatLog .chat-message .ui-md li::marker{color:#a49d93}
#chatLog .chat-message .ui-md blockquote{border-left:2px solid #6a5844;padding:2px 0 2px 12px;color:#d6cfc4}
#chatLog .chat-message .ui-md pre{overflow-x:auto;background:rgba(255,255,255,.07);border-radius:10px;padding:10px 12px;font:12.5px/1.5 var(--mono);white-space:pre;-webkit-overflow-scrolling:touch}
#chatLog .chat-message .ui-md pre code{padding:0;background:none}
#chatLog .chat-message .ui-md hr{border:0;border-top:1px solid rgba(255,255,255,.14);width:100%}
#chatLog .chat-message .ui-md a{color:#ffb68a;text-underline-offset:3px;overflow-wrap:anywhere}
.ui-md-table{overflow-x:auto;-webkit-overflow-scrolling:touch}
.ui-md-table table{border-collapse:collapse;font-size:13px;min-width:100%}
.ui-md-table th,.ui-md-table td{padding:6px 10px;border-bottom:1px solid rgba(255,255,255,.12);text-align:left;vertical-align:top}
.ui-md-table th{font-weight:700;color:#f6f1ea;white-space:nowrap}
/* [1] marks: small numbers, the page opens when they are tapped */
.ui-cite{margin-left:2px;font-size:.7em;line-height:0;vertical-align:baseline;position:relative;top:-.5em}
.ui-cite a{display:inline-grid;place-items:center;min-width:1.55em;height:1.55em;padding:0 3px;border-radius:999px;background:rgba(242,101,34,.2);color:#ffb68a!important;font-weight:700;text-decoration:none!important}
.ui-cite.is-plain{color:#8c857b}
/* the pages an answer came from */
.ui-src{margin-top:var(--ui-3);border:1px solid rgba(255,255,255,.12);border-radius:12px;background:rgba(255,255,255,.03)}
.ui-src>summary{display:flex;align-items:center;min-height:44px;padding:0 var(--ui-3);cursor:pointer;list-style:none;font:600 12px var(--mono);letter-spacing:.08em;text-transform:uppercase;color:#a49d93}
.ui-src>summary::-webkit-details-marker{display:none}
.ui-src>summary::after{content:'';margin-left:auto;width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg) translateY(-2px);transition:transform .15s}
.ui-src[open]>summary::after{transform:rotate(-135deg) translateY(-2px)}
.ui-src ol{list-style:none;margin:0;padding:0}
.ui-src li a{display:grid;grid-template-columns:24px minmax(0,1fr);column-gap:10px;align-items:center;min-height:44px;padding:8px var(--ui-3);border-top:1px solid rgba(255,255,255,.08);color:#e8e3da;text-decoration:none}
.ui-src-n{grid-row:1/3;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:rgba(242,101,34,.2);color:#ffb68a;font:700 12px var(--sans)}
.ui-src-t{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;font-size:14px;line-height:1.3}
.ui-src li small{grid-column:2;color:#8c857b;font-size:12px}
/* a note about one moment ("web search unavailable") is folded, with its date, so it is not read as today's state */
.ui-md-note{margin-top:var(--ui-1);padding-top:var(--ui-2);border-top:1px dashed rgba(255,255,255,.16);font-size:12.5px;color:#a49d93}
.ui-md-note>summary{display:flex;align-items:center;min-height:32px;cursor:pointer}
.ui-md-note>summary::after{content:'';margin-left:8px;width:6px;height:6px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg) translateY(-2px);transition:transform .15s}
.ui-md-note[open]>summary::after{transform:rotate(-135deg) translateY(-2px)}
.ui-md-note>summary::-webkit-details-marker{display:none}
.ui-md-note>summary{list-style:none}
.ui-md-note p{margin:4px 0 0}
/* waiting and failing */
.ui-typing{display:inline-flex;align-items:center;gap:6px;color:#a49d93;font-size:14px}
.ui-typing i{width:6px;height:6px;border-radius:50%;background:#f26522;opacity:.3;animation:uiDot 1.1s infinite}
.ui-typing i:nth-child(2){animation-delay:.15s}.ui-typing i:nth-child(3){animation-delay:.3s}
.ui-typing span{margin-left:4px}
@keyframes uiDot{0%,80%,100%{opacity:.25}40%{opacity:1}}
@media (prefers-reduced-motion:reduce){.ui-typing i{animation:none;opacity:.7}}
#chatLog .chat-message .ui-ai-error p{margin:0;color:#ffac79}
#chatLog .chat-message .ui-ai-error details p{color:#cfc8bd}

/* the close mark of the assistant is a real "x", not a speck */
#assistant #closeAI{font-size:26px!important;line-height:1!important;color:#d6cfc4!important}

/* =================================================================== a compact composer: write first, the small controls in one row below */
#chatForm{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px}
#chatForm .chat-composer{order:1;flex:1 1 100%;margin-top:0}
#chatInput{resize:none}
#chatForm .web-toggle{order:3;height:36px;min-height:36px;margin:0;padding:0}
#chatForm .ai-footer{display:contents}
#chatForm .ai-footer .ai-ideas-btn{order:2}
#chatForm .ai-footer #micButton{order:4;min-height:36px}
#chatForm .ai-footer .ai-note{order:5;flex:1 1 100%;text-align:left}
.ai-ideas-btn{min-height:36px;padding:0 14px;border:1px solid #3d3a35;border-radius:999px;background:transparent;color:#d6cfc4;font:600 12.5px var(--sans)}
.ai-ideas-btn[aria-expanded=true]{border-color:#f26522;color:#ffb68a}
#aiPrompts button{min-height:40px}
@media (max-width:650px),(pointer:coarse) and (max-height:500px) and (max-width:1000px){
  /* one inset (12 px) for the whole panel: the title line, the status, the conversation and the composer were each indented a second time,
     and the title line left a band of empty space above the status */
  body.d19 #assistant.assistant.open{padding-left:12px!important;padding-right:12px!important;padding-bottom:6px!important}
  body.d19 #assistant .assistant-head{min-height:44px!important;padding:0!important;align-items:center;justify-content:space-between}
  body.d19 #assistant .assistant-head>div{display:flex;align-items:center;gap:8px}
  body.d19 #assistant .ai-status{padding:0!important;margin:0 0 6px!important}
  body.d19 #assistant #chatForm{padding:0 0 calc(var(--ui-2) + env(safe-area-inset-bottom))}
  body.d19 #assistant .ai-status #aiContext{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  body.d19 #assistant #chatInput{min-height:44px;max-height:112px;padding:12px}
  body.d19 #assistant .chat-composer{align-items:flex-end}
  body.d19 #assistant .web-toggle{display:flex!important}
  body.d19 #assistant .ai-footer{display:contents!important}
  body.d19 #assistant .web-toggle{gap:8px;font-size:12.5px}
  body.d19 #assistant .web-toggle input{width:18px;height:18px;flex:none}
  body.d19 #assistant .ai-note{font-size:10.5px}
  body.d19 #assistant #aiPrompts{display:flex;flex-wrap:nowrap;overflow-x:auto;gap:var(--ui-2);margin:0;padding:var(--ui-1) 0 var(--ui-2)!important;scrollbar-width:none}
  body.d19 #assistant #aiPrompts[hidden]{display:none!important}
  body.d19 #assistant #aiPrompts::-webkit-scrollbar{display:none}
  body.d19 #assistant #aiPrompts button{flex:none;white-space:nowrap;padding:0 var(--ui-3)}
}
/* held sideways there is little height: the note goes, the controls stay */
@media (pointer:coarse) and (max-height:500px) and (max-width:1000px){
  body.d19 #assistant .ai-note{display:none}
}

/* =================================================================== forms: what is wrong sits next to the field */
.ui-field-error{display:block;margin:6px 0 0;color:#ffa598;font:600 13.5px/1.4 var(--sans)}
.ui-field-error:empty{display:none}
.ui-field-error::before{content:'!';display:inline-grid;place-items:center;width:16px;height:16px;margin-right:7px;border-radius:50%;background:#ffa598;color:#161513;font:800 11px/1 var(--sans);vertical-align:1px}
.ui-field .ui-field-error,.p2-page .ui-field-error{color:var(--ui-red)}
.ui-field .ui-field-error::before,.p2-page .ui-field-error::before{background:var(--ui-red);color:#fff}
input[aria-invalid=true],select[aria-invalid=true],textarea[aria-invalid=true]{border-color:#ff8f80!important;box-shadow:0 0 0 1px #ff8f80!important}
/* a time pair that does not apply is not shown */
.d19-adv-grid[hidden]{display:none!important}

/* one frame around the composer: the container lights up, not a second box inside it */
.chat-composer textarea:focus,.chat-composer textarea:focus-visible{outline:0!important;box-shadow:none!important}
.chat-composer:focus-within{border-color:var(--orange,#f26522);box-shadow:0 0 0 1px var(--orange,#f26522)}

/* =================================================================== typing: dialog and assistant sit exactly above the on-screen keyboard
   --vvh / --vvt are the visible area (studio-v121.js). body.ui-kb = a text field has focus and the keys are up;
   body.ui-ai = the assistant is open. Nothing is navigated while typing, so the conversation gets every pixel that is left. */
@media (max-width:650px),(pointer:coarse) and (max-height:500px) and (max-width:1000px){
  body.d19.ui-kb dialog#modal[open]{top:var(--vvt,0px)!important;bottom:auto!important;height:var(--vvh,100dvh)!important;max-height:var(--vvh,100dvh)!important}
  body.d19.ui-kb.ui-ai #assistant.assistant.open{top:var(--vvt,0px)!important;bottom:auto!important;left:0!important;right:0!important;width:auto!important;max-width:none!important;height:var(--vvh,100dvh)!important;max-height:var(--vvh,100dvh)!important;border:0!important;border-radius:0!important;padding-top:0!important}
  body.d19.ui-kb.ui-ai #d19TabBar{display:none!important}
  body.d19.ui-kb.ui-ai #assistant{padding:0 12px!important}
  body.d19.ui-kb.ui-ai #assistant .assistant-head{min-height:34px!important;height:34px;padding:0!important;align-items:center}
  body.d19.ui-kb.ui-ai #assistant #closeAI{height:34px;min-height:34px;padding:0 10px}
  body.d19.ui-kb.ui-ai #assistant .ai-status,
  body.d19.ui-kb.ui-ai #assistant .voice-row,
  body.d19.ui-kb.ui-ai #assistant #aiPrompts,
  body.d19.ui-kb.ui-ai #assistant .web-toggle,
  body.d19.ui-kb.ui-ai #assistant .ai-footer>*{display:none!important}
  body.d19.ui-kb.ui-ai #assistant #chatLog{flex:1 1 auto;min-height:0}
  body.d19.ui-kb.ui-ai #assistant #chatForm{padding:0 0 8px!important}
  body.d19.ui-kb.ui-ai #assistant #chatInput{min-height:40px;padding:9px 12px}
}
/* an upright phone: the tab bar would float right above the keys, and there is nothing to open while typing */
@media (max-width:519px){
  body.d19.ui-kb #d19TabBar{display:none!important}
}
