:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --sidebar: #efefec;
  --ink: #191918;
  --muted: #73736d;
  --line: #e5e5e0;
  --accent: #6657d9;
  --accent-dark: #5547c3;
  --accent-soft: #eeebff;
  --green: #39a875;
  --shadow: 0 12px 40px rgba(34, 31, 25, 0.09);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.mobile-only { display: none !important; }

svg { width: 1.25rem; height: 1.25rem; fill: currentColor; }
.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: rgba(0, 0, 0, 0.055); }

/* Authentication */
.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(118, 100, 216, 0.1), transparent 34%),
    linear-gradient(150deg, #f7f7f4, #f1f0f7);
}
.auth-glow { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .5; }
.auth-glow-one { width: 330px; height: 330px; left: -170px; top: 10%; background: #ded8ff; }
.auth-glow-two { width: 260px; height: 260px; right: -100px; bottom: -70px; background: #d9f0e6; }
.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  padding: 44px 42px 30px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 24px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 30px 80px rgba(49, 44, 73, .13);
  backdrop-filter: blur(18px);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: white;
  background: linear-gradient(145deg, #7567df, #5143ba);
  box-shadow: 0 6px 16px rgba(86, 70, 194, .25);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark-large { width: 50px; height: 50px; border-radius: 15px; margin: 0 auto 20px; }
.brand-mark-large svg { width: 30px; height: 30px; }
.login-heading { text-align: center; margin-bottom: 30px; }
.login-heading h1 { margin: 0 0 9px; font-size: 27px; letter-spacing: -.7px; }
.login-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.password-field > span { display: block; margin: 0 0 8px 2px; font-size: 13px; font-weight: 650; }
.password-input-wrap { position: relative; }
.password-input-wrap > svg {
  position: absolute;
  top: 50%; left: 14px;
  width: 18px; height: 18px;
  color: #92918d;
  transform: translateY(-50%);
}
.password-input-wrap input {
  width: 100%; height: 48px;
  padding: 0 47px 0 43px;
  border: 1px solid #deded9;
  border-radius: 12px;
  outline: 0;
  background: rgba(250,250,248,.85);
  transition: .2s;
}
.password-input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(102,87,217,.12); background: white; }
.field-action { position: absolute; right: 7px; top: 6px; color: #85847f; }
.field-action svg { width: 18px; height: 18px; }
.form-error { min-height: 19px; margin: 7px 2px 2px; color: #c54848; font-size: 12px; }
.primary-button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  cursor: pointer;
  transition: .2s;
}
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .6; cursor: wait; transform: none; }
.login-button { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; height: 48px; }
.login-button svg { width: 18px; height: 18px; }
.secure-note { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 24px; color: #999892; font-size: 11px; }
.secure-note svg { width: 14px; height: 14px; color: #76aa91; }

/* App shell */
.app { display: flex; width: 100%; height: 100dvh; }
.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex: 0 0 276px;
  flex-direction: column;
  width: 276px;
  padding: 20px 14px 14px;
  border-right: 1px solid rgba(0,0,0,.035);
  background: var(--sidebar);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 19px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 750; letter-spacing: -.3px; }
.new-chat-button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 45px;
  padding: 0 12px;
  gap: 10px;
  border: 1px solid #deded8;
  border-radius: 12px;
  background: rgba(255,255,255,.72);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.025);
}
.new-chat-button:hover { border-color: #d1d0ca; background: white; }
.new-chat-button svg { width: 18px; height: 18px; }
.new-chat-button kbd { margin-left: auto; border: 0; color: #aaa9a3; background: transparent; font-size: 10px; }
.creation-actions { display: grid; margin: 0 0 18px; gap: 8px; }
.conversation-item[data-kind="image"] .conversation-title::before { content: "▧"; margin-right: 7px; color: #7465d0; }
.conversation-item[data-kind="video"] .conversation-title::before { content: "▶"; margin-right: 7px; color: #b36b56; font-size: 8px; }
.conversation-item[data-kind="advanced-video"] .conversation-title::before { content: "◆"; margin-right: 7px; color: #6173bd; font-size: 8px; }
.history-label { margin: 23px 10px 8px; color: #989791; font-size: 11px; font-weight: 650; letter-spacing: .04em; }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d8d7d2 transparent; }
.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 6px 9px 6px 11px;
  border-radius: 10px;
  color: #45443f;
  cursor: pointer;
}
.conversation-item:hover { background: rgba(255,255,255,.55); }
.conversation-item.active { color: #30296b; background: rgba(255,255,255,.82); font-weight: 600; }
.conversation-summary { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 3px; }
.conversation-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.conversation-time { padding-left: 15px; color: #aaa8a2; font-size: 8px; font-weight: 450; line-height: 1; }
.conversation-item.active .conversation-time { color: #918bac; }
.delete-conversation { display: none; width: 28px; height: 28px; color: #8d8b86; }
.delete-conversation svg { width: 15px; height: 15px; }
.conversation-item:hover .delete-conversation, .conversation-item.active:hover .delete-conversation { display: grid; }
.sidebar-footer { display: flex; align-items: center; padding: 13px 7px 3px; border-top: 1px solid #deded9; }
.user-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: white; background: #33323a; font-size: 10px; font-weight: 700; }
.user-info { display: flex; flex: 1; flex-direction: column; gap: 2px; margin-left: 10px; }
.user-info strong { font-size: 12px; }
.user-info span { color: #96958f; font-size: 10px; }
.sidebar-footer .icon-button { color: #77766f; }
.sidebar-footer .icon-button svg { width: 18px; height: 18px; }

.chat-main { position: relative; display: flex; flex: 1; min-width: 0; flex-direction: column; background: var(--surface); }
.chat-main.advanced-mode > .chat-header { display: none; }
.chat-header {
  position: relative;
  z-index: 10;
  display: flex;
  flex: 0 0 70px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid #efefeb;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
}
.header-left { display: flex; align-items: center; min-width: 0; gap: 8px; }
.header-left h2 { overflow: hidden; max-width: 420px; margin: 0 0 4px; font-size: 14px; font-weight: 680; white-space: nowrap; text-overflow: ellipsis; }
.online-state { display: flex; align-items: center; gap: 6px; color: #8a8984; font-size: 10px; }
.online-state span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #e6f5ed; }
.online-state b { font-weight: 500; }
.context-tools { display: flex; align-items: center; gap: 14px; }
.char-count { display: flex; align-items: center; gap: 6px; color: #777670; font-size: 11px; }
.char-count svg { width: 16px; height: 16px; color: #aaa9a3; }
.char-count strong { color: #51504b; font-weight: 600; }
.compress-button {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  gap: 7px;
  border: 1px solid #deddd8;
  border-radius: 9px;
  background: white;
  color: #605f5a;
  font-size: 11px;
  cursor: pointer;
}
.compress-button:hover:not(:disabled) { border-color: #cfcce8; color: var(--accent); background: #faf9ff; }
.compress-button:disabled { opacity: .42; cursor: not-allowed; }
.compress-button svg { width: 15px; height: 15px; }
.compress-button.loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.chat-scroll.advanced-mode { overflow: hidden; }
.advanced-video-studio { width: 100%; height: 100%; }
.advanced-video-studio[hidden] { display: none; }
.studio-panel { width: min(100% - 40px, 820px); margin: 0 auto; padding: 38px 0 8px; }
.studio-panel[hidden] { display: none; }
.studio-heading { margin-bottom: 20px; }
.studio-kicker { display: block; margin-bottom: 8px; color: #7566d0; font-size: 9px; font-weight: 750; letter-spacing: .16em; }
.studio-heading h1 { margin: 0 0 8px; color: #28272c; font-size: clamp(23px, 3vw, 31px); letter-spacing: -.6px; }
.studio-heading p { max-width: 640px; margin: 0; color: #898781; font-size: 12px; line-height: 1.7; }
.studio-form { padding: 20px; border: 1px solid #e3e1eb; border-radius: 18px; background: linear-gradient(145deg, #fff, #fbfaff); box-shadow: 0 12px 35px rgba(50,43,90,.055); }
.studio-field-row { display: flex; align-items: flex-end; margin-bottom: 15px; gap: 10px; }
.studio-field { display: flex; flex: 1; flex-direction: column; gap: 7px; color: #62605d; font-size: 10px; font-weight: 650; }
.studio-field select, .studio-field textarea, .studio-field input { width: 100%; border: 1px solid #dedce5; border-radius: 11px; outline: 0; color: #343238; background: #fff; font: inherit; font-size: 12px; font-weight: 450; }
.studio-field select, .studio-field input { height: 39px; padding: 0 11px; }
.studio-field textarea { min-height: 94px; padding: 11px 12px; resize: vertical; line-height: 1.65; }
.studio-field select:focus, .studio-field textarea:focus, .studio-field input:focus { border-color: #aaa1df; box-shadow: 0 0 0 3px rgba(108,92,201,.08); }
.studio-upload-button { display: flex; align-items: center; justify-content: center; height: 39px; padding: 0 14px; gap: 7px; border: 1px solid #d8d4eb; border-radius: 11px; color: #6558bc; background: #f8f6ff; font-size: 10px; font-weight: 650; cursor: pointer; }
.studio-upload-button:hover { background: #f1eeff; }
.studio-upload-button svg { width: 16px; height: 16px; fill: currentColor; }
.studio-media-list { display: flex; flex-wrap: wrap; margin: 0 0 15px; gap: 9px; }
.studio-media-list:empty { display: none; }
.studio-media-card { position: relative; overflow: hidden; width: 116px; border: 1px solid #dfdce9; border-radius: 11px; background: #f4f2f7; }
.studio-media-card img, .studio-media-card video { display: block; width: 100%; height: 90px; object-fit: cover; background: #e8e6ed; }
.studio-media-card video { height: auto; max-height: 220px; }
.studio-media-card > span { display: block; overflow: hidden; padding: 6px 8px; color: #6c6970; font-size: 8px; white-space: nowrap; text-overflow: ellipsis; }
.studio-media-remove { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 21px; height: 21px; padding: 0; border: 0; border-radius: 50%; color: white; background: rgba(35,33,42,.72); font-size: 16px; cursor: pointer; }
#video-reference .studio-media-card { width: min(100%, 420px); }
.video-upload-zone { display: flex; align-items: center; min-height: 82px; margin-bottom: 15px; padding: 15px; gap: 13px; border: 1px dashed #cfc9e7; border-radius: 13px; color: #6c60bf; background: #faf9ff; cursor: pointer; }
.video-upload-zone:hover { border-color: #9e93d6; background: #f6f3ff; }
.video-upload-zone > svg { flex: 0 0 27px; width: 27px; height: 27px; fill: currentColor; }
.video-upload-zone > span { display: flex; flex-direction: column; gap: 5px; }
.video-upload-zone strong { color: #534b80; font-size: 12px; }
.video-upload-zone small { color: #949097; font-size: 9px; font-weight: 450; }
.studio-speed { max-width: 190px; margin-top: 14px; }
.voice-picker-row { display: flex; align-items: flex-end; margin-top: 14px; gap: 10px; }
.voice-select-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.voice-select-row select { min-width: 0; }
.voice-refresh-actions { display: flex; gap: 7px; }
.secondary-button { height: 39px; padding: 0 12px; border: 1px solid #dcd9e8; border-radius: 10px; color: #665d88; background: #fff; font-size: 9px; font-weight: 650; cursor: pointer; white-space: nowrap; }
.secondary-button:hover:not(:disabled) { border-color: #bcb5dd; background: #f8f6ff; }
.secondary-button:disabled { opacity: .45; cursor: default; }
.voice-clone-panel { margin-top: 12px; border: 1px solid #e3e1eb; border-radius: 14px; background: #fcfbff; }
.voice-clone-panel > summary { padding: 13px 16px; color: #655a91; font-size: 10px; font-weight: 680; cursor: pointer; }
.voice-clone-form { padding: 3px 16px 16px; border-top: 1px solid #eceaf1; }
.clone-field-grid { display: grid; margin: 14px 0 12px; grid-template-columns: 1fr 1fr; gap: 10px; }
.clone-audio-upload { display: block; padding: 12px; border: 1px dashed #cec8e4; border-radius: 10px; color: #77718e; background: #faf9ff; font-size: 9px; cursor: pointer; }
.clone-audio-upload:hover { border-color: #9e93d6; }
.audio-review { display: grid; align-items: center; margin-top: 13px; padding: 11px 12px; border: 1px solid #dfdce9; border-radius: 12px; background: #faf9ff; grid-template-columns: auto minmax(180px, 1fr); gap: 8px 12px; }
.audio-review[hidden] { display: none; }
.audio-review > span { color: #625b7d; font-size: 10px; font-weight: 680; white-space: nowrap; }
.audio-review audio { width: 100%; height: 34px; }
.audio-review small { color: #888390; font-size: 9px; grid-column: 2; }
.studio-submit-row { display: flex; flex-wrap: wrap; gap: 9px; }
.studio-submit { min-width: 145px; height: 39px; margin-top: 15px; padding: 0 18px; border: 0; border-radius: 11px; color: white; background: linear-gradient(135deg, #695ac8, #5143ad); font-size: 11px; font-weight: 680; cursor: pointer; box-shadow: 0 7px 18px rgba(76,62,170,.18); }
.studio-submit:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(76,62,170,.24); }
.studio-submit:disabled { opacity: .42; cursor: default; box-shadow: none; }
.studio-status { display: inline-block; margin: 0 0 0 12px; color: #85818e; font-size: 10px; }
#video-status { display: block; min-height: 14px; margin: 9px 0 0; }
.video-task-status { margin-top: 11px; padding: 11px 12px; border: 1px solid #dedbea; border-radius: 11px; background: #faf9ff; }
.video-task-status[hidden] { display: none; }
.video-task-summary { display: flex; align-items: center; gap: 8px; color: #777282; font-size: 10px; }
.video-task-summary strong { color: #5e54a2; font-size: 11px; }
.video-task-summary b { margin-left: auto; color: #51479b; font-size: 11px; font-variant-numeric: tabular-nums; }
.video-task-track { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: #e6e2f3; }
.video-task-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7667d7, #5547b9); transition: width .35s ease; }
.welcome { display: flex; align-items: center; flex-direction: column; width: min(100% - 36px, 700px); margin: 0 auto; padding: clamp(60px, 10vh, 112px) 0 35px; text-align: center; }
.welcome-orb { position: relative; width: 68px; height: 68px; margin-bottom: 26px; }
.orb-core { position: absolute; inset: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #faf9ff, #8879e7 45%, #5545c2 78%); box-shadow: 0 8px 26px rgba(88,72,199,.28); }
.orb-ring { position: absolute; border: 1px solid rgba(105,88,216,.25); border-radius: 50%; }
.ring-one { inset: 7px; border-left-color: transparent; transform: rotate(-25deg); }
.ring-two { inset: 0; border-color: rgba(105,88,216,.11); border-right-color: transparent; transform: rotate(35deg); }
.welcome h1 { margin: 0 0 12px; font-size: clamp(27px, 3vw, 35px); font-weight: 720; letter-spacing: -1.1px; }
.welcome > p { max-width: 520px; margin: 0; color: #85847e; font-size: 13px; line-height: 1.75; }
.suggestions { display: grid; width: 100%; margin-top: 42px; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.suggestion {
  display: flex;
  align-items: flex-start;
  min-height: 106px;
  padding: 16px 14px;
  gap: 10px;
  border: 1px solid #e8e8e3;
  border-radius: 15px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: .2s;
}
.suggestion:hover { border-color: #dcd9ee; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(39,35,67,.07); }
.suggestion-icon { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
.suggestion-icon.violet { color: #6e5fd2; background: #efecff; }
.suggestion-icon.amber { color: #b27a2f; background: #fff2dc; }
.suggestion-icon.blue { color: #397fbb; background: #e5f3ff; }
.suggestion > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.suggestion strong { font-size: 12px; font-weight: 650; }
.suggestion small { color: #999892; font-size: 10px; line-height: 1.45; }
.suggestion b { margin-left: auto; color: #bbb9b3; font-size: 12px; font-weight: 400; }

.messages { width: min(100% - 40px, 820px); margin: 0 auto; padding: 38px 0 48px; }
.messages.video-results { display: grid; padding-top: 22px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.messages.video-results.hidden { display: none; }
.video-result-card { overflow: hidden; border: 1px solid #dedbe8; border-radius: 15px; background: #fff; box-shadow: 0 10px 28px rgba(50,43,90,.07); }
.video-result-card video { display: block; width: 100%; max-height: 520px; background: #17161b; }
.video-result-footer { display: flex; align-items: center; justify-content: space-between; min-width: 0; padding: 10px 12px; gap: 12px; }
.video-result-footer span { overflow: hidden; color: #69666f; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.video-result-footer a { flex: 0 0 auto; color: #6557be; font-size: 10px; font-weight: 650; text-decoration: none; }
.video-result-footer a:hover { text-decoration: underline; }
.message { display: flex; margin-bottom: 28px; gap: 13px; }
.message.user { justify-content: flex-end; }
.message-avatar { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; margin-top: 2px; border-radius: 10px; color: white; background: linear-gradient(145deg, #786ae1, #5547be); }
.message-avatar svg { width: 19px; height: 19px; }
.message-body { min-width: 0; max-width: min(88%, 720px); }
.message-body .message-content { max-width: none; }
.message.user .message-body { display: flex; align-items: flex-end; flex-direction: column; }
.message-content { min-width: 0; max-width: min(88%, 720px); color: #302f2b; font-size: 14px; line-height: 1.75; }
.message.user .message-content { width: 100%; padding: 10px 15px; border-radius: 17px 17px 4px 17px; background: #f0eff7; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.assistant .message-content { padding-top: 3px; }
.message.summary { padding: 16px 18px; border: 1px solid #e0dcf6; border-radius: 15px; background: #faf9ff; }
.message.summary .message-avatar { background: #897de0; }
.message.summary .message-content::before { content: "已压缩的上下文"; display: block; margin-bottom: 5px; color: #7466d3; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.message-content p { margin: 0 0 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h1, .message-content h2, .message-content h3 { margin: 20px 0 9px; line-height: 1.35; }
.message-content h1 { font-size: 1.35em; } .message-content h2 { font-size: 1.2em; } .message-content h3 { font-size: 1.08em; }
.message-content ul, .message-content ol { margin: 8px 0 13px; padding-left: 24px; }
.message-content li { margin: 4px 0; }
.message-content a { color: #5e50c7; text-decoration: none; border-bottom: 1px solid #cbc5f1; }
.message-content a:hover { border-color: #5e50c7; }
.message-content blockquote { margin: 12px 0; padding: 4px 0 4px 13px; border-left: 3px solid #d4cff4; color: #6e6c65; }
.message-content code { padding: 2px 5px; border-radius: 5px; background: #f0f0ec; font-family: "Cascadia Code", Consolas, monospace; font-size: .9em; }
.math-block { max-width: 100%; margin: 10px 0 14px; padding: 4px 2px; overflow-x: auto; overflow-y: hidden; text-align: center; }
.math-block .katex-display { margin: .45em 0; }
.message-content .katex, .reasoning-content .katex { white-space: normal; font-size: 1.05em; }
.message.user .math-block { text-align: left; }
.message-attachments { display: flex; flex-wrap: wrap; margin-top: 10px; gap: 8px; }
.message-image {
  display: block;
  overflow: hidden;
  width: min(260px, 100%);
  max-height: 240px;
  border: 1px solid rgba(75, 68, 107, .12) !important;
  border-radius: 12px;
  background: #ecebf1;
}
.message-image img { display: block; width: 100%; max-height: 240px; object-fit: contain; }
.message-media-card { display: flex; align-items: flex-start; flex-direction: column; gap: 6px; }
.message-video { display: block; overflow: hidden; width: min(440px, 100%); border: 1px solid rgba(75,68,107,.12) !important; border-radius: 12px; background: #16151a; }
.message-video video { display: block; width: 100%; max-height: 420px; }
.message-audio { display: block; padding: 8px; border: 1px solid rgba(75,68,107,.12) !important; border-radius: 12px; background: #f8f7fc; }
.message-audio audio { display: block; width: min(360px, 70vw); height: 36px; }
.reuse-image-button { align-self: center; padding: 5px 9px; border: 1px solid #d7d2ef; border-radius: 8px; color: #6557be; background: #faf9ff; font-size: 9px; cursor: pointer; }
.reuse-image-button:hover { background: #f1eeff; }
.message-file {
  display: flex;
  align-items: center;
  min-width: 180px;
  max-width: 280px;
  padding: 9px 11px;
  gap: 9px;
  border: 1px solid rgba(75, 68, 107, .12) !important;
  border-radius: 11px;
  color: #4c4960 !important;
  background: rgba(255,255,255,.72);
  text-decoration: none;
}
.message-file > svg { flex: 0 0 19px; width: 19px; height: 19px; color: #7466d3; }
.message-file > span { display: flex; min-width: 0; flex-direction: column; line-height: 1.35; }
.message-file strong { overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.message-file small { color: #92908c; font-size: 8px; }
.message.user .message-attachments { justify-content: flex-end; }
.message-actions { display: flex; justify-content: flex-end; height: 25px; padding: 3px 3px 0; }
.message-edit-button {
  display: grid;
  place-items: center;
  width: 25px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: #99968f;
  background: transparent;
  cursor: pointer;
  opacity: .58;
  transition: .18s;
}
.message-edit-button:hover:not(:disabled) { color: #5e50c7; background: #f1effa; opacity: 1; }
.message-edit-button:disabled { cursor: not-allowed; opacity: .25; }
.message-edit-button svg { width: 13px; height: 13px; }
.message.user .message-content.editing {
  width: min(620px, 72vw);
  min-width: 360px;
  padding: 12px;
  border: 1px solid #cfc9ed;
  border-radius: 15px;
  background: #f8f7fc;
  box-shadow: 0 7px 22px rgba(64, 51, 130, .08);
  white-space: normal;
}
.reasoning-panel { width: 100%; margin: 0 0 10px; color: #77736f; font-size: 12px; }
.reasoning-panel summary {
  display: flex;
  align-items: center;
  width: fit-content;
  padding: 4px 7px;
  gap: 7px;
  border-radius: 8px;
  color: #7b7773;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: .18s;
}
.reasoning-panel summary::-webkit-details-marker { display: none; }
.reasoning-panel summary:hover { color: #5f56a6; background: #f5f3fb; }
.reasoning-panel summary > svg { width: 14px; height: 14px; transition: transform .18s; }
.reasoning-panel[open] summary > svg { transform: rotate(180deg); }
.reasoning-status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.reasoning-status > i { width: 6px; height: 6px; border-radius: 50%; background: #9a91cf; }
.reasoning-panel.thinking .reasoning-status > i { animation: reasoning-pulse 1.2s infinite ease-in-out; }
@keyframes reasoning-pulse { 0%, 100% { opacity: .35; box-shadow: 0 0 0 0 rgba(113, 97, 202, .2); } 50% { opacity: 1; box-shadow: 0 0 0 5px rgba(113, 97, 202, 0); } }
.reasoning-content {
  max-height: 300px;
  margin: 5px 0 2px 10px;
  padding: 5px 12px;
  overflow-y: auto;
  border-left: 2px solid #ded9f2;
  color: #85817c;
  font-size: 12px;
  line-height: 1.65;
}
.reasoning-content p { margin: 0 0 8px; }
.reasoning-content p:last-child { margin-bottom: 0; }
.reasoning-content ul, .reasoning-content ol { margin: 6px 0 8px; padding-left: 20px; }
.reasoning-content code { padding: 1px 4px; border-radius: 4px; background: #f0efeb; font-family: "Cascadia Code", Consolas, monospace; }
.message-edit-input {
  display: block;
  width: 100%;
  min-height: 58px;
  max-height: 240px;
  padding: 2px 3px;
  resize: none;
  border: 0;
  outline: 0;
  color: #2e2c34;
  background: transparent;
  font-size: 14px;
  line-height: 1.6;
}
.message-edit-actions { display: flex; justify-content: flex-end; margin-top: 10px; gap: 7px; }
.message-edit-actions button {
  height: 30px;
  padding: 0 13px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}
.edit-cancel-button { border: 1px solid #d9d7df; color: #68666d; background: white; }
.edit-cancel-button:hover { background: #f3f2f5; }
.edit-submit-button { border: 1px solid var(--accent); color: white; background: var(--accent); }
.edit-submit-button:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.code-block { position: relative; margin: 14px 0; overflow: hidden; border: 1px solid #dededb; border-radius: 11px; background: #25242a; color: #ecebef; }
.code-header { display: flex; justify-content: space-between; align-items: center; height: 34px; padding: 0 10px 0 13px; color: #aaa8b0; background: #302f36; font-size: 10px; }
.copy-code { border: 0; color: #c8c6cc; background: transparent; font-size: 10px; cursor: pointer; }
.code-block pre { margin: 0; padding: 14px; overflow-x: auto; }
.code-block code { padding: 0; color: inherit; background: transparent; font-size: 12px; line-height: 1.65; }
.typing { display: inline-flex; align-items: center; height: 27px; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #8b82c9; animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
.message-error { margin-top: 8px; color: #c64b4b; font-size: 11px; }

.composer-area { position: relative; z-index: 5; flex: 0 0 auto; padding: 0 24px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, white 20%); }
.composer { width: min(100%, 820px); margin: 0 auto; padding: 12px 12px 9px; border: 1px solid #deded9; border-radius: 18px; background: white; box-shadow: 0 8px 28px rgba(27,25,19,.075); transition: .2s; }
.composer:focus-within { border-color: #cbc8df; box-shadow: 0 9px 32px rgba(43,36,96,.1); }
.composer.dragging { border-color: var(--accent); background: #faf9ff; }
.composer textarea { display: block; width: 100%; max-height: 180px; padding: 2px 5px 8px; resize: none; border: 0; outline: 0; color: #25241f; background: transparent; font-size: 14px; line-height: 1.55; }
.composer textarea::placeholder { color: #aaa9a3; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.composer-tool { display: flex; align-items: center; height: 30px; padding: 0 7px; gap: 5px; border: 0; border-radius: 8px; color: #77766f; background: transparent; font-size: 10px; cursor: pointer; }
.composer-tool:hover { background: #f3f3ef; }
.composer-tool svg { width: 17px; height: 17px; }
.search-chip { display: flex; align-items: center; height: 27px; padding: 0 8px; gap: 5px; border: 1px solid #dbece3; border-radius: 8px; color: #438565; background: #f3fbf7; font-size: 10px; }
.search-chip svg { width: 14px; height: 14px; }
.send-button { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 10px; color: white; background: #28272c; cursor: pointer; transition: .2s; }
.send-button:hover { background: var(--accent); }
.send-button:disabled { color: #a7a6a0; background: #e9e9e5; cursor: default; }
.send-button svg { width: 17px; height: 17px; }
.send-button .stop-icon { display: none; width: 15px; height: 15px; }
.send-button.streaming .send-icon { display: none; }
.send-button.streaming .stop-icon { display: block; }
.composer-note { margin: 8px 0 0; color: #aaa9a4; font-size: 9px; text-align: center; }
.upload-list { display: flex; width: min(100%, 820px); margin: 0 auto 7px; overflow-x: auto; gap: 7px; }
.upload-item { display: flex; align-items: center; flex: 0 0 auto; max-width: 260px; height: 38px; padding: 0 8px 0 10px; gap: 7px; border: 1px solid #dfded8; border-radius: 10px; background: white; box-shadow: 0 3px 10px rgba(0,0,0,.04); }
.upload-item > svg { flex: 0 0 17px; width: 17px; height: 17px; color: #7568cf; }
.upload-details { display: flex; min-width: 0; flex-direction: column; }
.upload-details strong { overflow: hidden; font-size: 10px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.upload-details small { color: #999892; font-size: 8px; }
.upload-remove { width: 24px; height: 24px; color: #96958f; }
.upload-remove svg { width: 13px; height: 13px; }
.upload-progress { width: 44px; height: 3px; overflow: hidden; border-radius: 2px; background: #e7e5f3; }
.upload-progress::after { content: ""; display: block; width: 45%; height: 100%; background: var(--accent); animation: upload 1s infinite alternate ease-in-out; }
@keyframes upload { to { transform: translateX(120%); } }

.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: min(350px, calc(100vw - 32px)); padding: 11px 15px; border: 1px solid #e0dfd9; border-radius: 11px; color: #484741; background: rgba(255,255,255,.96); box-shadow: var(--shadow); font-size: 12px; animation: toast-in .22s ease-out; }
.toast.error { border-color: #f0d0d0; color: #a63f3f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.sidebar-overlay { display: none; }

@media (max-width: 760px) {
  .mobile-only { display: grid !important; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: 18px 0 50px rgba(0,0,0,.13);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; z-index: 15; inset: 0; background: rgba(21,20,24,.28); backdrop-filter: blur(2px); }
  .sidebar-overlay.open { display: block; }
  .chat-header { flex-basis: 64px; padding: 0 14px; }
  .header-left h2 { max-width: 150px; }
  .context-tools { gap: 8px; }
  .char-count svg { display: none; }
  .compress-button { width: 34px; padding: 0; justify-content: center; }
  .compress-button span { display: none; }
  .welcome { width: min(100% - 28px, 550px); padding-top: 48px; }
  .studio-panel { width: calc(100% - 24px); padding-top: 24px; }
  .studio-form { padding: 15px; border-radius: 15px; }
  .studio-field-row { align-items: stretch; flex-direction: column; }
  .voice-picker-row { align-items: stretch; flex-direction: column; }
  .voice-refresh-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .audio-review { grid-template-columns: 1fr; }
  .audio-review small { grid-column: 1; }
  .clone-field-grid { grid-template-columns: 1fr; }
  .studio-upload-button { width: 100%; }
  .studio-status { display: block; margin: 9px 0 0; }
  .suggestions { grid-template-columns: 1fr; margin-top: 30px; }
  .suggestion { min-height: 72px; }
  .messages { width: calc(100% - 26px); padding-top: 26px; }
  .message { gap: 9px; margin-bottom: 23px; }
  .message-avatar { flex-basis: 27px; width: 27px; height: 27px; border-radius: 9px; }
  .message-content { max-width: calc(100% - 36px); font-size: 13px; }
  .message-body { max-width: calc(100% - 36px); }
  .message.user .message-body { max-width: 88%; }
  .message.user .message-content { max-width: 100%; }
  .message.user .message-content.editing { width: calc(100vw - 26px); min-width: 0; max-width: none; }
  .message-edit-input { font-size: 13px; }
  .composer-area { padding: 0 10px max(8px, env(safe-area-inset-bottom)); }
  .composer { border-radius: 16px; }
  .composer-note { margin-top: 6px; }
  .toast-region { right: 16px; bottom: 16px; }
}

@media (max-width: 430px) {
  .login-card { padding: 38px 24px 26px; }
  .welcome h1 { font-size: 26px; }
  .welcome > p { font-size: 12px; }
  .context-tools { gap: 5px; }
  .char-count { font-size: 10px; }
  .header-left h2 { max-width: 105px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
