:root { color-scheme: dark; font-family: Inter, ui-rounded, system-ui, -apple-system, sans-serif; background: #08111f; color: #f3f7ff; }
* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; min-height: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; min-height: -webkit-fill-available; background: radial-gradient(circle at 20% 0, #173563 0, #08111f 42%); }
button, textarea, input { font: inherit; }
button { min-height: 44px; border: 0; border-radius: 14px; padding: 10px 16px; background: #6bd4ff; color: #07111c; font-weight: 750; cursor: pointer; }
button:disabled { opacity: .5; }
.shell { width: 100%; max-width: 900px; height: 100vh; min-height: -webkit-fill-available; margin: auto; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; padding: 22px; gap: 16px; overflow: hidden; }
header { display: flex; align-items: center; gap: 14px; padding: 10px 4px; }
header > div:nth-child(2) { min-width: 0; }
header h1 { margin: 0; font-size: 1.55rem; }
header p { margin: 3px 0 0; color: #a8bad3; }
.avatar { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 17px; background: linear-gradient(145deg, #f7b2ff, #8a7dff); color: #07111c; font-size: 1.5rem; font-weight: 900; box-shadow: 0 10px 30px #07111c88; }
.quiet { color: #d9e8ff; background: #ffffff12; border: 1px solid #ffffff24; }
.header-actions { margin-left: auto; display: flex; }
.header-actions[hidden] { display: none !important; }
.header-actions button + button { margin-left: 8px; }
.messages { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px; background: #07101bbd; border: 1px solid #ffffff16; border-radius: 25px; box-shadow: 0 24px 70px #0005; }
.message { display: table; width: auto; max-width: 78%; margin: 0 0 14px; padding: 13px 16px; border-radius: 18px; line-height: 1.45; white-space: pre-wrap; }
.nico, .athena { background: #30245a; border-bottom-left-radius: 5px; }
.roman, .isla { margin-left: auto; background: #bfa8ff; color: #07111c; border-bottom-right-radius: 5px; }
.error { background: #512635; }
.waiting { color: #a8bad3; }
.composer { min-width: 0; display: flex; align-items: end; padding: 8px; background: #ffffff0d; border: 1px solid #ffffff1c; border-radius: 20px; }
.composer textarea { margin-right: 8px; }
textarea, input { width: 100%; min-width: 0; resize: none; border: 0; outline: 0; padding: 12px; border-radius: 12px; background: transparent; color: #fff; }
.app-footer { display: flex; justify-content: center; }
.memory-nav { width: 100%; max-width: 260px; color: #f5efff; background: #6f55b8; box-shadow: 0 8px 24px #0004; }
.modal-panel[hidden] { display: none !important; }
.modal-panel.modal-open { display: block; position: fixed; top: 50%; right: auto; bottom: auto; left: 50%; z-index: 20; width: calc(100% - 30px); max-width: 620px; max-height: calc(100% - 24px); overflow-y: auto; transform: translate(-50%, -50%); margin: 0; border: 1px solid #ffffff24; border-radius: 24px; padding: 24px; background: #101d2e; color: #f3f7ff; box-shadow: 0 0 0 100vmax #02060ddd, 0 30px 100px #000b; }
.dialog-head { display: flex; align-items: center; }
.dialog-head h2 { margin: 0; }
.remember-form { display: flex; background: #ffffff0c; border: 1px solid #ffffff1c; padding: 6px; border-radius: 16px; }
.remember-form input { flex: 1 1 auto; min-width: 0; }
.remember-form input { margin-right: 8px; }
.remember-form button { flex: 0 0 auto; }
#memoryList { min-height: 80px; padding-left: 25px; color: #c9d8ec; }
.danger { color: #ffd7df; background: #5b2430; }
.instructions { padding-left: 24px; line-height: 1.7; }
.setup-details { padding: 12px 16px; border-radius: 16px; background: #07101b; }
.setup-details code { display: inline-block; margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: #ffffff12; font-size: 1.1rem; letter-spacing: .05em; user-select: all; }
.pair-error { min-height: 1.4em; color: #ffafbe; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@media (max-width: 620px) {
  .shell { padding: 10px; gap: 10px; }
  header { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px 10px; padding: 2px; }
  .avatar { width: 44px; height: 44px; border-radius: 14px; font-size: 1.3rem; }
  header h1 { font-size: 1.35rem; line-height: 1.1; }
  header p { margin-top: 2px; font-size: .72rem; line-height: 1.25; }
  .header-actions { grid-column: auto; width: auto; margin: 0; }
  .header-actions button { padding: 8px 12px; }
  .messages { padding: 14px; border-radius: 20px; }
  .message { max-width: 94%; margin-bottom: 10px; padding: 11px 13px; font-size: .94rem; }
  .composer button { padding-left: 14px; padding-right: 14px; }
  .memory-nav { width: 100%; }
  .modal-panel.modal-open { width: calc(100% - 20px); max-height: calc(100% - 20px); padding: 18px; border-radius: 20px; }
  .modal-panel h2 { font-size: 1.35rem; }
  .remember-form { padding: 5px; }
  .remember-form button { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 340px) {
  .shell { padding: 8px; gap: 8px; }
  .messages { padding: 12px; }
  .composer { border-radius: 16px; }
  .modal-panel.modal-open { width: calc(100% - 16px); padding: 16px; }
}

@media (display-mode: standalone) {
  .header-actions { display: none !important; }
}
