:root {
    --bg: #f6f7f8;
    --surface: #ffffff;
    --surface-soft: #f3f4f6;
    --surface-muted: #eceef1;
    --text: #181a1f;
    --text-soft: #5d626d;
    --text-faint: #8a909b;
    --line: #e1e3e7;
    --line-strong: #cfd3da;
    /* 与单轮模式共用的主题绿色层级 */
    --accent: #0b5345;
    --accent-hover: #16a085;
    --accent-soft: #e8f7f3;
    --accent-wash: #f0fdf9;
    --accent-line: #bfe3dc;
    --success: #16a085;
    --danger: #c74343;
    --warning: #9a6b13;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --sidebar-width: 330px;
    --content-width: 920px;
    font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a,
select {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-app {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.chat-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    padding: 18px 14px 14px;
    background: #eff1f3;
    border-right: 1px solid var(--line);
    z-index: 30;
}

.sidebar-mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    color: white;
    background: linear-gradient(135deg, #0b5345 0%, #16a085 100%);
}

.sidebar-mode-title {
    min-width: 0;
    flex: 1;
}

.sidebar-mode-title h1 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: white;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}

.sidebar-mode-title p {
    margin: 2px 0 0;
    color: rgba(255, 255, 255, .75);
    font-size: .7rem;
    line-height: 1.3;
}

.sidebar-version {
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    background: rgba(255, 255, 255, .2);
    font-size: 9px;
    font-weight: 500;
}

.sidebar-mode-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.sidebar-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 7px;
    color: rgba(255, 255, 255, .92);
    background: rgba(255, 255, 255, .1);
    text-decoration: none;
    font-size: 11px;
    white-space: nowrap;
}

.sidebar-mode-switch:hover,
.sidebar-settings-btn:hover,
.sidebar-header-close:hover {
    color: white;
    background: rgba(255, 255, 255, .2);
}

.sidebar-mode-switch svg {
    width: 16px;
    height: 16px;
}

.sidebar-settings-btn,
.sidebar-header-close {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    color: rgba(255, 255, 255, .88);
    background: rgba(255, 255, 255, .1);
    cursor: pointer;
}

.sidebar-settings-btn svg,
.sidebar-header-close svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.sidebar-brand,
.brand-mark,
.chat-header,
.chat-header-left,
.chat-header-actions,
.composer-toolbar,
.composer-tools,
.sidebar-footer,
.session-card-top,
.session-card-bottom,
.message-meta,
.assistant-status,
.message-actions,
.turn-detail {
    display: flex;
    align-items: center;
}

.sidebar-brand {
    justify-content: space-between;
    min-height: 42px;
    padding: 0 5px 13px;
}

.brand-mark {
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.brand-logo {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: white;
    background: var(--accent);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
}

.brand-mark strong,
.brand-mark small {
    display: block;
}

.brand-mark strong {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.brand-mark small {
    margin-top: 3px;
    color: var(--text-faint);
    font-size: 11px;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
}

.icon-btn:hover {
    background: var(--surface-muted);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.sidebar-close,
.sidebar-open {
    display: none;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    flex: 0 0 auto;
    margin-top: 12px;
    border: 1px solid var(--accent);
    border-radius: 11px;
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    cursor: pointer;
    font-weight: 500;
}

.new-chat-btn:hover {
    border-color: var(--accent-hover);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
}

.new-chat-btn svg {
    width: 17px;
    height: 17px;
}

.session-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    margin: 14px 0 12px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, .62);
}

.session-search:focus-within {
    border-color: var(--line-strong);
    background: white;
}

.session-search svg {
    width: 16px;
    height: 16px;
    color: var(--text-faint);
}

.session-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.session-search input::placeholder {
    color: var(--text-faint);
}

.session-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 7px 8px;
    color: var(--text-faint);
    font-size: 11px;
    letter-spacing: .02em;
}

.session-list-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.clear-sessions-btn {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-faint);
    background: transparent;
    cursor: pointer;
}

.clear-sessions-btn:hover:not(:disabled) {
    border-color: #efcaca;
    color: var(--danger);
    background: #fff5f5;
}

.clear-sessions-btn:disabled {
    opacity: .35;
    cursor: default;
}

.clear-sessions-btn svg {
    width: 14px;
    height: 14px;
}

.session-list {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

.session-list-empty {
    padding: 28px 12px;
    color: var(--text-faint);
    text-align: center;
    font-size: 12px;
}

.session-card-shell {
    position: relative;
    width: 100%;
    margin: 2px 0;
    border-radius: 11px;
}

.session-card {
    position: relative;
    width: 100%;
    padding: 10px;
    padding-right: 38px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.session-card:hover {
    background: rgba(255, 255, 255, .7);
}

.session-card.is-active {
    border-color: var(--line-strong);
    background: white;
}

.session-menu-toggle {
    position: absolute;
    top: 8px;
    right: 7px;
    z-index: 2;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-faint);
    background: transparent;
    cursor: pointer;
    opacity: 0;
}

.session-card-shell:hover .session-menu-toggle,
.session-card-shell.is-active .session-menu-toggle,
.session-menu-toggle[aria-expanded="true"],
.session-menu-toggle:focus-visible {
    opacity: 1;
}

.session-menu-toggle:hover,
.session-menu-toggle[aria-expanded="true"] {
    border-color: var(--line);
    color: var(--text-soft);
    background: var(--surface-soft);
}

.session-menu-toggle svg {
    width: 17px;
    height: 17px;
    stroke-width: 2;
}

.session-card-menu {
    position: absolute;
    top: 36px;
    right: 7px;
    z-index: 12;
    width: 154px;
    padding: 5px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: white;
}

.session-card-menu.opens-up {
    top: auto;
    bottom: 36px;
}

.session-card-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    padding: 0 9px;
    border: 0;
    border-radius: 6px;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-size: 11px;
}

.session-card-menu button:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-soft);
}

.session-card-menu button.is-danger {
    color: var(--danger);
}

.session-card-menu button.is-danger:hover:not(:disabled) {
    background: #fff3f3;
}

.session-card-menu button:disabled {
    color: var(--text-faint);
    cursor: not-allowed;
    opacity: .55;
}

.session-card-menu svg {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
}

.session-card-top {
    gap: 9px;
}

.session-cover {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-muted);
}

.session-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.session-cover.is-empty {
    display: grid;
    place-items: center;
    color: var(--text-faint);
}

.session-cover.is-empty svg {
    width: 19px;
    height: 19px;
}

.session-card-copy {
    min-width: 0;
    flex: 1;
}

.session-title {
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-subtitle {
    margin-top: 5px;
    overflow: hidden;
    color: var(--text-faint);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-card-bottom {
    justify-content: space-between;
    margin-top: 8px;
    color: var(--text-faint);
    font-size: 10px;
}

.session-state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.session-state::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #9aa0aa;
}

.session-state.is-running::before {
    background: var(--accent);
}

.session-state.is-failed::before {
    background: var(--danger);
}

.session-state.is-interrupted::before {
    background: var(--warning);
}

.sidebar-footer {
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 5px 0;
    border-top: 1px solid var(--line);
    color: var(--text-faint);
    font-size: 10px;
}

.back-generator-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 12px;
}

.back-generator-link:hover {
    color: var(--text);
}

.back-generator-link svg {
    width: 15px;
    height: 15px;
}

.app-version {
    color: var(--text-faint);
    font-size: 10px;
}

.sidebar-backdrop {
    display: none;
}

.chat-main {
    display: grid;
    grid-template-rows: 68px minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: var(--surface);
}

.chat-header {
    justify-content: space-between;
    min-width: 0;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
}

.chat-header-left {
    min-width: 0;
    gap: 10px;
}

.conversation-heading {
    min-width: 0;
}

.conversation-heading h1 {
    max-width: 520px;
    margin: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 550;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
    color: var(--text-faint);
    font-size: 10px;
}

.conversation-meta span + span::before {
    content: "·";
    margin-right: 7px;
}

.chat-header-actions {
    gap: 8px;
}

.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text-soft);
    font-size: 11px;
}

.connection-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.connection-badge.is-busy .connection-dot {
    background: var(--accent);
    animation: pulse 1.3s ease-in-out infinite;
}

.connection-badge.is-error .connection-dot {
    background: var(--danger);
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: white;
    cursor: pointer;
    font-size: 12px;
}

.header-btn:hover {
    background: var(--surface-soft);
}

.header-btn svg {
    width: 15px;
    height: 15px;
}

.chat-viewport {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    background: var(--surface);
}

.welcome-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 690px;
    min-height: 100%;
    margin: 0 auto;
    padding: 52px 24px 80px;
    text-align: center;
}

.welcome-symbol {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 20px;
    border: 1px solid var(--line-strong);
    border-radius: 15px;
    color: #353941;
    background: var(--surface-soft);
}

.welcome-symbol svg {
    width: 25px;
    height: 25px;
}

.welcome-eyebrow {
    margin: 0 0 9px;
    color: var(--text-faint);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.welcome-panel h2 {
    max-width: 580px;
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 520;
    letter-spacing: -.035em;
    line-height: 1.22;
}

.welcome-copy {
    max-width: 570px;
    margin: 17px 0 25px;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.75;
}

.prompt-suggestions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
}

.prompt-suggestions button {
    min-height: 54px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: white;
    cursor: pointer;
    color: var(--text-soft);
    font-size: 12px;
}

.prompt-suggestions button:hover {
    border-color: var(--line-strong);
    color: var(--text);
    background: var(--surface-soft);
}

.message-list {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: 34px 28px 70px;
}

.turn-block {
    padding: 22px 0 28px;
    border-bottom: 1px solid var(--line);
}

.turn-block:last-child {
    border-bottom: 0;
}

.message {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 13px;
}

.message + .message {
    margin-top: 26px;
}

.message-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text-soft);
    background: var(--surface-soft);
    font-size: 10px;
    font-weight: 600;
}

.message.is-assistant .message-avatar {
    color: white;
    background: var(--accent);
    border-color: var(--accent);
}

.message-content {
    min-width: 0;
    padding-top: 3px;
}

.message-meta {
    gap: 8px;
    min-height: 21px;
    margin-bottom: 8px;
}

.message-author {
    font-size: 12px;
    font-weight: 600;
}

.message-time,
.turn-index {
    color: var(--text-faint);
    font-size: 10px;
}

.message-text {
    color: #2d3037;
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.user-reference-grid,
.assistant-image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 280px));
    gap: 9px;
    margin-top: 13px;
}

.user-reference-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 118px));
}

.message-image {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.assistant-image-grid .message-image {
    aspect-ratio: 1 / 1;
    max-width: 280px;
}

.user-reference-grid .message-image {
    aspect-ratio: 1 / 1;
}

.message-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    cursor: zoom-in;
}

.image-actions {
    position: absolute;
    right: 7px;
    bottom: 7px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity .16s ease;
}

.message-image:hover .image-actions {
    opacity: 1;
}

.image-action {
    display: grid;
    place-items: center;
    width: 31px;
    height: 31px;
    border: 1px solid rgba(255, 255, 255, .32);
    border-radius: 8px;
    color: white;
    background: rgba(20, 22, 27, .78);
    cursor: pointer;
    backdrop-filter: blur(6px);
}

.image-action svg {
    width: 15px;
    height: 15px;
}

.assistant-status {
    gap: 9px;
    min-height: 30px;
    color: var(--text-soft);
    font-size: 12px;
}

.stream-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.stream-indicator i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    animation: streamDot 1.15s infinite ease-in-out;
}

.stream-indicator i:nth-child(2) { animation-delay: .15s; }
.stream-indicator i:nth-child(3) { animation-delay: .3s; }

.assistant-status.is-error {
    color: var(--danger);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

.assistant-status.is-complete {
    color: var(--text-faint);
}

.message-actions {
    gap: 7px;
    margin-top: 12px;
}

.message-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-soft);
    background: white;
    cursor: pointer;
    font-size: 11px;
}

.message-action-btn:hover {
    color: var(--text);
    background: var(--surface-soft);
}

.message-action-btn.is-primary {
    border-color: var(--accent);
    color: white;
    background: var(--accent);
}

.message-action-btn.is-primary:hover {
    border-color: var(--accent-hover);
    color: white;
    background: var(--accent-hover);
}

.message-action-btn svg {
    width: 14px;
    height: 14px;
}

.message-action-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-soft);
    background: white;
    cursor: pointer;
}

.message-action-icon-btn:hover {
    color: var(--text);
    background: var(--surface-soft);
}

.message-action-icon-btn svg {
    width: 14px;
    height: 14px;
}

.turn-detail {
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 12px;
    color: var(--text-faint);
    font-size: 10px;
}

.turn-detail span {
    display: inline-flex;
    align-items: center;
    min-height: 23px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-soft);
}

.turn-editor {
    margin-top: 13px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-soft);
}

.turn-editor textarea {
    display: block;
    width: 100%;
    min-height: 84px;
    max-height: 180px;
    resize: vertical;
    padding: 8px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    outline: none;
    color: var(--text);
    background: white;
    font: inherit;
    font-size: 13px;
    line-height: 1.65;
}

.turn-editor textarea:focus {
    border-color: #aeb5c0;
}

.turn-editor-params {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.turn-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 9px;
}

.turn-editor-param-control {
    flex: 0 0 auto;
}

.turn-editor-references {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 7px;
    padding-left: 10px;
    border-left: 1px solid var(--line);
    color: var(--text-soft);
    font-size: 11px;
}

.turn-editor-reference-label {
    flex: 0 0 auto;
    color: var(--text-faint);
    white-space: nowrap;
}

.turn-editor-add-reference {
    flex: 0 0 auto;
    min-height: 34px;
    white-space: nowrap;
}

.turn-editor-reference-grid {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.turn-editor-reference-item {
    position: relative;
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.turn-editor-reference-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.turn-editor-reference-item button {
    position: absolute;
    top: 3px;
    right: 3px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 6px;
    color: white;
    background: rgba(20, 22, 27, .76);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

.turn-editor-note {
    min-width: 0;
    margin: 0;
    color: var(--text-faint);
    font-size: 10px;
    line-height: 1.55;
}

.turn-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
}

.turn-editor-actions,
.turn-variant-pager {
    display: flex;
    align-items: center;
}

.turn-editor-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 7px;
}

.turn-variant-pager {
    gap: 7px;
    margin-top: 12px;
    color: var(--text-faint);
    font-size: 10px;
}

.variant-nav-btn {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text-soft);
    background: white;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
}

.variant-nav-btn:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-soft);
}

.variant-nav-btn:disabled {
    opacity: .4;
    cursor: default;
}

.variant-index {
    min-width: 62px;
    text-align: center;
}

.composer-shell {
    position: relative;
    z-index: 12;
    padding: 10px 24px 15px;
    border-top: 1px solid rgba(225, 227, 231, .84);
    background: rgba(255, 255, 255, .96);
}

.composer,
.reference-strip,
.composer-footnote {
    width: min(100%, var(--content-width));
    margin: 0 auto;
}

.reference-strip {
    display: flex;
    gap: 7px;
    padding: 0 1px 8px;
    overflow-x: auto;
}

.reference-item {
    position: relative;
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface-soft);
}

.reference-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.reference-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    display: grid;
    place-items: center;
    width: 19px;
    height: 19px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    color: white;
    background: rgba(20, 22, 27, .76);
    cursor: pointer;
    font-size: 13px;
}

.composer {
    padding: 9px 10px 9px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 15px;
    background: white;
}

.composer:focus-within {
    border-color: #aeb5c0;
}

.composer textarea {
    display: block;
    width: 100%;
    max-height: 160px;
    min-height: 31px;
    resize: none;
    padding: 5px 3px 7px;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    font-size: 14px;
    line-height: 1.55;
}

.composer textarea::placeholder {
    color: #999faa;
}

.composer-toolbar {
    justify-content: space-between;
    gap: 10px;
}

.composer-tools {
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-btn,
.compact-select-wrap {
    display: inline-flex;
    align-items: center;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-soft);
    background: var(--surface-soft);
    font-size: 11px;
}

.tool-btn {
    gap: 6px;
    padding: 0 9px;
    cursor: pointer;
}

.tool-btn:hover {
    color: var(--text);
    border-color: var(--line-strong);
}

.translate-prompt-btn {
    color: var(--accent);
    border-color: var(--accent-line);
    background: var(--accent-wash);
}

.translate-prompt-btn:hover {
    color: var(--accent);
    border-color: var(--accent-hover);
    background: var(--accent-soft);
}

.translate-prompt-btn:disabled {
    opacity: .58;
    cursor: not-allowed;
}

.translate-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(11, 83, 69, .2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.translate-spinner[hidden] {
    display: none;
}

.prompt-flash {
    animation: promptFlash .5s ease;
}

@keyframes promptFlash {
    0% { background: rgba(22, 160, 133, .13); }
    100% { background: transparent; }
}

.tool-btn svg {
    width: 14px;
    height: 14px;
}

.compact-select-wrap {
    gap: 4px;
    padding-left: 8px;
}

.compact-select-wrap > span {
    color: var(--text-faint);
}

.compact-select-wrap select {
    max-width: 146px;
    height: 28px;
    padding: 0 20px 0 2px;
    border: 0;
    outline: 0;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    font-size: 11px;
}

.compact-select-wrap select:disabled {
    opacity: .72;
    cursor: not-allowed;
}

.compact-select-wrap .native-select-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.chat-custom-select {
    position: relative;
    min-width: 70px;
    height: 28px;
}

.chat-custom-select.is-model {
    min-width: 148px;
}

.chat-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    height: 28px;
    padding: 0 5px 0 2px;
    border: 0;
    outline: 0;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    font-size: 11px;
}

.chat-select-trigger:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.chat-select-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-select-arrow {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
    color: var(--text-faint);
    transition: transform .16s ease;
}

.chat-custom-select.is-open .chat-select-arrow {
    color: var(--accent);
    transform: rotate(180deg);
}

.compact-select-wrap:focus-within,
.compact-select-wrap:has(.chat-custom-select.is-open) {
    border-color: var(--accent-hover);
    background: white;
}

.chat-select-menu {
    position: absolute;
    right: -6px;
    bottom: calc(100% + 7px);
    z-index: 80;
    display: none;
    width: max(100%, 118px);
    max-height: 224px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: white;
}

.chat-custom-select.is-model .chat-select-menu {
    width: max(100%, 220px);
}

.chat-custom-select.is-open .chat-select-menu {
    display: block;
}

.chat-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    border: 0;
    border-radius: 7px;
    color: var(--text-soft);
    background: white;
    cursor: pointer;
    text-align: left;
    font-size: 11px;
}

.chat-select-option:hover:not(:disabled),
.chat-select-option:focus-visible {
    outline: none;
    color: var(--accent);
    background: var(--accent-wash);
}

.chat-select-divider {
    height: 1px;
    margin: 5px 4px;
    background: var(--line);
}

.custom-model-modal-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(5px);
}

.custom-model-modal-content {
    position: relative;
    z-index: 1;
    width: min(430px, 100%);
    max-width: calc(100vw - 32px);
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: white;
    animation: settingsModalShow .2s ease;
}

.custom-model-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
}

.field-optional {
    color: var(--text-faint);
    font-size: .72rem;
    font-weight: 400;
}

.custom-model-billing {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.custom-model-billing legend {
    margin-bottom: 7px;
    color: #475569;
    font-size: .82rem;
    font-weight: 600;
}

.custom-model-billing-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.custom-model-billing-options label {
    cursor: pointer;
}

.custom-model-billing-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.custom-model-billing-options span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-soft);
    background: white;
    font-size: .82rem;
}

.custom-model-billing-options input:checked + span {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-wash);
}

.custom-model-billing-options input:focus-visible + span {
    outline: 2px solid var(--accent-line);
    outline-offset: 2px;
}

.chat-select-add {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    border: 0;
    border-radius: 7px;
    color: var(--accent);
    background: white;
    cursor: pointer;
    text-align: left;
    font-size: 11px;
}

.chat-select-add:hover,
.chat-select-add:focus-visible {
    outline: none;
    background: var(--accent-wash);
}

.chat-select-add > span:first-child {
    font-size: 15px;
    line-height: 1;
}

.chat-select-option-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    align-items: center;
    gap: 2px;
}

.chat-select-remove {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    color: var(--text-faint);
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.chat-select-remove:hover,
.chat-select-remove:focus-visible {
    outline: none;
    color: var(--danger);
    background: #fff1f1;
}

.chat-select-option[aria-selected="true"] {
    color: var(--accent);
    background: var(--accent-soft);
}

.chat-select-option:disabled {
    color: var(--text-faint);
    background: var(--surface-soft);
    cursor: not-allowed;
}

.chat-select-check {
    color: var(--accent);
    opacity: 0;
}

.chat-select-option[aria-selected="true"] .chat-select-check {
    opacity: 1;
}

.send-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: white;
    background: var(--accent);
    cursor: pointer;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn:disabled {
    color: #9da2ac;
    background: var(--surface-muted);
    cursor: not-allowed;
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.send-btn .send-spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid rgba(255, 255, 255, .36);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.send-btn.is-stopping .send-icon {
    display: none;
}

.send-btn.is-stopping .send-spinner {
    display: block;
}

.composer-footnote {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 4px 0;
    color: var(--text-faint);
    font-size: 9px;
}

.modal-layer[hidden],
.image-viewer[hidden] {
    display: none;
}

.modal-layer,
.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.modal-backdrop,
.viewer-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(22, 24, 29, .46);
}

.session-confirm-card {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    width: min(90vw, 420px);
    padding: 20px;
    transform: translate(-50%, -50%);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: white;
}

.session-confirm-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    color: var(--danger);
    background: #fff1f1;
}

.session-confirm-icon svg {
    width: 19px;
    height: 19px;
}

.session-confirm-copy {
    min-width: 0;
}

.session-confirm-copy h2 {
    margin: 1px 0 7px;
    color: var(--text);
    font-size: 15px;
    font-weight: 550;
}

.session-confirm-copy p {
    margin: 0;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.6;
}

.session-confirm-detail {
    margin-top: 5px !important;
    color: var(--text-faint) !important;
    font-size: 10px !important;
}

.session-confirm-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 5px;
}

.session-confirm-actions button {
    min-width: 76px;
    height: 34px;
    padding: 0 13px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
}

.session-confirm-cancel {
    border: 1px solid var(--line-strong);
    color: var(--text-soft);
    background: white;
}

.session-confirm-submit {
    border: 1px solid var(--danger);
    color: white;
    background: var(--danger);
}

.session-confirm-actions button:disabled {
    opacity: .55;
    cursor: wait;
}

.settings-card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(92vw, 470px);
    overflow: hidden;
    transform: translate(-50%, -50%);
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: white;
}

.settings-card > header,
.settings-card > footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 17px 20px;
}

.settings-card > header {
    border-bottom: 1px solid var(--line);
}

.settings-card > header h2 {
    margin: 4px 0 0;
    font-size: 17px;
    font-weight: 550;
}

.settings-eyebrow {
    color: var(--text-faint);
    font-size: 10px;
    letter-spacing: .06em;
}

.settings-body {
    padding: 20px;
}

.field-label {
    display: block;
    margin: 0 0 7px;
    color: var(--text-soft);
    font-size: 11px;
}

.field-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    outline: 0;
    color: var(--text);
    background: white;
}

.field-input:focus {
    border-color: #9aa3b2;
}

.field-help {
    margin: 6px 0 17px;
    color: var(--text-faint);
    font-size: 10px;
    line-height: 1.5;
}

.password-field {
    position: relative;
}

.password-field .field-input {
    padding-right: 60px;
}

.password-field button {
    position: absolute;
    top: 6px;
    right: 6px;
    height: 30px;
    padding: 0 9px;
    border: 0;
    border-radius: 7px;
    color: var(--text-soft);
    background: var(--surface-soft);
    cursor: pointer;
    font-size: 11px;
}

.settings-card > footer {
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--line);
    background: var(--surface-soft);
}

.primary-btn,
.secondary-btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 12px;
}

.primary-btn {
    border: 1px solid var(--accent);
    color: white;
    background: var(--accent);
}

.secondary-btn {
    border: 1px solid var(--line-strong);
    color: var(--text-soft);
    background: white;
}

/* Settings modal mirrors the single-turn mode component. */
.settings-modal-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(5px);
}

.settings-modal-backdrop {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.settings-modal-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(440px, 100%);
    max-width: calc(100vw - 32px);
    max-height: min(90vh, 700px);
    overflow: hidden;
    border-radius: 10px;
    background: white;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
    animation: settingsModalShow .3s ease;
}

@keyframes settingsModalShow {
    from { opacity: 0; transform: translateY(-50px) scale(.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 16px 20px;
    color: white;
    background: linear-gradient(135deg, #0b5345 0%, #16a085 100%);
}

.settings-modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.settings-modal-header h3 svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    stroke-width: 2;
}

.settings-modal-close {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    color: rgba(255, 255, 255, .8);
    background: transparent;
    cursor: pointer;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.settings-modal-close:hover {
    color: white;
}

.settings-modal-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
}

.settings-section {
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid #e8ebef;
    border-radius: 10px;
    background: #f8f9fb;
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid #e8ebef;
    background: white;
}

.settings-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b5345;
}

.settings-section-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.settings-section-title {
    flex: 1;
    color: #374151;
    font-size: .9rem;
    font-weight: 600;
}

.settings-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    cursor: pointer;
    font-size: .8rem;
}

.settings-toggle input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #0b5345;
    cursor: pointer;
}

.settings-section-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
}

.settings-section-body.disabled {
    opacity: .5;
    pointer-events: none;
}

.settings-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-row label {
    color: #475569;
    font-size: .82rem;
    font-weight: 600;
}

.settings-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    outline: none;
    color: #1e293b;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    font-size: .92rem;
    font-weight: 500;
    letter-spacing: -.01em;
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

.settings-input:hover {
    border-color: #cbd5e1;
    background: linear-gradient(180deg, #fff 0%, #f1f5f9 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .06);
}

.settings-input:focus {
    border-color: #0b5345;
    background: linear-gradient(180deg, #fff 0%, #f0fdf9 100%);
    box-shadow: 0 0 0 3px rgba(11, 83, 69, .12), 0 2px 4px rgba(0, 0, 0, .06);
}

.settings-input::placeholder {
    color: #94a3b8;
}

.settings-input-group {
    display: flex;
    gap: 8px;
}

.settings-input-group .settings-input {
    min-width: 0;
    flex: 1;
}

.settings-link-btn {
    padding: 9px 14px;
    border: 1px solid #0b5345;
    border-radius: 6px;
    color: #0b5345;
    background: transparent;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all .2s ease;
}

.settings-link-btn:hover {
    color: white;
    background: #0b5345;
}

.settings-hint {
    margin: 0;
    color: #9ca3af;
    font-size: .75rem;
    line-height: 1.4;
}

.settings-key-preference {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 24px;
}

.settings-memory-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #64748b;
    cursor: pointer;
    font-size: .78rem;
    user-select: none;
}

.settings-memory-toggle input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #0b5345;
    cursor: pointer;
}

.settings-clear-key-btn {
    padding: 2px 0;
    border: 0;
    color: #64748b;
    background: transparent;
    cursor: pointer;
    font-size: .75rem;
}

.settings-clear-key-btn:hover {
    color: #0b5345;
}

.settings-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
    padding: 14px 16px;
    border-top: 1px solid #e8ebef;
    background: #f8f9fb;
}

.settings-btn-primary,
.settings-btn-secondary {
    padding: 9px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
    transition: all .2s ease;
}

.settings-btn-primary {
    border: 0;
    color: white;
    background: linear-gradient(135deg, #0b5345 0%, #16a085 100%);
    font-weight: 600;
}

.settings-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 83, 69, .3);
}

.settings-btn-secondary {
    border: 1px solid #d1d5db;
    color: #6b7280;
    background: white;
    font-weight: 500;
}

.settings-btn-secondary:hover {
    color: #374151;
    background: #f3f4f6;
}

@media (max-width: 480px) {
    .settings-modal-content { max-height: 90vh; }
    .settings-modal-header { padding: 14px 16px; }
    .settings-modal-header h3 { font-size: .95rem; }
    .settings-modal-body { gap: 10px; padding: 12px; }
    .settings-section-header { padding: 10px 12px; }
    .settings-section-body { padding: 10px 12px; }
    .settings-row .settings-input { padding: 8px 10px; font-size: .85rem; }
    .settings-modal-footer { padding: 12px; }
    .settings-btn-primary,
    .settings-btn-secondary { padding: 8px 16px; font-size: .85rem; }
}

.image-viewer {
    display: grid;
    place-items: center;
    padding: 48px;
    overflow: hidden;
    touch-action: none;
}

.image-viewer img {
    position: relative;
    z-index: 1;
    max-width: min(94vw, 1400px);
    max-height: 88vh;
    border-radius: 12px;
    object-fit: contain;
    cursor: zoom-in;
    transform-origin: center;
    transition: transform .12s ease-out;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

.image-viewer img.is-zoomed {
    cursor: grab;
    transition: none;
}

.image-viewer img.is-dragging {
    cursor: grabbing;
}

.viewer-zoom-hint {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 9px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 7px;
    color: rgba(255, 255, 255, .78);
    background: rgba(20, 22, 27, .66);
    font-size: 11px;
    pointer-events: none;
}

.viewer-zoom-hint strong {
    min-width: 34px;
    color: white;
    font-weight: 500;
    text-align: right;
}

.viewer-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    color: white;
    background: rgba(20, 22, 27, .72);
}

.toast-region {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    left: 50%;
    right: auto;
    bottom: auto;
    z-index: 150;
    display: grid;
    width: min(360px, calc(100vw - 32px));
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    padding: 11px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--text);
    background: white;
    font-size: 12px;
    line-height: 1.5;
    pointer-events: auto;
    animation: toastIn .18s ease-out;
}

.toast.is-error {
    border-color: #e4bcbc;
    color: #8e2e2e;
    background: #fff8f8;
}

.toast.is-success {
    border-color: #b9ddcd;
    color: #176643;
    background: #f6fcf9;
}

@keyframes pulse {
    0%, 100% { opacity: .38; }
    50% { opacity: 1; }
}

@keyframes streamDot {
    0%, 70%, 100% { transform: translateY(0); opacity: .35; }
    35% { transform: translateY(-3px); opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 901px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar-mode-header {
        gap: 6px;
        padding: 10px 12px;
    }

    .sidebar-mode-title h1 {
        gap: 4px;
        font-size: 14px;
    }

    .sidebar-version {
        padding: 2px 4px;
        font-size: 8px;
    }

    .sidebar-mode-actions {
        gap: 4px;
    }

    .sidebar-mode-switch {
        gap: 0;
        padding: 0 7px;
        font-size: 10px;
    }

    .sidebar-mode-switch svg {
        display: none;
    }
}

@media (max-height: 800px) {
    .sidebar-mode-header {
        padding: 10px 12px;
    }

    .sidebar-mode-title h1 {
        font-size: .95rem;
    }

    .sidebar-mode-title p {
        font-size: .65rem;
    }
}

@media (max-height: 750px) and (min-width: 901px) and (max-width: 1400px) {
    :root {
        --sidebar-width: 300px;
    }
}

@media (max-height: 650px) and (min-width: 901px) and (max-width: 1400px) {
    :root {
        --sidebar-width: 280px;
    }
}

@media (max-height: 700px) {
    .sidebar-mode-header {
        padding: 8px 10px;
    }

    .sidebar-mode-title h1 {
        font-size: .9rem;
    }

    .sidebar-mode-title p {
        font-size: .6rem;
        line-height: 1.2;
    }

    .sidebar-version {
        padding: 2px 4px;
        font-size: .55rem;
    }
}

@media (max-height: 600px) {
    .sidebar-mode-header {
        padding: 6px 8px;
    }

    .sidebar-mode-title h1 {
        font-size: .85rem;
    }

    .sidebar-mode-title p {
        display: none;
    }
}

@media (max-width: 900px) {
    .chat-app {
        display: block;
    }

    .chat-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(86vw, var(--sidebar-width));
        transform: translateX(-102%);
        transition: transform .2s ease;
    }

    .sidebar-mode-header {
        padding: 12px;
    }

    .sidebar-mode-title p {
        font-size: 9px;
    }

    body.is-sidebar-open .chat-sidebar {
        transform: translateX(0);
    }

    .sidebar-close,
    .sidebar-open {
        display: inline-grid;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 25;
        border: 0;
        background: rgba(22, 24, 29, .38);
    }

    body.is-sidebar-open .sidebar-backdrop {
        display: block;
    }

    .chat-main {
        width: 100%;
    }
}

@media (max-width: 680px) {
    .chat-main {
        grid-template-rows: 60px minmax(0, 1fr) auto;
    }

    .chat-header {
        padding: 0 12px;
    }

    .connection-badge,
    .header-btn span {
        display: none;
    }

    .header-btn {
        width: 36px;
        justify-content: center;
        padding: 0;
    }

    .message-list {
        padding: 18px 15px 44px;
    }

    .message {
        grid-template-columns: 27px minmax(0, 1fr);
        gap: 9px;
    }

    .message-avatar {
        width: 27px;
        height: 27px;
        border-radius: 8px;
    }

    .assistant-image-grid {
        grid-template-columns: 1fr;
    }

    .assistant-image-grid .message-image {
        max-width: 100%;
    }

    .turn-editor {
        padding: 9px;
    }

    .turn-editor-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .turn-editor-params {
        flex-wrap: nowrap;
    }

    .turn-editor-param-control {
        flex: 1;
        min-width: 0;
    }

    .turn-editor-param-control .chat-custom-select {
        flex: 1;
        min-width: 0;
    }

    .turn-editor-references {
        width: 100%;
        padding: 0;
        border-left: 0;
    }

    .turn-editor-reference-item {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    .turn-editor-footer {
        align-items: flex-end;
        flex-direction: column;
        gap: 8px;
    }

    .turn-editor-note {
        align-self: stretch;
    }

    .prompt-suggestions {
        grid-template-columns: 1fr;
    }

    .composer-shell {
        padding: 8px 10px 9px;
    }

    .compact-select-wrap > span,
    .tool-btn span {
        display: none;
    }

    .compact-select-wrap {
        padding-left: 3px;
    }

    .compact-select-wrap select {
        max-width: 98px;
        padding-left: 4px;
    }

    .composer-footnote span:last-child {
        display: none;
    }

    .image-viewer {
        padding: 42px 10px 20px;
    }
}

/* 桌面端品牌栏与单轮 control-header-compact 使用同一组几何规格。
   多轮仅在移动端保留侧栏抽屉行为，因此不影响移动端布局。 */
@media (min-width: 901px) {
    .sidebar-mode-header {
        gap: 0;
        margin: -10px -5px 14px -6px;
        padding: 12px 14px;
    }

    .sidebar-mode-title h1 {
        line-height: 1.6;
    }
}

@media (min-width: 901px) and (max-height: 800px) {
    .sidebar-mode-header {
        padding: 10px 12px;
    }
}

@media (min-width: 901px) and (max-height: 700px) {
    .sidebar-mode-header {
        padding: 8px 10px;
    }
}

@media (min-width: 901px) and (max-height: 600px) {
    .sidebar-mode-header {
        padding: 6px 8px;
    }
}

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