:root {
  color-scheme:light;
  --text:#162033;
  --muted:#65758b;
  --primary:#1d6fd8;
  --line:#e2e8f0;
  --soft:#f5f7fb;
  --red:#b42332;
  --radius:10px;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
  font-size:14px;
  color:var(--text);
  background:#fff
}
* {
  box-sizing:border-box
}
body {
  margin:0
}
button,input,select,textarea {
  font:inherit;
  color:inherit
}
button,a,summary {
  touch-action:manipulation
}
button,summary {
  cursor:pointer
}
a {
  color:var(--primary);
  text-decoration:none
}
a:hover {
  text-decoration:underline
}
[hidden] {
  display:none!important
}
:focus-visible {
  outline:3px solid #91bcf1;
  outline-offset:3px
}
.btn {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  border:1px solid var(--line);
  border-radius:8px;
  min-height:38px;
  padding:8px 13px;
  background:white;
  text-decoration:none;
  white-space:nowrap
}
.btn:hover {
  background:var(--soft);
  text-decoration:none
}
.btn.primary {
  background:var(--primary);
  color:white;
  border-color:var(--primary)
}
.btn.danger {
  color:var(--red)
}
button:disabled {
  opacity:.5;
  cursor:not-allowed
}
.icon-btn {
  border:0;
  background:transparent;
  border-radius:6px;
  padding:8px;
  min-height:36px
}
.icon-btn:hover {
  background:#eaf0f8
}
.muted {
  color:var(--muted)
}
.gate {
  min-height:100dvh;
  display:grid;
  place-items:center;
  background:var(--soft);
  padding:24px
}
.gate-box {
  width:min(400px,100%);
  padding:32px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:16px
}
.gate-brand strong {
  font-size:23px;
  display:block;
  margin:22px 0 8px
}
.gate-brand span {
  color:var(--muted);
  line-height:1.6
}
.field {
  margin-top:20px
}
.field label {
  display:block;
  margin-bottom:8px
}
.field input {
  width:100%;
  padding:11px 12px;
  border:1px solid #cbd5e1;
  border-radius:8px
}
.field.has-error input {
  border-color:var(--red)
}
.gate-actions {
  margin-top:24px
}
.gate-actions .btn {
  width:100%
}
.gate-msg {
  color:var(--red);
  line-height:1.6
}
.gate-msg:not(:empty) {
  border:1px solid #efb9be;
  background:#fff4f5;
  padding:12px;
  border-radius:8px;
  margin-top:20px
}
.gate-foot {
  display:flex;
  justify-content:space-between;
  margin-top:22px;
  font-size:13px
}
.workspace {
  height:100dvh;
  display:grid;
  grid-template-columns:258px minmax(0,1fr);
  overflow:hidden
}
.rail {
  padding:20px 14px 12px;
  background:var(--soft);
  border-right:1px solid var(--line);
  display:flex;
  flex-direction:column;
  gap:14px;
  min-height:0
}
.brand {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 4px
}
.brand a {
  font-weight:650;
  color:var(--text)
}
.search-label {
  font-size:12px;
  color:var(--muted)
}
#historySearch {
  width:100%;
  border:1px solid var(--line);
  border-radius:8px;
  background:white;
  padding:10px 12px;
  margin-top:6px
}
.conversation-list {
  flex:1;
  min-height:0;
  overflow:auto
}
.history-heading {
  color:var(--muted);
  font-size:11px;
  letter-spacing:.04em;
  padding:16px 9px 8px
}
.conversation-row {
  display:flex;
  align-items:center;
  border-radius:8px;
  margin:3px 0
}
.conversation-row.active {
  background:#e6edf8
}
.conversation-item {
  flex:1;
  min-width:0;
  border:0;
  background:transparent;
  text-align:left;
  padding:11px 10px;
  border-radius:8px
}
.conversation-title {
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap
}
.history-menu {
  position:relative
}
.history-menu summary {
  list-style:none;
  padding:10px
}
.history-menu summary::-webkit-details-marker {
  display:none
}
.history-menu[open] {
  z-index:3
}
.menu-panel {
  position:absolute;
  right:0;
  top:36px;
  width:154px;
  padding:5px;
  background:white;
  border:1px solid var(--line);
  box-shadow:0 8px 28px #182b4920;
  border-radius:8px
}
.menu-panel button {
  display:block;
  text-align:left;
  width:100%;
  border:0;
  background:white;
  padding:10px;
  border-radius:5px
}
.menu-panel button:hover {
  background:var(--soft)
}
.conversation-empty {
  padding:18px 10px;
  color:var(--muted);
  line-height:1.7
}
.rail-foot {
  border-top:1px solid var(--line);
  padding-top:12px
}
.rail-links {
  display:flex;
  align-items:center;
  justify-content:space-between
}
.account-name {
  display:block;
  font-size:12px;
  color:var(--muted);
  padding:10px 5px 0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap
}
.main {
  min-width:0;
  min-height:0;
  display:grid;
  grid-template-rows:auto auto minmax(0,1fr) auto
}
.topbar {
  grid-row:1;
  min-height:82px;
  border-bottom:1px solid var(--line);
  padding:14px 28px;
  display:flex;
  gap:16px;
  align-items:center
}
.model-control {
  min-width:0
}
.model-control select {
  font-size:16px;
  font-weight:600;
  width:min(330px,100%);
  border:0;
  background:#fff;
  padding:3px 26px 3px 0
}
.model-control p {
  color:var(--muted);
  font-size:12px;
  margin:5px 0 0
}
.model-price {
  margin-left:auto;
  font-size:12px;
  color:var(--muted);
  position:relative
}
.model-price p {
  position:absolute;
  right:0;
  width:220px;
  background:#fff;
  border:1px solid var(--line);
  padding:12px;
  line-height:1.7;
  z-index:2;
  border-radius:8px
}
.notice {
  grid-row:2;
  padding:10px 26px;
  background:#f1f6fd;
  color:#365f8b;
  line-height:1.6
}
.notice.err {
  background:#fff1f2;
  color:var(--red)
}
.notice button {
  margin-left:10px
}
.messages {
  grid-row:3;
  overflow:auto;
  min-height:0;
  padding:30px max(24px,calc((100% - 860px)/2)) 24px
}
.empty {
  height:100%;
  min-height:180px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  color:var(--muted);
  line-height:1.7
}
.empty h1 {
  font-size:29px;
  line-height:1.4;
  font-weight:600;
  color:var(--text);
  margin:0 0 12px
}
.empty p {
  margin:0;
  max-width:330px
}
.message {
  margin:0 0 28px;
  min-width:0
}
.message.user {
  display:flex;
  justify-content:flex-end
}
.message.user .bubble {
  background:#eff3f8;
  border-radius:16px 16px 3px 16px;
  padding:12px 17px;
  max-width:85%;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  line-height:1.75
}
.message.assistant .bubble {
  line-height:1.9;
  overflow-wrap:anywhere
}
.message.error .bubble {
  border-left:3px solid var(--red);
  background:#fff5f6;
  border-radius:0 8px 8px 0;
  padding:12px 16px;
  color:#972332;
  line-height:1.7
}
.message.error p {
  margin:3px 0 10px
}
.answer-label {
  font-size:12px;
  color:var(--muted);
  margin-bottom:7px
}
.answer-actions {
  display:flex;
  gap:16px;
  align-items:flex-start;
  color:var(--muted);
  font-size:12px;
  margin-top:12px;
  flex-wrap:wrap
}
.answer-actions button,.code-toolbar button {
  background:transparent;
  border:0;
  color:inherit;
  padding:3px 0
}
.streaming-status {
  margin-top:12px;
  color:var(--muted);
  font-size:12px
}
.streaming-status::before {
  content:"";
  display:inline-block;
  width:6px;
  height:6px;
  margin-right:7px;
  border-radius:50%;
  background:var(--primary);
  animation:pulse 1s ease-in-out infinite
}
.answer-details {
  flex:1;
  min-width:120px
}
.answer-details dl {
  background:var(--soft);
  padding:12px;
  border-radius:8px;
  display:grid;
  grid-template-columns:76px minmax(0,1fr);
  gap:8px;
  margin:8px 0
}
.answer-details dt {
  color:var(--muted)
}
.answer-details dd {
  margin:0;
  overflow-wrap:anywhere
}
.answer-more .menu-panel {
  top:22px
}
.bubble p {
  margin:0 0 14px
}
.bubble h2,.bubble h3 {
  margin:22px 0 12px
}
.bubble pre {
  overflow:auto;
  margin:0;
  padding:16px;
  background:#f6f8fc;
  line-height:1.65;
  font-size:13px
}
.bubble :not(pre)>code {
  background:#eef2f7;
  padding:2px 5px;
  border-radius:4px
}
.code-block {
  border:1px solid var(--line);
  border-radius:8px;
  overflow:hidden;
  margin:16px 0
}
.code-toolbar {
  display:flex;
  justify-content:space-between;
  padding:7px 13px;
  font-size:12px;
  background:#eef2f7;
  color:#52617a
}
.table-scroll {
  overflow:auto;
  margin:14px 0
}
.table-scroll table {
  border-collapse:collapse;
  min-width:100%;
  font-size:13px
}
.table-scroll th,.table-scroll td {
  border:1px solid var(--line);
  padding:8px 12px;
  text-align:left;
  white-space:normal;
  min-width:90px
}
.table-scroll th {
  background:var(--soft)
}
blockquote {
  border-left:3px solid #ccd8e9;
  padding-left:16px;
  margin:16px 0;
  color:var(--muted)
}
.composer-wrap {
  grid-row:4;
  padding:12px max(24px,calc((100% - 860px)/2)) 16px;
  background:#fff
}
.composer {
  border:1px solid #cad6e6;
  border-radius:14px;
  padding:12px;
  display:flex;
  align-items:flex-end;
  gap:12px;
  box-shadow:0 3px 12px #21355d06
}
.composer:focus-within {
  border-color:#79a9e6;
  box-shadow:0 0 0 2px #1d6fd813
}
.composer textarea {
  width:100%;
  resize:none;
  border:0;
  padding:6px 3px;
  background:transparent;
  min-height:44px;
  max-height:160px;
  line-height:1.6;
  outline:none;
  overflow-y:auto
}
.composer textarea:focus-visible {
  outline:none
}
.composer-hint {
  text-align:center;
  font-size:11px;
  color:var(--muted);
  margin:8px 0 0
}
.waiting {
  color:var(--muted);
  padding:8px 0;
  line-height:1.7
}
.waiting::before {
  content:'';
  display:inline-block;
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--primary);
  margin-right:9px;
  animation:pulse 1.2s infinite
}
@keyframes pulse {
  50% {
    opacity:.3
  }
}
dialog {
  border:1px solid var(--line);
  border-radius:14px;
  width:min(420px,calc(100% - 36px));
  padding:24px
}
dialog::backdrop {
  background:#0f172a60
}
dialog h2 {
  font-size:20px;
  margin:0 0 16px
}
dialog p {
  line-height:1.7;
  color:var(--muted)
}
dialog input {
  width:100%;
  padding:10px;
  border:1px solid #cbd5e1;
  border-radius:7px
}
.dialog-actions {
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:24px
}
#toast {
  position:fixed;
  left:50%;
  bottom:26px;
  transform:translateX(-50%);
  padding:10px 18px;
  background:#162033;
  color:white;
  border-radius:9px;
  opacity:0;
  pointer-events:none;
  z-index:20;
  max-width:90%;
  transition:opacity .15s
}
#toast.show {
  opacity:1
}
.sidebar-collapsed .workspace {
  grid-template-columns:0 minmax(0,1fr)
}
.sidebar-collapsed .rail {
  visibility:hidden;
  padding:0;
  border:0
}
.mobile-new,.rail-close {
  display:none
}
.backdrop {
  display:none
}
@media(max-width:760px) {
  .workspace {
    grid-template-columns:minmax(0,1fr)
  }
  .rail {
    position:fixed;
    left:0;
    top:0;
    bottom:0;
    width:280px;
    z-index:12;
    display:none;
    box-shadow:10px 0 40px #14213820
  }
  .sidebar-open .rail {
    display:flex
  }
  .sidebar-open .backdrop {
    display:block;
    position:fixed;
    inset:0;
    border:0;
    background:#0e1b345c;
    z-index:11
  }
  .rail-close,.mobile-new {
    display:inline-flex
  }
  .topbar {
    padding:10px 12px;
    gap:7px;
    min-height:76px
  }
  .model-control {
    flex:1
  }
  .model-control select {
    font-size:14px;
    max-width:220px
  }
  .model-control p {
    font-size:10px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:220px
  }
  .model-price {
    display:none
  }
  .messages {
    padding:22px 18px
  }
  .empty h1 {
    font-size:25px
  }
  .composer-wrap {
    grid-row:4;
    padding:10px 12px max(10px,env(safe-area-inset-bottom))
  }
  .composer {
    padding:8px;
    gap:6px
  }
  .composer .btn {
    padding:8px 12px
  }
  .composer-hint {
    font-size:10px
  }
  .notice {
    grid-row:2;
    padding:9px 16px;
    font-size:12px
  }
  .gate {
    padding:18px
  }
  .gate-box {
    padding:26px
  }
  .sidebar-collapsed .workspace {
    grid-template-columns:minmax(0,1fr)
  }
}
@media(prefers-reduced-motion:reduce) {
  *,*::before {
    animation:none!important;
    scroll-behavior:auto!important;
    transition:none!important
  }
}
