main.container { max-width: 760px; padding-top: 1rem; padding-bottom: 2rem; }
.top { margin-bottom: 1rem; }
.muted { color: var(--pico-muted-color); }
.error { color: var(--pico-del-color); }
.copy-row { display: flex; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.copy-row input { margin: 0; }
.copy-row button { width: auto; margin: 0; white-space: nowrap; flex-shrink: 0; }
#mylink { margin-bottom: 1rem; }
.hint { padding: .75rem 1rem; border-left: 4px solid var(--pico-primary); margin-bottom: 1rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.row button { width: auto; margin-bottom: 0; }
#messages { display: flex; flex-direction: column; gap: .75rem; padding-bottom: 1rem; }
.msg { padding: .6rem .9rem; border-radius: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 88%; }
.msg.assistant { background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color); align-self: flex-start; }
.msg.user { background: var(--pico-primary-background); color: var(--pico-primary-inverse); align-self: flex-end; }
.msg.pending::after { content: "…"; opacity: .6; }
.session-actions { margin-bottom: 1rem; }
.session-actions button { padding: .35rem .75rem; font-size: .875rem; }
#composer {
  background: var(--pico-background-color);
  padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom));
  margin-bottom: 0;
  border-top: 1px solid var(--pico-muted-border-color);
}

/* Chat screen = an app shell: exactly one screen tall, the page itself never scrolls, only the
   message list does, and the composer is the last row of the shell, so it is always flush with the
   bottom edge. --app-h follows the visual viewport (it shrinks when a phone keyboard opens). */
body.chat-mode { height: var(--app-h, 100dvh); overflow: hidden; }
body.chat-mode main.container {
  height: var(--app-h, 100dvh); display: flex; flex-direction: column;
  padding-top: .75rem; padding-bottom: 0;
}
body.chat-mode main.container > * { flex: none; }
body.chat-mode .top { margin-bottom: .5rem; }
body.chat-mode #mylink { margin-bottom: .5rem; max-height: 40%; overflow-y: auto; }
body.chat-mode #chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0; }
body.chat-mode #chat > .session-actions { flex: none; margin-bottom: .5rem; }
body.chat-mode #messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
body.chat-mode #composer { flex: none; }
.composer-row { display: flex; gap: .5rem; align-items: flex-end; }
.composer-row textarea { flex: 1; margin: 0; font-size: 16px; /* 16px stops iOS zooming on focus */ resize: none; max-height: 40vh; }
.composer-row button { width: auto; margin: 0; }
#composer .error { margin: 0 0 .5rem; }
.close-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .5rem .75rem; margin-bottom: .5rem; border-radius: .5rem; background: var(--pico-card-sectioning-background-color);
  border: 1px solid var(--pico-primary); }
.close-bar button { width: auto; margin: 0; padding: .4rem .9rem; white-space: nowrap; }
#hint { display: block; margin-top: .25rem; }
@media (pointer: coarse) { #hint { display: none; } }
#history { margin-top: 1.5rem; }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  padding: .5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); list-style: none; }
.history-list li button { width: auto; margin: 0; padding: .3rem .7rem; font-size: .85rem; white-space: nowrap; }
.history-list .actions { display: flex; gap: .4rem; }
.view-messages { display: flex; flex-direction: column; gap: .75rem; max-height: 60vh; overflow-y: auto; }
.hard-btn { align-self: flex-start; width: auto; margin: -.4rem 0 0; padding: .1rem .5rem; font-size: .8rem; border: none; background: none; color: var(--pico-muted-color); text-decoration: underline; }
.hard-btn[disabled] { text-decoration: none; opacity: .8; }
.hard-text { white-space: pre-wrap; max-height: 40vh; overflow-y: auto; margin: 0 0 1rem; }
.ratings { padding: .75rem 1rem; }
.scale-q { margin-bottom: .75rem; }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: .25rem; }
.scale label { margin: 0; display: block; width: 100%; position: relative; }
.scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale span { display: block; width: 100%; box-sizing: border-box; text-align: center; padding: .4rem 0; border: 1px solid var(--pico-muted-border-color); border-radius: .4rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.scale input:checked + span { background: var(--pico-primary-background); color: var(--pico-primary-inverse); border-color: var(--pico-primary-background); }
.scale input:focus-visible + span { outline: 2px solid var(--pico-primary); outline-offset: 2px; }
.scale-ends { display: flex; justify-content: space-between; font-size: .8rem; margin-top: .2rem; }
