* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #141414;
  color: #e6e6e6;
  overflow: hidden;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.screen {
  height: 100%;
  height: var(--vvh, 100%);
  width: 100%;
}

.card {
  width: calc(100% - 32px);
  max-width: 360px;
  margin: 16vh auto 0;
  padding: 24px;
  background: #1c1c1c;
  border-radius: 12px;
}
.card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.card p { color: #888; font-size: 13px; }
.card input, .card button {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border-radius: 8px;
  border: 0;
  font-size: 16px;
}
.card input { background: #2a2a2a; color: #eee; }
.card button, .btn-new, #form button[type="submit"] { background: #3b82f6; color: #fff; cursor: pointer; }
.err { color: #f87171; margin-top: 8px; min-height: 1.2em; font-size: 13px; }

#app {
  display: flex;
  height: 100%;
  height: var(--vvh, 100%);
  width: 100%;
  overflow: hidden;
}
.drawer-mask {
  display: none;
}
aside {
  width: 260px;
  background: #181818;
  display: flex;
  flex-direction: column;
  padding: 10px 8px 0;
  flex-shrink: 0;
}
.btn-new {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
}
.ws-box { margin: 8px 0; }
#workspace {
  width: 100%;
  background: #242424;
  color: #ddd;
  border: 0;
  border-radius: 8px;
  padding: 11px 10px;
  font-size: 16px;
}
.thread-list { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 8px; }
.item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: #c8c8c8;
  font-size: 15px;
}
.item:hover, .item.active { background: #2a2a2a; color: #fff; }
.ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.7;
}
.item-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-tag {
  font-size: 10px;
  line-height: 1.3;
  padding: 1px 5px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.item-tag.pc { color: #93c5fd; background: #1e3a5f; }
.item-tag.web { color: #86efac; background: #14532d; }
.item-x {
  display: none;
  color: #888;
  font-size: 16px;
  padding: 0 6px;
}
.item.active .item-x, .item:hover .item-x { display: inline; }
.aside-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #222;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.who { font-size: 13px; }
.plan { color: #777; font-size: 11px; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #141414;
  position: relative;
}
header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}
#menuBtn, .head-plus {
  display: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #242424;
  color: #eee;
  font-size: 20px;
  flex: 0 0 40px;
}
.head-text { flex: 1; min-width: 0; }
#title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#wsHint {
  color: #777;
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.empty {
  margin: auto;
  color: #555;
  font-size: 14px;
  text-align: center;
  padding: 24px;
}
.bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 15px;
}
.user { align-self: flex-end; background: #2563eb; }
.assistant { align-self: flex-start; background: #242424; }
.status {
  color: #8a8a8a;
  font-size: 12px;
  margin-bottom: 6px;
}
.status.spin::after {
  content: "…";
}
.shot {
  display: block;
  max-width: min(240px, 70vw);
  max-height: 240px;
  margin-top: 8px;
  border-radius: 8px;
  object-fit: contain;
  background: #111;
}
.jump {
  position: absolute;
  right: 16px;
  bottom: 92px;
  z-index: 5;
  border: 0;
  border-radius: 18px;
  padding: 8px 14px;
  background: #2f2f2f;
  color: #eee;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.previews {
  display: flex;
  gap: 8px;
  padding: 0 12px 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.previews:empty { display: none; }
.pv {
  position: relative;
  width: 64px;
  height: 64px;
}
.pv img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
}
.pv button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #444;
  color: #fff;
  font-size: 14px;
  padding: 0;
}
#form {
  display: flex;
  gap: 8px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  align-items: flex-end;
  flex-shrink: 0;
  background: #141414;
  border-top: 1px solid #222;
}
#pickImg {
  border: 0;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: #2a2a2a;
  color: #ddd;
  flex: 0 0 44px;
  font-size: 14px;
}
#input {
  flex: 1;
  resize: none;
  border-radius: 12px;
  border: 0;
  padding: 11px 12px;
  background: #1c1c1c;
  color: #eee;
  font-size: 16px;
  line-height: 1.4;
  min-height: 44px;
  max-height: 120px;
}
#form button[type="submit"] {
  border: 0;
  border-radius: 12px;
  height: 44px;
  padding: 0 16px;
  flex: 0 0 auto;
  font-size: 15px;
}

@media (max-width: 860px) {
  #menuBtn, .head-plus { display: inline-flex; align-items: center; justify-content: center; }
  .drawer-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .drawer-open .drawer-mask {
    opacity: 1;
    pointer-events: auto;
  }
  aside {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(82vw, 320px);
    z-index: 21;
    transform: translateX(-105%);
    transition: transform .22s ease;
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .drawer-open aside { transform: translateX(0); }
  .jump { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .bubble { max-width: 88%; font-size: 16px; }
  #form {
    padding-bottom: var(--form-bottom, max(10px, env(safe-area-inset-bottom)));
  }
}
