body.app-page { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
body.app-page .site-foot { padding: 10px 16px 12px; flex-shrink: 0; margin-top: 0; }
body.app-page .top { position: relative; flex-shrink: 0; }
.app {
  flex: 1; min-height: 0; display: flex; gap: 12px;
  padding: 12px 16px 8px; background: transparent;
}
.sidebar {
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden;
}
.side-bar { display: flex; gap: 8px; padding: 14px 12px 10px; }
.side-bar button, .side-bar a {
  flex: 1; text-align: center; background: rgba(174, 182, 195, 0.08);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 0;
  color: var(--muted); font-weight: 600; font-size: 13px;
}
.side-bar button:hover, .side-bar a:hover { color: var(--text); border-color: rgba(26, 115, 232, 0.4); }
.sessions { flex: 1; overflow: auto; padding: 4px 10px 12px; scrollbar-gutter: stable; overscroll-behavior: contain; }
.chat-item {
  position: relative;
  background: rgba(174, 182, 195, 0.05); border: 1px solid transparent;
  border-radius: 12px; padding: 12px 34px 12px 12px; margin-bottom: 8px; cursor: pointer;
}
.chat-item:hover { background: rgba(26, 115, 232, 0.08); }
.chat-item.on {
  border-color: rgba(26, 115, 232, 0.45);
  background: rgba(26, 115, 232, 0.14);
}
.chat-item .t {
  color: var(--text); font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px;
}
.chat-item .m { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.chat-item-x {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; padding: 0; border: 0;
  border-radius: 999px; background: rgba(174, 182, 195, 0.12);
  color: var(--muted); font-size: 14px; line-height: 1; font-weight: 600;
}
.chat-item-x:hover { background: rgba(248, 113, 113, 0.18); color: var(--danger); }
.side-tail { padding: 8px 12px 14px; }
.new-chat {
  width: 100%; border: 0; border-radius: 999px; height: 42px; font-weight: 600;
  background: linear-gradient(90deg, var(--secondary-purple), var(--primary-blue)); color: #fff;
}
.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.titles { flex: 1; min-width: 0; }
.titles h2 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.chat-head select {
  max-width: 220px; border-radius: 999px; padding: 6px 12px;
  background: var(--bg2); border: 1px solid var(--line);
}
.icon-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(174, 182, 195, 0.08); color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: rgba(26, 115, 232, 0.4); }
.messages { flex: 1; overflow: auto; padding: 16px 12px 22px; scrollbar-gutter: stable; overscroll-behavior: contain; }
.messages .empty {
  margin: 18vh auto 0; text-align: center; color: var(--muted); font-size: 15px;
}
.msg {
  display: flex; gap: 10px; margin: 14px 0; max-width: 82%;
  align-items: flex-start;
}
.msg.assistant { margin-right: auto; margin-left: 0; }
.msg.user { margin-left: auto; margin-right: 0; flex-direction: row-reverse; }
.msg .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--secondary-purple), var(--primary-blue));
}
.msg.user .avatar {
  background: rgba(26, 115, 232, 0.22); color: var(--text);
}
.msg-body { min-width: 0; }
.msg.user .msg-body { text-align: right; }
.bubble {
  display: inline-block; max-width: 100%; text-align: left;
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px; line-height: 1.65; color: var(--text);
  user-select: text; overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: linear-gradient(90deg, var(--secondary-purple), var(--primary-blue));
  color: #fff; border: 0; border-radius: 16px 16px 4px 16px;
}
.msg.user .bubble a { color: #fff; }
.meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 12px; margin-bottom: 6px; color: var(--muted);
}
.msg.user .meta { justify-content: flex-end; }
.meta .who { color: var(--text); font-weight: 600; }
.actions { display: flex; gap: 6px; margin-top: 8px; opacity: 0; }
.msg:hover .actions { opacity: 1; }
.msg.user .actions { justify-content: flex-end; }
.actions button { border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.md p { margin: 0 0 .6em; }
.md p:last-child { margin: 0; }
.md pre {
  background: var(--code-bg); border-radius: 8px; padding: 10px 12px;
  overflow: auto; font-size: 12.5px; line-height: 1.5;
}
.msg.user .md pre { background: rgba(0, 0, 0, 0.22); }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.md :not(pre) > code { background: var(--code-bg); border-radius: 4px; padding: 0 4px; }
.msg.user .md :not(pre) > code { background: rgba(0, 0, 0, 0.22); }
.cursor { display: inline-block; width: 8px; height: 14px; background: var(--primary-blue); margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer { padding: 8px 16px 16px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
  padding: 6px 6px 6px 16px;
}
.composer-box:focus-within { border-color: var(--primary-blue); }
.composer textarea {
  display: block; flex: 1; min-width: 0; min-height: 36px; max-height: 180px;
  resize: none; border: 0; border-radius: 0; outline: none;
  background: transparent; color: var(--text);
  padding: 6px 0; line-height: 24px; font-size: 14px;
}
.composer textarea:focus { border-color: transparent; }
.send {
  flex-shrink: 0; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(90deg, var(--secondary-purple), var(--primary-blue)); color: #fff;
  line-height: 0;
}
.send svg { display: block; }
.send:disabled { opacity: .45; }
.overlay {
  position: fixed; inset: 0; background: rgb(0 0 0 / 45%);
  display: none; place-items: center; z-index: 30;
}
.overlay.open { display: grid; }
.sheet {
  width: min(720px, 92vw); max-height: 80vh; overflow: auto;
  background: var(--card); border-radius: 18px; padding: 18px 20px 24px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.sheet header { display: flex; align-items: center; }
.sheet h3 { margin: 0; flex: 1; }
.hint { font-size: 13px; }
.mask-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.mask {
  text-align: left; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.mask:hover { border-color: var(--primary-blue); }
.mask b { display: block; color: var(--text); margin-bottom: 6px; }
.mask span { font-size: 12px; }
.mobile { display: none; }
@media (max-width: 720px) {
  .app { padding: 8px; gap: 0; }
  .sidebar {
    position: fixed; inset: 72px 12px 12px 12px; z-index: 15; width: auto;
    transform: translateX(-110%); transition: transform .2s;
  }
  .sidebar.open { transform: none; }
  .mobile { display: grid; }
  .messages { padding: 12px 8px 16px; }
  .msg { max-width: 94%; }
}
