* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: #f6f7f9;
  color: #17181c;
}
.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f6f7f9;
  box-shadow: 0 0 28px rgba(0,0,0,.05);
  position: relative;
  overflow: hidden;
}
.gone { display: none !important; }
.hidden { display: none !important; }

/* ============ 顶部栏 ============ */
.topbar {
  background: #fff;
  border-bottom: 1px solid #eef0f4;
  padding: 10px 12px 8px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.tb-row { display: flex; align-items: center; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: #5b6270; cursor: pointer;
  display: grid; place-items: center; transition: .15s; flex: none;
}
.icon-btn:active { background: #f2f4f8; }
.tb-title {
  flex: 1; text-align: center; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.tb-status {
  font-size: 12px; color: #9aa0ab; display: flex; align-items: center; gap: 5px;
  min-width: 36px; justify-content: flex-end;
}
.tb-status i {
  width: 7px; height: 7px; border-radius: 50%; background: #2bb673; display: inline-block;
}
.seg {
  display: flex; background: #eef0f5; border-radius: 999px; padding: 4px;
  width: fit-content; margin: 10px auto 2px;
}
.tab {
  border: 0; background: transparent; color: #667085; cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 7px 26px; border-radius: 999px; transition: .2s;
}
.tab.active {
  background: #fff; color: #17181c; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

/* ============ 欢迎区 ============ */
.hero { text-align: center; padding: 36px 18px 12px; }
.hero-avatar {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%;
  background: #eef1ff; display: grid; place-items: center;
  font-size: 26px; font-weight: 800;
  background-image: linear-gradient(#eef1ff, #eef1ff);
  color: transparent;
  position: relative;
}
.hero-avatar::before {
  content: "AI";
  background: linear-gradient(135deg, #4f6ef7, #7b5cf0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-avatar { box-shadow: 0 10px 26px rgba(79,110,247,.16); }
.hero-avatar img,
.msg .avatar img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}
.hero h1 { font-size: 20px; margin: 0 0 8px; letter-spacing: .5px; }
.hero p { font-size: 13px; color: #9aa0ab; margin: 0; line-height: 1.7; white-space: pre-line; }

.rec-section { margin-top: 30px; text-align: left; }
.rec-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2px 10px; font-size: 15px; font-weight: 700;
}
.rec-head span { font-size: 12px; color: #b0b6c0; font-weight: 400; }
.cards {
  display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px;
  scrollbar-width: none;
}
.cards::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; width: 150px;
  background: #fff; border: 1px solid #eef0f4; border-radius: 16px;
  padding: 14px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03); transition: .15s;
  font-family: inherit;
}
.chip:active { transform: scale(.97); }
.chip-ic {
  width: 34px; height: 34px; border-radius: 10px; background: #f2f4ff;
  display: grid; place-items: center; font-size: 17px;
}
.chip-t { font-size: 14px; font-weight: 600; color: #1f2330; }
.chip-s { font-size: 11px; color: #a0a6b1; }

/* ============ 消息区 ============ */
.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 8px; max-width: 100%; align-items: flex-end; }
.msg .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff;
}
.msg.ai .avatar { background: linear-gradient(135deg, #4f6ef7, #7b5cf0); }
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: #2bb673; }
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px; line-height: 1.6;
  font-size: 15px; word-break: break-word; white-space: pre-wrap;
}
.msg.ai .bubble {
  background: #fff; color: #1f2330; border-bottom-left-radius: 6px;
  border: 1px solid #eef0f4;
}
.msg.user .bubble {
  background: linear-gradient(135deg, #4f6ef7, #6a5cf0); color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble .hl { color: #4f6ef7; font-weight: 700; }
.msg.user .bubble .hl { color: #fff; }
.bubble img { max-width: 100%; border-radius: 10px; display: block; margin-top: 4px; }
.bubble.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 0%,50%{opacity:1} 51%,100%{opacity:0} }

.bubble-tools { margin-top: 6px; display: flex; gap: 8px; }
.speak-btn {
  border: 0; background: #f2f4ff; color: #4f6ef7; cursor: pointer;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
}

/* ============ 输入栏 ============ */
.inputbar { padding: 10px 12px 6px; }
.pill {
  display: flex; align-items: flex-end; gap: 4px;
  background: #fff; border-radius: 26px; padding: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,.06);
  border: 1px solid #eef0f4;
}
#textInput {
  flex: 1; resize: none; border: 0; background: transparent; outline: none;
  font-size: 15px; line-height: 1.45; padding: 8px 4px; max-height: 110px;
  font-family: inherit; color: #17181c;
}
#textInput::placeholder { color: #b0b6c0; }
.pill .icon-btn { width: 38px; height: 38px; }
#micBtn.recording { background: #ff5b5b; color: #fff; transform: scale(1.05); }
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; flex: none;
  background: linear-gradient(135deg, #4f6ef7, #7b5cf0); color: #fff;
  display: grid; place-items: center; cursor: pointer; transition: .15s;
}
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .6; }
.rec-hint {
  display: none; text-align: center; font-size: 13px; color: #ff5b5b;
  padding: 4px 0 10px; font-weight: 600;
}
.rec-hint.show { display: block; }

/* ============ 绘画模式 ============ */
.draw-tip { padding: 16px 16px 4px; color: #8a90a0; font-size: 13px; }
.draw-form {
  margin: 8px 14px; background: #fff; border-radius: 16px; padding: 14px;
  border: 1px solid #eef0f4;
}
#drawInput {
  width: 100%; border: 0; resize: none; outline: none;
  font-size: 15px; line-height: 1.55; font-family: inherit; min-height: 64px; color: #17181c;
}
#drawInput::placeholder { color: #b0b6c0; }
.draw-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.draw-row label { font-size: 13px; color: #667085; display: flex; align-items: center; gap: 6px; }
#drawSize {
  border: 1px solid #e2e6ee; border-radius: 8px; padding: 6px; font-size: 13px; background: #fff;
}
.gen-btn {
  margin-left: auto; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #4f6ef7, #7b5cf0); color: #fff;
  border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 600;
}
.gallery {
  flex: 1; overflow-y: auto; padding: 10px 14px 16px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start;
}
.gallery .card {
  background: #fff; border-radius: 14px; overflow: hidden;
  border: 1px solid #eef0f4;
}
.gallery .card img { width: 100%; display: block; }
.gallery .card .meta { padding: 6px 8px; font-size: 11px; color: #8a90a0; word-break: break-all; }
.gallery .loading {
  grid-column: 1 / -1; text-align: center; color: #a0a6b1; font-size: 13px; padding: 30px 0;
}

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%);
  background: rgba(23,24,28,.82); color: #fff; padding: 9px 16px; border-radius: 10px;
  font-size: 13px; z-index: 99; max-width: 80%; text-align: center;
}
