/* Chat page refinements: fluid scaling, attachment tray, drag & drop, readable sizes. Loaded after petoai.css (chat page only).
   --s is the single scale factor: screen width steps x the user's "Tekstin koko" preference (data-text-size on <html>). */
:root { --s: 1; --pref: 1; }
@media (min-width: 1400px) { :root { --s: 1.1; } }
@media (min-width: 1700px) { :root { --s: 1.2; } }
@media (min-width: 2300px) { :root { --s: 1.45; } }
@media (min-width: 3200px) { :root { --s: 1.9; } }
html[data-text-size="large"] { --pref: 1.12; }
html[data-text-size="xlarge"] { --pref: 1.25; }
:root { --z: calc(var(--s) * var(--pref)); }

/* layout: sidebar and content scale with the factor instead of fixed pixels */
.app { grid-template-columns: calc(286px * var(--z)) minmax(0, 1fr) !important; }
.content { width: min(calc(980px * var(--z)), calc(100% - 48px)) !important; }
.composer { width: min(calc(980px * var(--z)), 100%) !important; }
.message { max-width: calc(880px * var(--z)) !important; grid-template-columns: calc(36px * var(--z)) minmax(0, 1fr) !important; }
.message.user { grid-template-columns: minmax(0, 1fr) calc(36px * var(--z)) !important; max-width: min(calc(760px * var(--z)), 100%) !important; width: fit-content; min-width: calc(330px * var(--z)); }
.avatar { width: calc(36px * var(--z)) !important; height: calc(36px * var(--z)) !important; font-size: calc(12px * var(--z)) !important; }
.message.user .bubble { overflow-wrap: anywhere; min-width: calc(260px * var(--z)); }
.message.user { justify-self: end; }
.brand img { width: calc(186px * var(--z)) !important; }

/* text: no size below 12px at 1x, everything proportional */
.bubble { font-size: calc(15px * var(--z)) !important; line-height: 1.6; }
.bubble .who { font-size: calc(11px * var(--z)) !important; }
.bubble .meta, .conv-notice { font-size: calc(12px * var(--z)) !important; }
#text { font-size: calc(15.5px * var(--z)) !important; min-height: calc(48px * var(--z)); max-height: calc(200px * var(--z)); }
.composer-note { font-size: calc(12px * var(--z)) !important; }
.side-link { font-size: calc(14px * var(--z)) !important; }
.new-chat { font-size: calc(16px * var(--z)) !important; }
.capability strong { font-size: calc(13px * var(--z)) !important; }
.capability small, .capability .value { font-size: calc(12px * var(--z)) !important; }
.title-block strong { font-size: calc(16px * var(--z)) !important; }
.title-block span, #connectionText { font-size: calc(12.5px * var(--z)) !important; }
.prompt strong { font-size: calc(14px * var(--z)) !important; } .prompt span { font-size: calc(12px * var(--z)) !important; }
.hero p { font-size: calc(15px * var(--z)) !important; }
.bubble img { max-width: min(calc(420px * var(--z)), 100%); max-height: calc(300px * var(--z)); }

/* composer: tray row above the input row */
.composer { grid-template-columns: auto auto minmax(0, 1fr) auto !important; }
/* COMPOSER_GRID_20261107: attach | mic | text | send. #923 added the Puhu button to the 3-column grid above, so the mic took the
   1fr column, the text box shrank to a stamp and send wrapped to a second row. The text box and the send/stop buttons are
   placed explicitly, so an added or hidden button can never take the text column again. */
.composer > #text { grid-column: 3; }
.composer > #send, .composer > #stop { grid-column: 4; }
.composer .tray { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 6px; }
.attach { width: auto !important; min-width: calc(46px * var(--z)); height: calc(46px * var(--z)) !important; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
          font-size: calc(14px * var(--z)) !important; font-weight: 700; color: #cfe3ec; position: relative; }
.send { height: calc(46px * var(--z)) !important; font-size: calc(15px * var(--z)); }
.attach-count { min-width: 18px; height: 18px; border-radius: 9px; background: var(--orange); color: #14100c; font-size: 11px; line-height: 18px; text-align: center; font-weight: 800; padding: 0 5px; }
.chip-att { display: inline-flex; align-items: center; gap: 8px; max-width: min(100%, calc(320px * var(--z))); padding: 5px 6px 5px 8px; border: 1px solid rgba(73,213,232,.35);
            border-radius: 10px; background: rgba(73,213,232,.07); font-size: calc(13px * var(--z)); }
.chip-att img { width: calc(30px * var(--z)); height: calc(30px * var(--z)); object-fit: cover; border-radius: 6px; }
.chip-att .ic { font-size: calc(18px * var(--z)); line-height: 1; }
.chip-att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip-att .sz { color: var(--pt-muted); font-size: calc(12px * var(--z)); white-space: nowrap; }
.chip-att .rm { width: calc(26px * var(--z)); height: calc(26px * var(--z)); border: 0; border-radius: 7px; background: transparent; color: #cfe3ec; font-size: calc(18px * var(--z)); cursor: pointer; line-height: 1; }
.chip-att .rm:hover { background: rgba(255,123,121,.2); color: #ff7b79; }
.attach-note { width: min(calc(980px * var(--z)), 100%); margin: 0 auto 8px; padding: 8px 12px; border: 1px solid rgba(255,200,106,.45); border-radius: 10px;
               background: rgba(255,200,106,.08); color: #ffd98f; font-size: calc(13px * var(--z)); }
.drop-hint { width: min(calc(980px * var(--z)), 100%); margin: 0 auto 8px; padding: 14px; text-align: center; border: 2px dashed var(--orange); border-radius: 14px;
             background: rgba(255,122,26,.1); color: #ffd2ad; font-weight: 700; font-size: calc(14px * var(--z)); }
body.dragging .composer { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,.18); }
.speak-btn { display: inline-block; margin: 10px 0 0; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.03); color: #cfe3ec;
             font-size: calc(12.5px * var(--z)); cursor: pointer; }
.speak-btn:hover { border-color: rgba(73,213,232,.5); background: rgba(73,213,232,.08); }
.speak-btn { display: block; width: fit-content; }

/* narrow screens: keep the sidebar hidden (existing behaviour) but make the composer touch-friendly */
@media (max-width: 850px) {
  .app { grid-template-columns: 1fr !important; }
  .attach-label { display: none; }
  .attach { padding: 0 12px; }
  .content, .composer, .message { width: auto !important; max-width: 100% !important; }
  .send { font-size: calc(14px * var(--z)); }
  .send::after { content: none; }
}
@media (max-width: 600px) {
  form#form { grid-template-columns: auto auto 1fr !important; row-gap: 6px; }
  .composer > #text { grid-column: 1 / -1; grid-row: 2; }
  .composer > #imgbtn { grid-column: 1; grid-row: 3; }
  .composer > #mic { grid-column: 2; grid-row: 3; }
  .composer > #send, .composer > #stop { grid-column: 3; grid-row: 3; justify-self: end; min-width: 64px; }
}
@media (max-height: 700px) { .hero { min-height: 190px !important; } }

/* ST12_P0_CHAT_LAYOUT_V1 (2026-10-20): compact composer that never covers the conversation.
   - hidden attachment tray / hint really hidden (the flex rule above overrode [hidden] and added an empty row)
   - input and buttons scale with --z but are clamped, so the empty composer stays ~56-80 px at every width / text size
   - text-size preference scales through --pref only: body zoom on top double-scaled and pushed the 100vh shell past the window */
.composer .tray[hidden], .drop-hint[hidden], .attach-count[hidden] { display: none !important; }
.composer { padding: 6px !important; }
#text { min-height: clamp(42px, calc(42px * var(--z)), 54px) !important; max-height: min(30vh, 220px) !important; overflow-y: auto; padding: 11px 7px 9px; }
.attach, .send { height: clamp(42px, calc(42px * var(--z)), 52px) !important; }
.attach { min-width: clamp(42px, calc(42px * var(--z)), 52px); }
.composer-note { margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.composer .tray:not([hidden]) { max-height: min(22vh, 140px); overflow-y: auto; }   /* many attachments never squeeze the conversation */
@media (max-height: 520px) { .composer-note { display: none; } }
html[data-text-size] body { zoom: 1 !important; }
@media (min-width: 851px) {
  .app { grid-template-columns: clamp(232px, calc(286px * var(--z)), 340px) minmax(0, 1fr) !important; }
}
