:root {
  --bg: #f7f8fa;
  --panel: #fff;
  --ink: #1f2329;
  --muted: #8a919f;
  --line: #e5e6eb;
  --accent: #3370ff;
  --accent2: #4e6ef2;
  --user-bg: #3370ff;
  --bot-bg: #fff;
  --side: #0f1115;
  --side-w: 280px;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}
#app { display: flex; height: 100%; }
.sidebar {
  width: var(--side-w);
  background: var(--side);
  color: #e8eaed;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 30;
  transition: transform .22s ease, width .22s ease;
}
.brand {
  padding: 16px 14px 12px;
  display: flex; gap: 8px; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #3370ff, #6d5dfc);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.brand-name { flex: 1; font-weight: 650; font-size: 17px; letter-spacing: -.02em; }
.btn-new {
  border: 0; background: var(--accent); color: #fff;
  border-radius: 10px; height: 34px; padding: 0 12px; cursor: pointer; font-size: 13px;
}
.btn-new:hover { filter: brightness(1.08); }
.user-box { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.btn-auth, .user-chip {
  width: 100%; border: 1px solid rgba(255,255,255,.12); background: transparent;
  color: #e8eaed; border-radius: 10px; height: 38px; cursor: pointer; font-size: 13px;
}
.user-chip { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; }
.sess-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 4px; color: var(--muted); font-size: 12px;
}
.btn-text {
  border: 0; background: transparent; color: #9aa0a6; cursor: pointer; font-size: 12px;
}
.btn-text:hover { color: #fff; }
.sess-list { flex: 1; overflow: auto; padding: 6px 8px 16px; }
.sess-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px; border-radius: 10px; cursor: pointer;
  color: #c9ccd1; font-size: 13px; margin-bottom: 2px;
}
.sess-item:hover { background: rgba(255,255,255,.06); }
.sess-item.active { background: rgba(51,112,255,.22); color: #fff; }
.sess-item .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sess-item .x {
  opacity: 0; border: 0; background: transparent; color: #9aa0a6; cursor: pointer; font-size: 14px;
}
.sess-item:hover .x { opacity: 1; }
.side-foot {
  padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.06);
  display: flex; gap: 12px; font-size: 12px;
}
.side-foot a { color: #9aa0a6; text-decoration: none; }
.side-foot a:hover { color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar {
  height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86);
  backdrop-filter: blur(8px); z-index: 10;
}
.icon-btn {
  display: none; width: 36px; height: 36px; border: 0; background: transparent;
  border-radius: 10px; cursor: pointer; font-size: 18px;
}
.top-title { font-weight: 600; font-size: 15px; flex: 1; }
.top-auth {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  height: 34px; padding: 0 14px; cursor: pointer; font-size: 13px;
}
.top-auth:hover { border-color: var(--accent); color: var(--accent); }

.chat { flex: 1; overflow: auto; padding: 24px 16px 12px; }
.chat-inner { max-width: 820px; margin: 0 auto; }
.welcome { text-align: center; padding: 48px 12px 24px; }
.w-mark {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: linear-gradient(135deg, #3370ff, #6d5dfc);
  display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 12px 30px rgba(51,112,255,.28);
}
.w-brand { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-bottom: 8px; }
.w-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.suggests {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  max-width: 560px; margin: 0 auto;
}
.suggest {
  text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 14px; padding: 12px 14px; cursor: pointer; font-size: 13px; color: var(--ink);
}
.suggest:hover { border-color: #bfd0ff; box-shadow: 0 4px 14px rgba(51,112,255,.08); }

.msg { display: flex; gap: 10px; margin: 0 0 18px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.msg.bot .avatar { background: linear-gradient(135deg, #3370ff, #6d5dfc); }
.msg.user .avatar { background: #111827; }
.bubble {
  max-width: min(100%, 680px); padding: 12px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.msg.bot .bubble {
  background: var(--bot-bg); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.msg.user .bubble { background: var(--user-bg); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot .bubble { border-bottom-left-radius: 6px; }
.meta { margin-top: 6px; font-size: 11px; color: var(--muted); }
.typing {
  display: inline-flex; gap: 4px; align-items: center; height: 18px;
}
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #9aa0a6;
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.composer-wrap {
  position: relative;
  padding: 8px 12px 5px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 35%);
}
.composer {
  max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-radius: 24px; padding: 8px 10px 8px 8px; display: flex; gap: 6px; align-items: flex-end;
  box-shadow: 0 6px 20px rgba(15,17,21,.05);
}
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; max-height: 160px;
  font: inherit; font-size: 15px; line-height: 1.5; padding: 8px 0; background: transparent;
}
#send {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; cursor: pointer; font-size: 18px; flex-shrink: 0;
}
#send:disabled { opacity: .45; cursor: not-allowed; }
.tip {
  max-width: 820px; margin: 2px auto 0; text-align: center;
  font-size: 11px; color: var(--muted); line-height: 1.2;
  position: static;
}
.mask {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25;
}
.mask.show { display: block; }
body.busy #send { opacity: .45; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-105%);
    width: min(86vw, 300px); box-shadow: 8px 0 30px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: inline-grid; place-items: center; }
  .suggests { grid-template-columns: 1fr; }
}

/* Five-bar clearance: ONE mechanism only (was double: #app−50 + body pad → ~50px extra gap).
   Kill dmk-tabbar.css body padding; reserve space via #app height on mobile only. */
body { padding-bottom: 0 !important; }
.dmk-five-bar { z-index: 1000; }

/* Desktop/PC: hide five-bar entirely */
@media (min-width: 861px) {
  .dmk-five-bar { display: none !important; }
  #app { height: 100%; }
  .composer-wrap { padding-bottom: 16px; }
  .voice-overlay { bottom: 24px; }
}

/* Mobile: keep five-bar; composer-wrap padding-bottom 5px = tip→tabbar gap */
@media (max-width: 860px) {
  #app {
    height: calc(100% - 50px - env(safe-area-inset-bottom, 0px));
    height: calc(100% - 50px - constant(safe-area-inset-bottom));
  }
}
.icon-tool {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: transparent; color: #6b7280; cursor: pointer;
  font-size: 18px; flex-shrink: 0; line-height: 1;
}
.icon-tool:hover { background: #f3f4f6; color: var(--ink); }
.icon-tool.active { color: var(--accent); background: #eef3ff; }
.icon-tool:disabled { opacity: .4; cursor: not-allowed; }
.hidden { display: none !important; }
.top-oa {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--accent); color: #fff !important; text-decoration: none;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.top-oa:hover { filter: brightness(1.06); color: #fff !important; }
.top-auth {
  margin-right: 0;
}

#btnFile {
  font-size: 26px; font-weight: 300; line-height: 1; padding: 0;
}
.hold-talk {
  flex: 1; min-height: 40px; border: 0; border-radius: 12px;
  background: #f3f4f6; color: var(--ink); cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 500;
  -webkit-user-select: none; user-select: none;
  touch-action: none; -webkit-touch-callout: none;
}
.hold-talk:active, .hold-talk.holding {
  background: var(--accent); color: #fff;
}
.hold-talk.canceling {
  background: #ef4444; color: #fff;
}
.voice-overlay {
  display: none; position: fixed; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); z-index: 1100;
  background: rgba(15,17,21,.88); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 13px; white-space: nowrap;
  pointer-events: none;
}
.voice-overlay.show { display: block; }
