/* ============================================================
   Aurora — 全屏画布 · 背景动画 · 克制排版
   ============================================================ */

:root {
  --bg:        #FCFCFD;
  --bg-soft:   rgba(255,255,255,.62);
  --panel:     rgba(255,255,255,.86);
  --panel-2:   rgba(244,246,249,.8);
  --border:    rgba(18,26,45,.08);
  --border-2:  rgba(18,26,45,.14);
  --text:      #10131A;
  --text-2:    #545C6B;
  --text-3:    #8F97A5;
  --accent:    #3A5BD9;
  --accent-2:  #7B4BD9;
  --accent-bg: rgba(58,91,217,.07);
  --ok:        #1B7F55;
  --ok-bg:     rgba(27,127,85,.07);
  --warn:      #96650B;
  --warn-bg:   rgba(150,101,11,.07);
  --err:       #B93B31;
  --err-bg:    rgba(185,59,49,.07);
  --radius:    14px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Cascadia Code", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC",
           "Noto Serif SC", serif;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 28px rgba(16,24,40,.07);
  --glass: saturate(180%) blur(20px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(18,26,45,.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(18,26,45,.24); }

/* ============================== 背景动画 ============================== */

.bg {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
  background: linear-gradient(170deg, #FBFCFE 0%, #F7F8FC 45%, #FBF9FE 100%);
}

.blob {
  position: absolute; border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
  will-change: transform;
}
.b1 {
  width: 62vmax; height: 62vmax;
  left: -22vmax; top: -26vmax;
  background: radial-gradient(circle at 35% 35%,
              rgba(96,132,255,.34), rgba(96,132,255,0) 68%);
  animation: drift1 34s ease-in-out infinite alternate;
}
.b2 {
  width: 56vmax; height: 56vmax;
  right: -20vmax; top: 4vmax;
  background: radial-gradient(circle at 60% 40%,
              rgba(158,110,255,.30), rgba(158,110,255,0) 68%);
  animation: drift2 42s ease-in-out infinite alternate;
}
.b3 {
  width: 66vmax; height: 66vmax;
  left: 18vmax; bottom: -34vmax;
  background: radial-gradient(circle at 50% 50%,
              rgba(90,200,190,.24), rgba(90,200,190,0) 70%);
  animation: drift3 50s ease-in-out infinite alternate;
}

@keyframes drift1 {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(7vmax, 5vmax,0) scale(1.14); }
}
@keyframes drift2 {
  from { transform: translate3d(0,0,0) scale(1.05); }
  to   { transform: translate3d(-8vmax, 7vmax,0) scale(.92); }
}
@keyframes drift3 {
  from { transform: translate3d(0,0,0) scale(.95); }
  to   { transform: translate3d(5vmax,-6vmax,0) scale(1.1); }
}

.grain {
  position: absolute; inset: 0; opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* ============================== 布局 ============================== */

.app {
  position: relative; z-index: 1;
  display: flex; height: 100dvh; overflow: hidden;
}

/* ------------------------------ 侧栏 ------------------------------ */

.sidebar {
  width: 252px; flex: 0 0 252px;
  background: rgba(255,255,255,.55);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px 10px;
  transition: transform .26s cubic-bezier(.4,0,.2,1);
}

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 18px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.logo {
  width: 20px; height: 20px; border-radius: 6px;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2),
              #59C8BE, var(--accent));
}
.brand-text {
  font-family: var(--serif); font-weight: 600;
  font-size: 16px; letter-spacing: .4px;
}

.new-chat {
  width: 100%; padding: 9px 12px; margin-bottom: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.8);
  color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s;
}
.new-chat:hover { background: #fff; border-color: rgba(18,26,45,.22); }

.side-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 1px;
  color: var(--text-3); text-transform: uppercase;
  padding: 0 6px 8px;
}

.session-list {
  flex: 1; overflow-y: auto; margin: 0 -4px;
  display: flex; flex-direction: column; gap: 1px;
}
.session-item {
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
  transition: background .12s, color .12s;
}
.session-item:hover { background: rgba(18,26,45,.045); color: var(--text); }
.session-item.on { background: rgba(255,255,255,.9); color: var(--text); font-weight: 550; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.session-item .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .del { opacity: 0; font-size: 11px; color: var(--text-3); padding: 2px 4px; border-radius: 4px; }
.session-item:hover .del { opacity: 1; }
.session-item .del:hover { color: var(--err); background: var(--err-bg); }
.session-item .spin-mini {
  width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%;
  border: 1.5px solid rgba(58,91,217,.25); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}

.side-foot {
  padding: 10px 4px 2px; border-top: 1px solid var(--border);
  margin-top: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.ghost-btn { background: none; border: none; color: var(--text-2); font-size: 12.5px; cursor: pointer; padding: 4px 2px; }
.ghost-btn:hover { color: var(--text); }
.ver { font-size: 10.5px; color: var(--text-3); }

/* ------------------------------ 主区 ------------------------------ */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.5);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  z-index: 5;
}
.title-wrap { flex: 1; min-width: 0; }
.title {
  margin: 0; font-family: var(--serif);
  font-size: 16px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subtitle { font-size: 11.5px; color: var(--text-3); }
.top-actions { display: flex; align-items: center; gap: 8px; }

.running-badge {
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  background: var(--accent-bg); color: var(--accent); font-weight: 550;
}

.icon-btn {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.7);
  color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: all .14s;
}
.icon-btn:hover { color: var(--text); background: #fff; border-color: var(--border-2); }
.only-mobile { display: none; }

/* ------------------------------ 消息流 ------------------------------ */

.stream { flex: 1; overflow-y: auto; padding: 34px 26px 8px; }
.stream > * { max-width: 720px; margin-left: auto; margin-right: auto; }

.empty { padding: 15vh 0 0; text-align: left; }
.empty-mark {
  font-family: var(--serif); font-size: 30px; font-weight: 600;
  letter-spacing: -.5px; margin-bottom: 10px; color: var(--text);
}
.empty-mark span {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty p { margin: 0 0 26px; font-size: 14px; color: var(--text-2); max-width: 30em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.72);
  color: var(--text-2); font-size: 12.5px;
  cursor: pointer; transition: all .14s;
}
.chip:hover { color: var(--accent); border-color: rgba(58,91,217,.3); background: #fff; }

/* 消息：不用聊天气泡，走文档流 */

.msg { margin-bottom: 26px; animation: fade .22s ease both; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.msg.user {
  display: flex; justify-content: flex-end;
}
.msg.user .bubble {
  background: rgba(58,91,217,.06);
  border-left: 2px solid rgba(58,91,217,.45);
  border-radius: 0 8px 8px 0;
  padding: 9px 15px;
  max-width: 80%;
  white-space: pre-wrap; word-break: break-word;
  font-size: 14.5px; color: #22305C;
}

.msg.assistant { position: relative; padding-left: 16px; }
.msg.assistant::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, rgba(58,91,217,.5), rgba(123,75,217,.15));
}
.msg.assistant .body { font-size: 14.5px; color: var(--text); word-break: break-word; }

/* 正文 */

.body p { margin: 0 0 11px; }
.body p:last-child { margin-bottom: 0; }
.body h1, .body h2, .body h3 {
  margin: 20px 0 9px; font-family: var(--serif); font-weight: 600;
  letter-spacing: .1px; line-height: 1.35;
}
.body h1 { font-size: 19px; }
.body h2 { font-size: 17px; }
.body h3 { font-size: 15.5px; }
.body ul, .body ol { margin: 9px 0 11px; padding-left: 22px; }
.body li { margin: 4px 0; }
.body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(58,91,217,.25); }
.body a:hover { border-bottom-color: var(--accent); }
.body strong { font-weight: 650; }
.body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.body code.inline {
  font-family: var(--mono); font-size: .87em;
  background: rgba(18,26,45,.05); border-radius: 4px;
  padding: 1.5px 5px; color: #2A3346;
}

.code-block {
  margin: 13px 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.82);
  overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: rgba(18,26,45,.025);
  border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-3);
}
.code-head .lang { font-family: var(--mono); letter-spacing: .3px; flex: 1; }
.copy-btn, .prev-btn {
  background: none; border: 1px solid transparent; color: var(--text-3);
  font-size: 11px; cursor: pointer; padding: 2px 8px; border-radius: 5px;
}
.copy-btn:hover, .prev-btn:hover { color: var(--accent); background: var(--accent-bg); }
.prev-btn { color: var(--accent); border-color: rgba(58,91,217,.22); }
.code-block pre {
  margin: 0; padding: 13px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.62;
  color: #2A3346;
}

/* 工具调用：紧凑行，不用大卡片 */

.tool-card {
  margin: 6px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.62);
  overflow: hidden;
  font-size: 12.5px;
}
.tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px; cursor: pointer; user-select: none;
}
.tool-head:hover { background: rgba(18,26,45,.03); }
.tool-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3); flex: 0 0 6px;
}
.tool-card.running .tool-dot { background: #D99A2B; animation: pulse 1.1s infinite; }
.tool-card.done .tool-dot { background: var(--ok); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.tool-name { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 550; }
.tool-brief { flex: 1; color: var(--text-3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-arrow { color: var(--text-3); font-size: 9px; transition: transform .18s; }
.tool-card.open .tool-arrow { transform: rotate(90deg); }

.tool-body { display: none; border-top: 1px solid var(--border); padding: 10px 11px; background: rgba(18,26,45,.02); }
.tool-card.open .tool-body { display: block; }
.tool-body .k {
  font-size: 10px; color: var(--text-3); letter-spacing: .5px;
  text-transform: uppercase; margin-bottom: 4px; font-weight: 600;
}
.tool-body pre {
  margin: 0 0 10px; padding: 9px 11px;
  background: rgba(255,255,255,.9); border-radius: 6px;
  border: 1px solid var(--border);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  color: #2A3346; overflow-x: auto; max-height: 300px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.tool-body pre:last-child { margin-bottom: 0; }

.status-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-3); padding: 4px 0;
}
.status-line .spin {
  width: 10px; height: 10px; flex: 0 0 10px;
  border: 1.5px solid rgba(18,26,45,.14);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.review-card {
  margin: 10px 0; border-radius: 8px;
  border: 1px solid var(--border); padding: 10px 13px;
  font-size: 12.5px; background: rgba(255,255,255,.7);
}
.review-card.ok { border-color: rgba(27,127,85,.28); background: var(--ok-bg); }
.review-card.bad { border-color: rgba(150,101,11,.28); background: var(--warn-bg); }
.review-title { font-weight: 650; margin-bottom: 4px; }
.review-card.ok .review-title { color: var(--ok); }
.review-card.bad .review-title { color: var(--warn); }
.review-card ul { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }

.approve-card {
  margin: 10px 0; border-radius: 8px;
  border: 1px solid rgba(150,101,11,.3);
  background: var(--warn-bg); padding: 12px 14px;
}
.approve-title { color: var(--warn); font-weight: 650; font-size: 13px; margin-bottom: 5px; }
.approve-desc { color: var(--text-2); font-size: 12.5px; margin-bottom: 10px; }
.approve-actions { display: flex; gap: 8px; }
.approve-actions button {
  padding: 7px 16px; border-radius: 7px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border-2); background: #fff; color: var(--text);
}
.approve-actions .allow { background: var(--accent); border-color: transparent; color: #fff; font-weight: 550; }

/* ------------------------------ 输入区 ------------------------------ */

.composer { padding: 8px 26px 0; }
.composer-inner {
  max-width: 720px; margin: 0 auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,.82);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  padding: 12px 14px 9px;
  box-shadow: var(--shadow);
  transition: border-color .16s, box-shadow .16s;
}
.composer-inner:focus-within {
  border-color: rgba(58,91,217,.35);
  box-shadow: 0 0 0 4px rgba(58,91,217,.07), var(--shadow);
}
#input {
  width: 100%; border: none; background: none; outline: none;
  resize: none; font-size: 14.5px; line-height: 1.62;
  color: var(--text); max-height: 190px; padding: 2px 2px 8px;
}
#input::placeholder { color: var(--text-3); }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.left-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hint { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-btn {
  padding: 4px 11px; border-radius: 6px;
  border: 1px solid var(--border-2); background: rgba(255,255,255,.9);
  color: var(--text-2); font-size: 12px; cursor: pointer;
}
.mini-btn:hover { color: var(--accent); border-color: rgba(58,91,217,.3); }

.send-btn {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 9px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; display: grid; place-items: center;
  transition: filter .14s, transform .1s;
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:active { transform: scale(.96); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ------------------------------ 状态栏 ------------------------------ */

.statbar {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; flex-wrap: wrap;
  padding: 8px 26px 14px;
  font-size: 11px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.statbar .item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.statbar .item b { font-weight: 600; color: var(--text-2); }
.statbar .sep { width: 1px; height: 9px; background: var(--border-2); }
.statbar .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.statbar b.live { color: var(--accent); }

/* ------------------------------ 弹窗 ------------------------------ */

.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16,24,40,.26);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; place-items: center; padding: 20px;
}
.modal.on { display: grid; }

.modal-card {
  width: 100%; max-width: 580px; max-height: 88dvh;
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 70px rgba(16,24,40,.2);
  animation: pop .18s ease both;
}
@keyframes pop {
  from { opacity: 0; transform: scale(.98) translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
}
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 600; }

.tabs { display: flex; gap: 2px; padding: 0 16px 12px; border-bottom: 1px solid var(--border); }
.tab {
  border: none; background: none; color: var(--text-3);
  font-size: 13px; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  transition: all .14s;
}
.tab:hover { color: var(--text-2); background: rgba(18,26,45,.04); }
.tab.on { background: var(--accent-bg); color: var(--accent); font-weight: 550; }

.modal-body { padding: 18px 20px 22px; overflow-y: auto; flex: 1; }
.pane { display: none; }
.pane.on { display: block; }
.tip { margin: 0 0 14px; font-size: 12.5px; color: var(--text-3); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px; }
.field-grid input, .field-grid textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--border-2); background: #fff;
  color: var(--text); outline: none; font-size: 13.5px;
  transition: border-color .14s, box-shadow .14s;
}
.field-grid input:focus, .field-grid textarea:focus {
  border-color: rgba(58,91,217,.4);
  box-shadow: 0 0 0 3px rgba(58,91,217,.07);
}
.field-grid input::placeholder, .field-grid textarea::placeholder { color: var(--text-3); }
.field-grid .wide { grid-column: 1 / -1; }

.model-row { display: flex; gap: 6px; }
.model-row input { flex: 1; }
.model-picker {
  margin: -4px 0 12px; max-height: 160px; overflow-y: auto;
  border: 1px solid var(--border-2); border-radius: 9px;
  background: #fff; padding: 6px;
}
.model-picker .m {
  padding: 6px 9px; border-radius: 6px; font-size: 12.5px;
  font-family: var(--mono); color: var(--text-2); cursor: pointer;
}
.model-picker .m:hover { background: var(--accent-bg); color: var(--accent); }

.primary-btn {
  padding: 10px 18px; border-radius: 9px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 13.5px; font-weight: 550;
  transition: filter .14s;
}
.primary-btn:hover { filter: brightness(1.08); }

.list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: rgba(255,255,255,.7);
  font-size: 13px;
}
.row-item .name { font-weight: 550; }
.row-item .meta { color: var(--text-3); font-size: 11.5px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .tag {
  font-size: 10px; padding: 2px 7px; border-radius: 20px;
  background: var(--accent-bg); color: var(--accent); font-weight: 550;
}
.row-item .act { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 12px; padding: 3px 6px; border-radius: 5px; }
.row-item .act:hover { color: var(--err); background: var(--err-bg); }
.row-item .act.use { color: var(--accent); }
.row-item .act.use:hover { background: var(--accent-bg); }

.switch-list { display: flex; flex-direction: column; }
.switch-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .grow { flex: 1; min-width: 0; }
.switch-row .n { font-size: 13px; font-weight: 500; }
.switch-row .d { font-size: 11.5px; color: var(--text-3); }

.toggle {
  width: 38px; height: 22px; flex: 0 0 38px; border-radius: 20px;
  border: 1px solid var(--border-2); background: rgba(18,26,45,.09);
  cursor: pointer; position: relative; transition: background .18s;
}
.toggle::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px;
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(16,24,40,.24); transition: all .18s;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { left: 19px; }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 9px 2px; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }

.lab { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.lab input, .lab textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--border-2); background: #fff;
  color: var(--text); outline: none; font-size: 13.5px; resize: vertical;
}
.lab.wide { margin-top: 8px; }

.overlay { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(16,24,40,.18); }
.overlay.on { display: block; }

/* 预览 */

.preview-card { max-width: 900px; height: 86dvh; }
.preview-body { flex: 1; padding: 0 16px 16px; }
.preview-body iframe {
  width: 100%; height: 100%; border: 1px solid var(--border-2);
  border-radius: 10px; background: #fff;
}

/* 用户区 */

.user-box {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 6px 2px; margin-top: 6px;
  border-top: 1px solid var(--border);
}
.avatar {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650; color: #fff; text-transform: uppercase;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 10.5px; color: var(--text-3); }
.icon-btn.tiny { width: 24px; height: 24px; flex: 0 0 24px; font-size: 10px; border-radius: 6px; }

/* ============================== 响应式 ============================== */

@media (max-width: 1000px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(16,24,40,.14);
  }
  .sidebar.on { transform: none; }
  .only-mobile { display: grid; }
  .stream { padding: 24px 16px 8px; }
  .composer { padding: 8px 16px 0; }
  .statbar { padding: 8px 16px 12px; }
  .topbar { padding: 13px 16px; }
}

@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .topbar { padding: 11px 13px; gap: 8px; }
  .title { font-size: 14.5px; }
  .subtitle { display: none; }
  .stream { padding: 18px 13px 6px; }
  .msg { margin-bottom: 20px; }
  .msg.assistant { padding-left: 13px; }
  .msg.user .bubble { max-width: 90%; font-size: 14px; }
  .msg.assistant .body { font-size: 14px; }
  .composer { padding: 6px 11px 0; }
  .composer-inner { padding: 10px 11px 7px; }
  .hint { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal-card { max-width: none; max-height: 100dvh; height: 100dvh; border-radius: 0; border: none; }
  .empty { padding-top: 10vh; }
  .empty-mark { font-size: 24px; }
  .chips { flex-direction: column; align-items: stretch; }
  .chip { text-align: center; }
  .statbar { gap: 10px; font-size: 10.5px; padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); }
  .blob { filter: blur(50px); opacity: .42; }
}

@media (max-width: 340px), (max-height: 340px) {
  body { font-size: 13px; line-height: 1.55; }
  .topbar { padding: 6px 8px; gap: 6px; }
  .title { font-size: 12.5px; }
  .icon-btn { width: 27px; height: 27px; flex-basis: 27px; font-size: 11px; }
  .stream { padding: 9px 8px 4px; }
  .msg { margin-bottom: 13px; }
  .msg.assistant { padding-left: 9px; }
  .msg.user .bubble { padding: 7px 10px; font-size: 12.5px; max-width: 94%; }
  .msg.assistant .body { font-size: 12.5px; }
  .composer { padding: 3px 6px 0; }
  .composer-inner { padding: 7px 8px 5px; border-radius: 10px; }
  #input { font-size: 12.5px; padding-bottom: 4px; }
  .send-btn { width: 29px; height: 29px; flex-basis: 29px; font-size: 14px; }
  .tool-head { padding: 5px 8px; }
  .tool-name { font-size: 11px; }
  .tool-brief { font-size: 10.5px; }
  .code-block pre { font-size: 11px; padding: 9px; }
  .empty-mark { font-size: 19px; }
  .empty p { font-size: 11.5px; }
  .chip { padding: 6px 10px; font-size: 11px; }
  .sidebar { width: 218px; flex-basis: 218px; }
  .statbar { font-size: 9.5px; gap: 7px; padding: 4px 8px 8px; }
  .statbar .sep { display: none; }
  .user-box { padding: 6px 4px 0; gap: 6px; }
  .avatar { width: 21px; height: 21px; flex-basis: 21px; font-size: 10px; }
  .user-name { font-size: 11px; }
  .user-role { display: none; }
  .modal-body { padding: 12px 12px 14px; }
  .tabs { padding: 0 10px 8px; }
  .tab { padding: 5px 8px; font-size: 11.5px; }
  .blob { filter: blur(38px); opacity: .35; }
}

@media (max-height: 300px) {
  .topbar { padding: 4px 6px; }
  .subtitle { display: none; }
  .empty { padding-top: 2vh; }
  .empty p { display: none; }
  .statbar { display: none; }
}
