[hidden] { display: none !important }
html { background: var(--bg) }
body { background: var(--bg); user-select: text }
main { max-width: 48rem; height: 100dvh; margin: auto; display: grid; grid-template-rows: auto minmax(0,1fr) auto auto; padding: env(safe-area-inset-top) max(12px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)) }
header, .rail-head, .controls { display: flex; align-items: center; gap: 9px }
header { min-height: 58px; border-bottom: 1px solid var(--border) }
.brand { border-radius: 8px }
.title { position: relative; display: grid; min-width: 0; gap: 2px; flex: 1 }
.title small,.desktop-meta,.hint,#status { color: var(--fg-muted); font-size: 11.5px }
.title strong { font-size:16px; line-height:1.3 }
.title strong,.p-head { overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
button, textarea { font-family: var(--font-ui); color: inherit }
button { min-height: 44px; border: 0; background: transparent; cursor: pointer; color: var(--fg-muted); font-size: 13px }
button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: -2px }
.title:has(#pick-thread:not([hidden])) { padding-right: 14px; width: max-content; max-width: calc(100% - 146px); flex: 0 1 auto }
#pick-thread { position: absolute; inset: 50% 0 auto; width: 100%; transform: translateY(-50%) }
#pick-thread::after { content: ""; position: absolute; top: 50%; right: 2px; width: 5px; height: 5px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg) }
#projects-button { margin-left: auto }
button:disabled { opacity: .55 }
#projects-button, #options-button { display:grid; place-items:center; width:44px; height:44px; flex:none; padding:0 }
#content { overflow: auto; overscroll-behavior: contain; padding: 8px 4px 12px }
#startup,#lock,#empty { display: grid; align-content: center; justify-items: center; height: 100%; color: var(--fg-muted); text-align: center }
h1 { font-size: 15px; font-weight: 600 } #lock p { max-width: 30ch; line-height: 1.5 }
.desktop-meta { padding: 4px 0 12px }
article { margin: 14px 0; white-space: pre-wrap; overflow-wrap: anywhere }
article.user, article.reply { display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 3px 9px }
.tile { grid-row: span 2; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--bg-raised) }
.tile.user { background: radial-gradient(at 10% 12%,var(--beam-warm),transparent 70%),linear-gradient(140deg,var(--beam-core),var(--beam-cool)) }
.tile img { width: 19px; height: 19px } article small { font-size: 12.5px; color: var(--fg); font-weight: 700 }
.reply-permalink { margin-inline-start: 9px; color: var(--fg-muted); font-size: 12px; font-weight: 400; text-underline-offset: 2px }
.msg-body { color: var(--fg-reading); font-size: 15px; line-height: 1.65 }
.msg-body a,.msg-body .message-file { color:var(--accent-strong); text-decoration:underline; text-underline-offset:2px }
.msg-body .message-file { display:inline; min-height:0; padding:0; font:inherit; text-align:inherit; overflow-wrap:anywhere }
.user .msg-body { width: fit-content; padding: 7px 11px; background: var(--card-strong); border: 1px solid var(--border); border-radius: 4px 14px 14px }
.task { padding: 10px 0; border-bottom: 1px solid var(--border) }
form { margin: 8px 0; padding: 6px; border: 1px solid transparent; border-radius: 14px; background: linear-gradient(var(--bg),var(--bg)) padding-box, linear-gradient(120deg,var(--border-strong),var(--accent-soft),var(--border-strong)) border-box }
form:focus-within { border-color: var(--accent) }
textarea { display: block; width: 100%; min-height: 44px; max-height: 24dvh; border: none; outline: none; resize: vertical; background: transparent; padding: 6px; font-size: 16px }
.controls { justify-content: space-between } #send { margin-left: auto; color: var(--accent-strong); font-weight: 650 } #mode[aria-pressed=true] { color: var(--accent-strong) }
#status { margin: 0 } #status:not(:empty) { padding: 3px }
dialog { inset: 0 0 0 auto; margin: 0 0 0 auto; width: min(86vw,340px); height: 100dvh; max-height: none; max-width: none; padding: env(safe-area-inset-top) max(12px,env(safe-area-inset-right)) env(safe-area-inset-bottom) 12px; color: var(--fg); background: var(--bg); border: 0; border-left: 1px solid var(--border-strong) }
dialog[open] { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto }
dialog::backdrop { background: rgb(0 0 0 / .5) }
.rail-head { justify-content: space-between; min-height: 58px } .rail-head h2 { font-size: 15px } #close-rail { width: 44px; font-size: 22px }
nav { overflow: auto; padding: 2px 2px 12px }
.project-card, .recent-cloud { padding: 3px 9px 6px; margin-bottom: 8px; display: grid; gap: 3px; box-shadow: none }
.p-head[aria-current=true]::before { background: var(--accent) }
#rail .rail-head h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#back-projects { display: grid; place-items: center; min-width: 44px }
.conversation-list.card { padding: 0; border: 0; background: transparent; box-shadow: none }
.conversation-group { margin: 10px 4px 4px; font-size: 12px; font-weight: 600; color: var(--fg-muted) }
.conversation-list .chip { min-height: 48px }
.p-head { color: var(--fg); font-size: 13px; font-weight: 600; text-align: left }
.p-head::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--fg-faint) }
.p-head svg { width: 13px; height: 13px; margin-left: 6px; vertical-align: -2px; fill: none; stroke: var(--accent-strong); stroke-linecap: round; stroke-linejoin: round }
.chip { display: flex; align-items: center; text-align: left; gap: 8px; border-radius: 6px; background: var(--bg-raised); padding: 4px 9px; overflow-wrap: anywhere }
.chip[aria-current=true] { box-shadow: inset 2px 0 var(--accent); background: var(--accent-soft); color: var(--fg) }
footer { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-block: 4px }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }

#options-button { width:44px; flex:none; letter-spacing:1px }
#options[open] { inset:auto 0 0; margin:0 auto; width:min(100%,32rem); height:auto; max-height:80dvh; grid-template-rows:auto minmax(0,1fr); border:1px solid var(--border-strong); border-radius:14px 14px 0 0; padding-bottom:max(12px,env(safe-area-inset-bottom)) }
#options-close { width:44px; font-size:22px }
#conversation-actions { display:grid; overflow:auto }
#conversation-actions button { width:100%; text-align:left; color:var(--fg); padding:8px 6px }
#cloud-check, #mac-actions { display:grid }
#send { white-space:nowrap; padding-inline:8px }
#draft { field-sizing:content; padding-block:10px; line-height:1.4; resize:none }
.title small { overflow:hidden; white-space:nowrap; text-overflow:ellipsis }

#filter { width: 100%; margin: 2px 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); color: var(--fg); font: 16px var(--font-ui); padding: 9px 10px; min-height: 44px }
.project-disclosure { display: flex; align-items: center; gap: 5px; min-width: 0; width: 100% }
.project-label { min-width: 0; overflow: hidden; text-overflow: ellipsis }
.project-empty { padding: 4px 9px; color: var(--fg-muted) }
.p-head::before { flex: none; margin-right: 3px }
.session-count { margin-left: auto; color: var(--fg-muted); font-size: 12px; font-weight: 500 }
.project-disclosure::after { content: ""; flex: none; width: 6px; height: 6px; border-right: 1px solid var(--fg-muted); border-bottom: 1px solid var(--fg-muted); transform: rotate(-45deg); margin: 0 4px }
#access-note { color: var(--fg-muted); font-size: 12px; border-top: 1px solid var(--border); padding: 10px 3px; margin: 0 }

.chip-label { min-width: 0; display: grid; gap: 3px; flex: 1 }
.chip-label > * { overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
.chip-label small { color: var(--fg-muted); font-size: 11.5px; font-weight: 400 }
.chip img { flex: none }

.receipt-action { color: var(--accent-strong); width: fit-content; text-align: left; padding-inline: 0 }
article button.quote-choice { text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 6px; outline: 1px dashed var(--border-strong); outline-offset: -1px }
article button.quote-choice:focus-visible { outline: 2px solid var(--accent-strong) }
article .receipt-action { grid-column: 2 }
.deliveries { margin-block: 6px 14px; border-bottom: 1px solid var(--border) }
.deliveries summary { cursor: pointer; padding-block: 14px; color: var(--fg-muted); font-size: 13px }
.delivery { display: grid; padding: 10px 0; gap: 4px; border-top: 1px solid var(--border) }
.delivery p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere }
.delivery small { color: var(--fg-muted) }
main:has(#access-note:not([hidden])):has(#compose:not([hidden])) { grid-template-rows: auto minmax(0,1fr) auto auto auto }

#repo-dialog[open] { grid-template-rows: auto minmax(0,1fr) }
#repo-dialog .rail-head h2 { overflow-wrap: anywhere }
#repo-close { width: 44px; font-size: 22px }
.repo-panel { overflow: auto }
.repo-link { text-align: left; font-size: 12px; color: var(--fg-muted) }
#repo-form { border: 0; background: transparent; padding: 6px 0; display: grid; gap: 8px }
#repo-form label,#repo-result strong { color: var(--fg); font-weight: 600 }
#repo-url { width: 100%; min-height: 44px; background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: 8px; color: var(--fg); font: 16px var(--font-ui); padding: 8px }
#repo-help,#repo-result p { margin: 0; line-height: 1.5; color: var(--fg-muted) }
#repo-start { justify-self: start; padding: 0 12px }
#repo-result { display: grid; gap: 6px; padding-block: 12px; overflow-wrap: anywhere }
#repo-result a { color: var(--accent-strong) }

#access-note:has(button) { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 0 }
.draft-row { display:flex; align-items:flex-end; gap:4px }
.draft-row textarea { flex:1; min-width:0 }
#ask-project-agent { flex:none; min-width:44px; padding-inline:8px; color:var(--accent-strong) }
#agent-source, #source-preview { display: flex; align-items: flex-start; gap: 8px; padding-inline: 6px }
.source-details { min-width: 0; flex: 1; max-height: 22dvh; overflow: auto; color: var(--fg-muted); font-size: 12px }
.source-details summary { cursor: pointer; padding-block: 12px; overflow-wrap: anywhere }
.source-details p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 3px 0 8px; color: var(--fg-reading) }
.source-details a { display: inline-block; padding-block: 10px; color: var(--accent-strong) }
#mac-history { margin: 6px 0 12px; padding-inline: 8px; border-bottom: 1px solid var(--border); max-height: 38dvh }
#mac-history-title { color: var(--fg-reading); font-weight: 600 }
#mac-history-preview { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
#mac-history[open] #mac-history-preview, #mac-history-preview:empty { display: none }
article .source-details { grid-column: 2 }

#files-dialog[open] { width: min(100vw,42rem); display: grid; grid-template-rows: auto minmax(0,1fr) auto }
#files-close,#import-close { min-width: 44px; font-size: 22px }
#files-list,#file-editor { overflow-y: auto; min-height: 0 }
#files-pick, #agent-upload-label, .import-pick { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding-inline: 12px; cursor: pointer }
#file-upload, #agent-upload, .import-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer }
#files-pick:focus-within, #agent-upload-label:focus-within, .import-pick:focus-within { outline: 2px solid var(--accent-strong) }
#files-entries { display: grid; gap: 6px; margin-block: 14px; color: var(--fg-muted) }
#file-editor { display: flex; flex-direction: column; gap: 8px }
#files-back { align-self: start; padding: 0 }
#file-name { overflow-wrap: anywhere }
#file-content { flex: 1; min-height: 8rem; max-height: none; resize: none; background: var(--bg-panel); color: var(--fg-reading); font: 16px/1.5 var(--font-mono); border: 1px solid var(--border); border-radius: 8px; padding: 8px }
#file-content:focus { border-color: var(--accent) }
#file-actions { display: flex; flex-wrap: wrap; gap: 8px }
#file-save { padding: 0 12px }
#file-conflict { color: var(--fg-muted); padding-block: 8px }
#file-conflict pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20dvh; overflow: auto }
#files-status { color: var(--fg-muted); font-size: 12px; padding-block: 6px }

#file-ai { flex: none; max-height: 45dvh; overflow: auto; border-top: 1px solid var(--border); color: var(--fg) }
#file-ai summary { cursor: pointer; padding-block: 12px; font-size: 13px }
.file-ai-body { display: grid; gap: 5px; padding-bottom: 8px }
.file-ai-body label, #proposal-state, #proposal-review small { color: var(--fg-muted); font-size: 12px }
#file-instruction { min-height: 48px; border: 1px solid var(--border); border-radius: 8px }
.file-ai-body button { justify-self: start; padding-inline: 10px }
#proposal-state { margin: 0 }
#proposal-review pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.4 var(--font-mono); margin: 4px 0 9px }

.return-picker { grid-column: 2; min-width: 0 }
.return-picker summary { width: fit-content; padding-block: 12px; color: var(--accent-strong); cursor: pointer; font-size: 13px }
.return-picker .chip { width: 100%; margin: 3px 0 }
#draft-limit { display: block; color: var(--fg-muted); padding-inline: 6px; font-size: 12px }

#repo-files, #repo-result details { color: var(--fg-muted); overflow-wrap: anywhere; font-size: 13px }
#repo-files summary, #repo-result summary { cursor: pointer; padding-block: 10px }
#repo-files ul, #repo-result ul { padding-inline-start: 18px }

#agent-dialog[open] { grid-template-rows: auto minmax(0,1fr) }
#agent-form { display: flex; flex-direction: column; gap: 8px; padding: 8px 2px max(12px,env(safe-area-inset-bottom)) }
#agent-question,#agent-provider,#agent-new-path,#repo-source { flex-shrink: 0; color: var(--fg-reading); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font: inherit; font-size: 16px }
#agent-files label { display: flex; align-items: center; gap: 8px; min-height: 44px; overflow-wrap: anywhere }
#agent-info { color: var(--fg-muted) }
#agent-start { align-self: start; min-height: 44px }

.agent-mode { display: flex; align-items: center; gap: 8px; min-height: 44px }
.agent-review { max-height: none }
.agent-review strong,.agent-review small { display: block; overflow-wrap: anywhere; margin-top: 8px }
.agent-review pre { margin: 4px 0; padding: 6px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-panel); color: var(--fg-reading); font-family: var(--font-mono) }
.agent-review button { margin-block: 8px; min-height: 44px }

#topic-name { width: 100%; min-height: 44px; padding: 6px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--fg); font: 16px var(--font-ui) }


#review-list { margin-bottom: 8px; padding: 3px 9px 6px; box-shadow: none }
#review-list summary { cursor: pointer; padding: 14px 8px; font-size: 13px; font-weight: 600 }
#review-list .chip { width: 100%; margin-bottom: 3px }
.recent-cloud > strong { font-size: 13px; padding: 4px 8px; color: var(--fg) }

#continuation-preview { border-top: 1px solid var(--border); margin: 14px 0 0; padding: 12px 0 0 }
#continuation-preview small, #continuation-question { color: var(--fg-muted); font-size: 12px }
#continuation-preview p { margin: 5px 0; white-space: pre-wrap; overflow-wrap: anywhere }
#continuation-answer { color: var(--fg-reading); font-size: 15px; line-height: 1.65 }
#continuation-open { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-strong); font-size: 13px }
#continuation-question, #continuation-answer { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden }
#continuation-question { -webkit-line-clamp: 2 }
#continuation-answer { -webkit-line-clamp: 5 }

#import-dialog[open] { width:min(100vw,42rem); grid-template-rows:auto minmax(0,1fr) auto }
#import-inputs { min-width:0; margin:0; border:0; padding:4px 0 }
#import-review small,#import-review strong { display:block }
#import-review mark { background:var(--accent-soft); color:inherit }
#import-review pre { max-height:28dvh; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font-family:var(--font-mono) }
#import-review details { margin-block:6px; overflow-wrap:anywhere }
#import-review summary,#import-review label { display:block; padding-block:10px }
#import-help,#import-review-help,#import-status { color:var(--fg-muted) }
#import-group,#import-list label { display:flex; align-items:center; gap:8px; min-height:44px; overflow-wrap:anywhere }
#import-search,#import-list input:not([type=checkbox]) { width:100%; padding:8px; color:var(--fg); background:var(--bg-panel); border:1px solid var(--border); border-radius:8px; font:inherit; font-size:16px }
#import-status { display:block } #import-share { margin-block:6px }

#import-search { margin-block:4px }
#import-share:enabled { color:var(--accent-strong) }

#stream .msg-body mark { background: var(--accent-soft); color: inherit; outline: 1px solid var(--accent); border-radius: 2px }

#startup { gap: 8px }
#startup h1 { margin: 0 }

#outage-draft { width: min(100%, 32rem); text-align: left; margin-block: 8px; font-size: 12px }
#outage-draft textarea { margin-top: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-raised) }

#earlier-activity:has(#continuation-preview[hidden]):has(#settled-receipts[hidden]) { display:none }
#earlier-activity { color:var(--fg-muted); border-bottom:1px solid var(--border) }
#earlier-title,.history-gap { min-height:44px; padding:12px 4px; font:inherit; font-size:12px; cursor:pointer }
#earlier-activity #continuation-preview { margin:0; padding:8px 4px 12px; border:0 }
#latest-message { position:sticky; bottom:4px; display:grid; place-items:center; width:44px; height:44px;
  margin:-44px 0 0 auto; z-index:1; background:var(--card-strong) }
.desktop-meta { padding:10px 6px 4px; border-top:1px solid var(--border) }
#compose { background:var(--bg-panel); border:1px solid var(--border-strong); margin:6px 0; }
#compose:focus-within { border-color:var(--accent) }
.draft-row { align-items:flex-end; gap:6px }
#send { min-height:44px; padding-inline:12px; flex:none; max-width:52%; white-space:normal }
#send:enabled { color:var(--fg); background:var(--accent-soft); border-color:var(--accent) }
#send:disabled { border-color:transparent; background:transparent; color:var(--fg-muted) }
#stream article { margin:20px 0 }
#stream .reply .msg-body { max-width:74ch; min-width:0; white-space:normal }
.reply .msg-body :is(p,h3,h4,h5,h6,ul,ol,pre) { margin:0 0 .7em }
.reply .msg-body > :last-child { margin-bottom:0 }
.reply .msg-body p,.reply .msg-body li { white-space:pre-wrap }
.reply .msg-body :is(h3,h4,h5,h6) { color:var(--fg); font-size:1em; font-weight:650; line-height:1.4 }
.reply .msg-body :is(ul,ol) { padding-inline-start:1.5em }
.reply .msg-body li+li { margin-top:.25em }
.reply .msg-body li::marker { color:var(--fg-muted) }
.reply .msg-body code { font: .89em var(--font-mono); background:var(--bg-raised); border-radius:4px; padding:1px 3px }
.reply .msg-body pre { border:1px solid var(--border); border-radius:10px; background:var(--bg-panel); padding:10px; overflow-x:auto; line-height:1.5 }
.reply .msg-body pre code { background:none; padding:0; white-space:pre; overflow-wrap:normal }
.tile.user::before { content:""; width:16px; height:16px; background:var(--bg);
  mask:url('/design/person.svg') center / contain no-repeat }

/* Jedno společné rozložení drží obsah i editor nad spodní hranou telefonu. */
main, main:has(#access-note:not([hidden])):has(#compose:not([hidden])) {
  height:var(--phone-height,100dvh);
  grid-template-columns: minmax(0,1fr);
  grid-template-rows: auto auto minmax(0,1fr) auto auto auto;
}
header { grid-row:1 }
#session-views { grid-row:2; justify-self:center; margin:4px 0 }
#content,#startup,#lock,#terminal-panel { grid-row:3; grid-column:1; min-height:0 }
#access-note { grid-row:4 }
#compose { grid-row:5; min-width:0; max-height:45dvh; overflow:auto }
#status { grid-row:6 }
#session-views .segment { justify-content:center; min-height:44px; min-width:86px; padding:0 12px; font-size:12px }
#session-views .segment[aria-pressed=true] { color:var(--fg); background:var(--bg-raised) }
#terminal-panel { display:grid; grid-template-rows:auto minmax(0,1fr); padding:8px 0; gap:6px }
#terminal-status { color:var(--fg-muted); font-size:12px }
#terminal-output { margin:0; overflow:auto; overscroll-behavior:contain; tab-size:4; color:var(--fg-reading);
  font:13px/1.5 var(--font-mono); white-space:pre; background:var(--term-tint); border-radius:8px; padding:8px }
#draft { box-sizing:border-box; min-width:0; padding:10px 6px; line-height:24px; overflow-y:auto }
#source-preview:empty { display:none }
#agent-form { min-height:0 }
#agent-form > * { flex-shrink:0 }
dialog { max-height:var(--phone-height,100dvh); box-sizing:border-box; overscroll-behavior:contain; overflow-y:auto }
.rail-head h2 { min-width:0; overflow-wrap:anywhere }
:where(.rail-head, footer) > button { flex-shrink:0 }
#filter, #file-editor, .repo-panel, #project-list { min-width:0 }
#lock,#startup { overflow:auto; padding:8px }
@media (prefers-reduced-motion:no-preference) {
  #session-views button,.chip,#send,#compose { transition:background-color .16s,color .16s,border-color .16s }
  #terminal-panel:not([hidden]) { animation:mobile-view-in .22s cubic-bezier(.2,.8,.2,1) }
  @keyframes mobile-view-in { from {opacity:0;transform:translateY(4px)} to {opacity:1;transform:none} }
  dialog { --panel-offset:translateX(20px); opacity:0; transform:var(--panel-offset);
    transition:opacity .22s,transform .26s cubic-bezier(.2,.8,.2,1),display .26s allow-discrete,overlay .26s allow-discrete }
  #options { --panel-offset:translateY(18px) }
  dialog[open] { opacity:1; transform:none }
  dialog::backdrop { opacity:0; transition:opacity .22s,display .26s allow-discrete,overlay .26s allow-discrete }
  dialog[open]::backdrop { opacity:1 }
  @starting-style {
    dialog[open] { opacity:0; transform:var(--panel-offset) }
    dialog[open]::backdrop { opacity:0 }
  }
}
#draft:focus-visible { outline:none }
