:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #12141b;
  color: #f3f4f8;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #23283a 0, #12141b 42%); }
button, input, select, textarea { font: inherit; }
.shell { width: min(100%, 680px); margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0; color: #98a2c8; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 2px 0 0; font-size: clamp(25px, 7vw, 36px); line-height: 1.1; }
h2 { margin: 0 0 14px; font-size: 16px; }
.connection { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid #34394b; border-radius: 999px; background: rgba(20, 22, 31, .8); color: #aeb4c9; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #747b91; }
.connection.online .dot { background: #5bd38b; box-shadow: 0 0 0 3px rgba(91, 211, 139, .13); }
.connection.stale .dot { background: #f0b45b; }
.card { margin: 12px 0; padding: 17px; border: 1px solid #2e3343; border-radius: 14px; background: rgba(26, 29, 40, .94); box-shadow: 0 12px 35px rgba(0, 0, 0, .18); }
.status-card p { margin: 0; color: #aeb4c9; font-size: 13px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head h2 { margin: 0; }
label { display: block; margin: 14px 0 6px; color: #c5c9d8; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #3a4053; border-radius: 10px; background: #141721; color: #f4f5fa; padding: 11px 12px; outline: none; }
textarea { resize: vertical; min-height: 140px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: #7988d9; box-shadow: 0 0 0 3px rgba(121, 136, 217, .14); }
.composer-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
#count { color: #7f879e; font-size: 11px; }
button { border: 0; border-radius: 9px; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.primary { min-height: 44px; padding: 0 18px; background: #7181dc; color: white; font-weight: 700; }
.primary:not(:disabled):active { transform: translateY(1px); }
.quiet { padding: 6px 9px; background: transparent; color: #9ea7c9; }
.message { min-height: 20px; margin: 10px 0 0; color: #aeb4c9; font-size: 12px; }
.message.error { color: #ff9e9e; }
.recent { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 9px; }
.recent li { padding: 11px; border: 1px solid #303547; border-radius: 10px; background: #171a24; }
.recent-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.recent-state { color: #9aa4c9; text-transform: capitalize; }
.recent-prompt { margin-top: 6px; color: #daddE7; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.recent-result { margin-top: 8px; padding-top: 8px; border-top: 1px solid #2d3242; color: #b9bfd4; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow-y: auto; }
.empty-recent { margin: 14px 0 0; color: #747c93; font-size: 12px; }
.history-status { margin: 0 0 8px; color: #7f879e; font-size: 11px; }
.history { max-height: 58vh; margin: 0; padding: 4px; overflow: auto; display: grid; gap: 10px; }
.history-empty { margin: 10px; color: #747c93; font-size: 12px; }
.history-message { width: min(90%, 560px); padding: 11px 12px; border: 1px solid #303547; border-radius: 14px; background: #171a24; box-shadow: 0 5px 14px rgba(0, 0, 0, .12); }
.history-user { justify-self: end; background: #29345c; border-color: #46558f; }
.history-assistant { justify-self: start; background: #202735; }
.history-system { justify-self: start; background: #24242d; border-color: #47485a; }
.history-message-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: #dfe4f8; font-size: 12px; }
.history-message-head time { color: #8f98b3; font-size: 10px; }
.history-message-body { color: #eef0f8; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: 13px; }
.history-attachments, .recent-attachments, .selected-attachments { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.attachment-card { position: relative; display: flex; align-items: center; gap: 7px; min-width: 0; padding: 6px 8px; border: 1px solid #3a4053; border-radius: 9px; background: #141721; color: #cdd3e8; font-size: 11px; }
.attachment-card img { width: 58px; height: 58px; object-fit: cover; border-radius: 6px; }
.attachment-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { padding: 4px 6px; background: #353b50; color: #e5e8f5; font-size: 10px; }
.selected-attachments { min-height: 4px; }
input[type="file"] { padding: 8px; color: #aeb4c9; }

@media (min-width: 620px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .card { padding: 21px; }
}
