:root {
    color-scheme: light;
    --bg-main: #f3ede2;
    --bg-panel: rgba(255, 249, 241, 0.76);
    --bg-panel-strong: rgba(255, 253, 248, 0.94);
    --bg-panel-soft: rgba(255, 248, 238, 0.82);
    --text-main: #211f1a;
    --text-soft: #70685c;
    --accent: #b65e43;
    --accent-deep: #8f3824;
    --accent-soft: #f4dbcf;
    --line: rgba(56, 43, 35, 0.1);
    --line-strong: rgba(56, 43, 35, 0.16);
    --shadow-main: 0 30px 80px rgba(73, 48, 34, 0.12);
    --shadow-soft: 0 18px 36px rgba(73, 48, 34, 0.08);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 18px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(182, 94, 67, 0.7) rgba(255, 251, 246, 0.52);
}

html,
body {
    margin: 0;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

body {
    font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at top left, rgba(240, 190, 157, 0.72), transparent 30%),
        radial-gradient(circle at 85% 12%, rgba(222, 201, 149, 0.45), transparent 24%),
        linear-gradient(135deg, #f7f1e7 0%, var(--bg-main) 48%, #eadfce 100%);
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    border-radius: 999px;
    background: rgba(255, 251, 246, 0.52);
}

*::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(201, 114, 84, 0.96), rgba(150, 57, 37, 0.9));
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(177, 80, 54, 0.96), rgba(137, 53, 34, 0.92));
    background-clip: padding-box;
}

*::-webkit-scrollbar-button {
    width: 0;
    height: 0;
    display: none;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

button,
a,
input,
select,
textarea,
summary,
[role="button"],
[tabindex]:not([tabindex="-1"]) {
    -webkit-tap-highlight-color: transparent;
}

body.settings-open {
    overflow: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 380px;
    height: 380px;
    border-radius: 999px;
    filter: blur(76px);
    opacity: 0.42;
    pointer-events: none;
    z-index: 0;
    animation: drift 18s ease-in-out infinite;
}

body::before {
    top: -2rem;
    right: -7rem;
    background: rgba(182, 94, 67, 0.2);
}

body::after {
    bottom: -5rem;
    left: -6rem;
    background: rgba(139, 164, 131, 0.18);
    animation-delay: -7s;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: clamp(300px, 24vw, 344px) minmax(0, 1fr);
    gap: 24px;
    height: 100dvh;
    min-height: 100dvh;
    padding: clamp(16px, 2.6vw, 32px);
    overflow: hidden;
}

.sidebar-panel,
.chat-panel {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--bg-panel);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-main);
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 14px;
    min-height: 0;
    overflow: hidden;
}

.sidebar-panel::before {
    content: "";
    position: absolute;
    inset: -20% auto auto 55%;
    width: 220px;
    height: 220px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(182, 94, 67, 0.18), transparent 68%);
    pointer-events: none;
}

.brand-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.brand-mark {
    width: 62px;
    height: 62px;
    flex: 0 0 62px;
    border-radius: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-copy {
    min-width: 0;
}

.brand-copy h1,
.chat-heading h2 {
    margin: 0;
    line-height: 1.04;
}

.brand-copy h1 {
    font-size: 20px;
    letter-spacing: -0.02em;
}

.sidebar-top {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow: hidden;
}

.conversation-sidebar,
.guest-sidebar-note {
    position: relative;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 24px;
    background: #fffdf8;
    box-shadow: none;
}

.conversation-sidebar {
    display: grid;
    grid-auto-rows: max-content;
    gap: 8px;
    padding: 16px 12px 12px;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    align-content: start;
    align-items: start;
    isolation: isolate;
    scrollbar-gutter: stable;
}

.conversation-sidebar[hidden] {
    display: none;
}

.conversation-sidebar-head {
    display: grid;
    gap: 10px;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1;
    padding-bottom: 8px;
    background: linear-gradient(180deg, rgba(255, 253, 248, 1), rgba(255, 253, 248, 0.94) 82%, rgba(255, 253, 248, 0));
}

.conversation-sidebar-head h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.08;
}

.conversation-sidebar > .conversation-item,
.conversation-sidebar > .conversation-empty {
    width: 100%;
}

.conversation-item {
    position: relative;
    z-index: 0;
    display: block;
    width: 100%;
    padding: 8px 9px;
    border: 1px solid rgba(182, 94, 67, 0.12);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 240, 0.88));
    color: var(--text-main);
    font: inherit;
    text-align: left;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.conversation-item.is-menu-open {
    z-index: 8;
}

.conversation-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.conversation-item-main {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.conversation-item strong,
.conversation-title-input {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-title-text {
    width: 100%;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.conversation-item-actions {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    min-width: 30px;
}

.conversation-item.is-menu-open .conversation-item-actions {
    z-index: 2;
}

.conversation-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    padding: 0;
    border: 1px solid rgba(182, 94, 67, 0.12);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 241, 233, 0.92));
    color: var(--text-soft);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.conversation-icon-button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.conversation-menu-trigger.is-active {
    color: var(--text-main);
    border-color: rgba(182, 94, 67, 0.22);
    background: linear-gradient(180deg, rgba(255, 248, 242, 0.98), rgba(250, 238, 229, 0.94));
}

.conversation-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 4;
    pointer-events: auto;
    display: grid;
    gap: 6px;
    min-width: 148px;
    max-width: min(180px, calc(100vw - 48px));
    padding: 8px;
    border: 1px solid rgba(182, 94, 67, 0.12);
    border-radius: 16px;
    background: rgba(255, 251, 246, 0.98);
    box-shadow: 0 18px 34px rgba(84, 55, 39, 0.16);
}

.conversation-menu[hidden] {
    display: none;
}

.conversation-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: rgba(255, 254, 251, 0.94);
    color: var(--text-main);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.conversation-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    color: var(--text-soft);
}

.conversation-menu-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.conversation-menu-item.is-danger,
.conversation-menu-item.is-danger .conversation-menu-icon {
    color: #a94d38;
}

.conversation-menu-item:hover {
    transform: translateY(-1px);
    border-color: rgba(182, 94, 67, 0.12);
    background: rgba(255, 247, 240, 0.96);
}

.conversation-icon-button.is-danger {
    color: #a94d38;
    background: linear-gradient(180deg, rgba(255, 247, 244, 0.96), rgba(255, 238, 233, 0.92));
    border-color: rgba(169, 77, 56, 0.16);
}

.conversation-icon-button.is-confirm {
    color: #2d7d55;
    background: linear-gradient(180deg, rgba(245, 255, 249, 0.96), rgba(236, 250, 242, 0.92));
    border-color: rgba(45, 125, 85, 0.18);
}

.conversation-icon-button:hover {
    transform: translateY(-1px);
    color: var(--text-main);
}

.conversation-item.is-editing {
    border-color: rgba(182, 94, 67, 0.2);
}

.conversation-title-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    padding: 8px 10px;
    border: 1px solid rgba(182, 94, 67, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    outline: none;
}

.conversation-title-input:focus {
    border-color: rgba(182, 94, 67, 0.42);
    box-shadow: 0 0 0 4px rgba(182, 94, 67, 0.1);
}

.conversation-item.is-active {
    border-color: rgba(182, 94, 67, 0.24);
    background: linear-gradient(145deg, rgba(255, 245, 239, 0.95), rgba(248, 237, 226, 0.92));
}

.conversation-empty,
.guest-sidebar-note {
    padding: 16px 18px;
}

.conversation-empty {
    border: 1px dashed rgba(56, 43, 35, 0.12);
    border-radius: 18px;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.7;
}

.guest-sidebar-note p {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.8;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-deep);
}

.sidebar-actions {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 20px;
    background: rgba(255, 251, 246, 0.88);
    color: var(--text-main);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 999px;
    background: linear-gradient(145deg, #faf3ea, #f2e7da);
    border: 1px solid rgba(56, 43, 35, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.user-avatar svg {
    width: 20px;
    height: 20px;
    fill: #9e8877;
}

.user-avatar img,
.account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.avatar-initials {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #8e6f5f;
}

.user-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
    text-align: left;
}

.user-copy strong,
.user-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-copy strong {
    font-size: 15px;
}

.user-copy small {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 500;
}

.user-caret {
    width: 18px;
    height: 18px;
    margin-left: auto;
    color: #9e8877;
    transition: transform 0.18s ease;
}

.user-caret svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.user-bar[aria-expanded="true"] .user-caret {
    transform: rotate(180deg);
}

.user-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 12px);
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 20px;
    background: rgba(255, 251, 246, 0.96);
    box-shadow: 0 20px 40px rgba(73, 48, 34, 0.16);
    max-height: min(320px, calc(100dvh - 120px));
    overflow-y: auto;
    overscroll-behavior: contain;
    transform-origin: left bottom;
    animation: menuPopoverIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.user-menu[hidden] {
    display: none;
}

.user-menu.is-closing {
    pointer-events: none;
    animation: menuPopoverOut 0.18s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(255, 254, 251, 0.94);
    color: var(--text-main);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.user-menu-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 10px;
    background: rgba(244, 219, 207, 0.38);
    color: var(--accent-deep);
}

.user-menu-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.user-menu-item:hover {
    background: rgba(244, 219, 207, 0.42);
    transform: translateY(-1px);
}

.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-stage {
    --composer-space: 120px;
    position: relative;
    flex: 1;
    min-height: 0;
}

.chat-empty-hero {
    position: absolute;
    left: 50%;
    bottom: calc(50% + 104px);
    z-index: 1;
    display: grid;
    gap: 12px;
    width: min(calc(100% - 48px), 760px);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 24px);
    transition: opacity 0.26s ease, transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-empty-hero strong {
    display: block;
    justify-self: center;
    width: max-content;
    max-width: 100%;
    font-size: var(--empty-hero-title-size, clamp(30px, 4vw, 52px));
    line-height: 1.08;
    letter-spacing: -0.04em;
    white-space: nowrap;
}

.chat-empty-hero span {
    color: rgba(112, 104, 92, 0.92);
    font-size: 16px;
    line-height: 1.7;
}

.chat-panel.is-empty-state .chat-empty-hero {
    opacity: 1;
    transform: translate(-50%, 0);
}

.chat-header {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 251, 246, 0.8), rgba(255, 251, 246, 0.5));
}

.chat-heading h2 {
    font-size: clamp(24px, 3vw, 34px);
}

.mobile-sidebar-button {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    padding: 0;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 14px;
    background: rgba(255, 251, 246, 0.94);
    box-shadow: 0 10px 18px rgba(73, 48, 34, 0.08);
    cursor: pointer;
}

.mobile-sidebar-button span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: #6f6255;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.mobile-sidebar-button span + span {
    margin-top: 4px;
}

.mobile-sidebar-button[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-sidebar-button[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.mobile-sidebar-button[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.sidebar-backdrop {
    display: none;
}

.assistant-badge {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.assistant-avatar {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    overflow: visible;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.assistant-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ghost-button,
.send-button,
.sidebar-primary-button,
.primary-button,
.secondary-button {
    border: 0;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, opacity 0.18s ease;
}

.ghost-button,
.sidebar-primary-button,
.secondary-button {
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 251, 246, 0.88);
    border: 1px solid var(--line);
    color: var(--text-main);
    font-weight: 700;
    font: inherit;
}

.ghost-button {
    border-radius: 999px;
    font-weight: 600;
}

.sidebar-primary-button {
    color: #fffaf7;
    background: linear-gradient(145deg, #be654b, #963925);
    box-shadow: 0 18px 30px rgba(150, 57, 37, 0.22);
}

.primary-button {
    padding: 14px 18px;
    border-radius: 18px;
    background: linear-gradient(145deg, #be654b, #963925);
    color: #fffaf7;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 18px 30px rgba(150, 57, 37, 0.22);
}

.secondary-button {
    min-width: 120px;
}

.message-list {
    height: 100%;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 28px calc(var(--composer-space) + 28px);
    background:
        linear-gradient(180deg, rgba(255, 251, 247, 0.42), rgba(253, 248, 242, 0.68)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
    background-size: auto, 28px 28px;
    transition: padding-bottom 0.3s ease;
}

.chat-panel.is-empty-state .message-list {
    overflow: hidden;
}

.message-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: fit-content;
    max-width: min(100%, clamp(340px, 78%, 980px));
}

.message-row.user {
    align-self: flex-end;
}

.message-row.assistant {
    align-self: flex-start;
}

.message-row.system {
    align-self: center;
    max-width: 100%;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px;
    font-size: 12px;
    color: var(--text-soft);
}

.message-meta time {
    opacity: 0.82;
}

.message {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: 16px 18px;
    border-radius: 24px;
    line-height: 1.75;
    white-space: normal;
    word-break: break-word;
}

.message-content {
    display: grid;
    gap: 0.82em;
}

.message-content > :first-child {
    margin-top: 0;
}

.message-content > :last-child {
    margin-bottom: 0;
}

.message-content--plain {
    white-space: pre-wrap;
}

.message-content p,
.message-content ul,
.message-content ol,
.message-content blockquote,
.message-content pre,
.message-content table,
.message-content hr {
    margin: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0;
    line-height: 1.3;
}

.message-content h1 {
    font-size: 1.34em;
}

.message-content h2 {
    font-size: 1.22em;
}

.message-content h3,
.message-content h4 {
    font-size: 1.08em;
}

.message-content ul,
.message-content ol {
    padding-left: 1.3em;
}

.message-content li + li {
    margin-top: 0.28em;
}

.message-content a {
    color: var(--accent-deep);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.16em;
}

.message.user .message-content a {
    color: #fffaf7;
}

.message-content strong {
    font-weight: 800;
}

.message-content em {
    font-style: italic;
}

.message-content hr {
    height: 1px;
    border: 0;
    background: rgba(56, 43, 35, 0.12);
}

.message-content blockquote {
    padding: 10px 14px;
    border-left: 3px solid rgba(182, 94, 67, 0.32);
    border-radius: 0 14px 14px 0;
    background: rgba(244, 219, 207, 0.24);
    color: var(--text-soft);
}

.message.user .message-content blockquote {
    border-left-color: rgba(255, 244, 238, 0.58);
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 248, 245, 0.92);
}

.message-content :not(pre) > code {
    padding: 0.14em 0.44em;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 999px;
    background: rgba(255, 251, 246, 0.92);
    font-family: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, monospace;
    font-size: 0.94em;
}

.message.user .message-content :not(pre) > code {
    border-color: rgba(255, 244, 238, 0.18);
    background: rgba(255, 255, 255, 0.14);
}

.message-codeblock {
    position: relative;
    display: grid;
    overflow: hidden;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 251, 246, 0.92);
}

.message-codeblock-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(56, 43, 35, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(244, 232, 223, 0.4)),
        rgba(255, 250, 245, 0.92);
}

.message-codeblock-label {
    min-width: 0;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.message-codeblock-copy {
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--text-main);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.message-codeblock-copy:hover {
    transform: translateY(-1px);
    border-color: rgba(182, 94, 67, 0.18);
    background: rgba(255, 255, 255, 0.96);
}

.message-codeblock-copy.is-copied {
    border-color: rgba(61, 124, 84, 0.2);
    background: rgba(227, 244, 233, 0.92);
    color: #2d6a45;
}

.message-codeblock-copy.is-error {
    border-color: rgba(150, 57, 37, 0.18);
    background: rgba(253, 232, 228, 0.92);
    color: #963925;
}

.message-codeblock-floating-copy {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text-main);
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(73, 48, 34, 0.12);
    backdrop-filter: blur(16px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
}

.message-codeblock.has-floating-copy .message-codeblock-floating-copy {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.message-codeblock-floating-copy svg {
    width: 18px;
    height: 18px;
}

.message-codeblock-floating-copy:hover {
    border-color: rgba(182, 94, 67, 0.18);
    background: rgba(255, 255, 255, 0.98);
}

.message-codeblock-floating-copy.is-copied {
    border-color: rgba(61, 124, 84, 0.2);
    background: rgba(227, 244, 233, 0.96);
    color: #2d6a45;
}

.message-codeblock-floating-copy.is-error {
    border-color: rgba(150, 57, 37, 0.18);
    background: rgba(253, 232, 228, 0.96);
    color: #963925;
}

.message-codeblock-scroller {
    overflow: auto;
    max-width: 100%;
}

.message-content pre {
    overflow: visible;
    margin: 0;
    padding: 14px 16px;
    border: 0;
    background: transparent;
}

.message-content pre code {
    display: block;
    min-width: max-content;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, monospace;
    font-size: 0.93em;
    line-height: 1.68;
    white-space: pre;
}

.message.user .message-codeblock {
    border-color: rgba(255, 244, 238, 0.16);
    background: rgba(255, 255, 255, 0.1);
}

.message.user .message-codeblock-bar {
    border-bottom-color: rgba(255, 244, 238, 0.16);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08)),
        rgba(255, 255, 255, 0.08);
}

.message.user .message-codeblock-label {
    color: rgba(255, 248, 245, 0.84);
}

.message.user .message-codeblock-copy {
    border-color: rgba(255, 244, 238, 0.16);
    background: rgba(255, 255, 255, 0.14);
    color: #fff8f5;
}

.message.user .message-codeblock-copy:hover {
    border-color: rgba(255, 244, 238, 0.3);
    background: rgba(255, 255, 255, 0.2);
}

.message.user .message-codeblock-floating-copy {
    border-color: rgba(255, 244, 238, 0.16);
    background: rgba(255, 255, 255, 0.16);
    color: #fff8f5;
}

.message.user .message-codeblock-floating-copy:hover {
    border-color: rgba(255, 244, 238, 0.3);
    background: rgba(255, 255, 255, 0.22);
}

.message.user .message-codeblock-floating-copy.is-copied {
    border-color: rgba(190, 234, 205, 0.22);
    background: rgba(90, 155, 116, 0.28);
    color: #f4fff7;
}

.message.user .message-codeblock-floating-copy.is-error {
    border-color: rgba(255, 214, 204, 0.22);
    background: rgba(170, 82, 61, 0.34);
    color: #fff2ef;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(56, 43, 35, 0.08);
}

.message-content th,
.message-content td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(56, 43, 35, 0.08);
    text-align: left;
    vertical-align: top;
}

.message-content th {
    background: rgba(244, 219, 207, 0.2);
    font-weight: 800;
}

.message-content tr:last-child td {
    border-bottom: 0;
}

.message-math-inline {
    display: inline-flex;
    max-width: 100%;
    vertical-align: middle;
}

.message-math-inline .katex {
    font-size: 1.02em;
}

.message-math-block {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    padding: 0.18em 0;
}

.message-math-block .katex-display {
    margin: 0;
}

.message.user {
    color: #fff8f5;
    background: linear-gradient(145deg, #c56d53, #a3452f);
    border-bottom-right-radius: 10px;
    box-shadow: 0 18px 34px rgba(163, 69, 47, 0.24);
}

.message.assistant {
    background: var(--bg-panel-strong);
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-bottom-left-radius: 10px;
    box-shadow: 0 14px 24px rgba(73, 48, 34, 0.06);
}

.message.system {
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(34, 34, 31, 0.9);
    color: #faf5ee;
    font-size: 14px;
    text-align: center;
}

.message.error {
    background: rgba(150, 57, 37, 0.96);
}

.message.is-pending {
    min-width: 90px;
}

.message-streaming-cursor {
    display: inline-block;
    width: fit-content;
    color: currentColor;
    opacity: 0.7;
    animation: blink 1s infinite ease-in-out;
}

.message-reasoning {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(182, 94, 67, 0.14);
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(205, 132, 104, 0.18), transparent 42%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(247, 237, 230, 0.76));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 12px 22px rgba(73, 48, 34, 0.05);
}

.message-reasoning-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.message-reasoning-toggle:disabled {
    cursor: default;
}

.message-reasoning-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.message-reasoning-badge {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(182, 94, 67, 0.12);
    color: var(--accent-deep);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.message-reasoning.is-streaming .message-reasoning-badge {
    background: rgba(182, 94, 67, 0.18);
    box-shadow: 0 0 0 6px rgba(182, 94, 67, 0.06);
}

.message-reasoning-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.message-reasoning-copy strong {
    font-size: 13px;
    line-height: 1.2;
}

.message-reasoning-copy span {
    overflow: hidden;
    color: var(--text-soft);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-reasoning-chevron {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border-right: 1.8px solid rgba(56, 43, 35, 0.54);
    border-bottom: 1.8px solid rgba(56, 43, 35, 0.54);
    opacity: 0.72;
    transform: rotate(45deg);
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.message-reasoning-toggle:hover .message-reasoning-chevron {
    opacity: 1;
}

.message-reasoning.is-expanded .message-reasoning-chevron {
    transform: rotate(225deg);
}

.message-reasoning-panel {
    overflow: hidden;
}

.message-reasoning-content {
    color: rgba(73, 48, 34, 0.88);
    font-size: 0.94em;
}

.message-reasoning-content blockquote {
    background: rgba(244, 219, 207, 0.18);
}

.message-reasoning-content pre {
    background: rgba(255, 255, 255, 0.72);
}

.message.assistant .message-reasoning .message-streaming-cursor {
    color: var(--accent-deep);
}

.typing-dots {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(34, 34, 31, 0.48);
    animation: blink 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.12s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.24s;
}

.composer-wrap {
    position: absolute;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 2;
    width: min(calc(100% - 36px), 960px);
    padding: 0;
    border: 0;
    background: transparent;
    transform: translate(-50%, 0);
    transition: bottom 0.44s cubic-bezier(0.22, 1, 0.36, 1), transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-panel.is-empty-state .composer-wrap {
    bottom: 50%;
    transform: translate(-50%, 50%);
}

.composer {
    display: block;
}

.composer-shell {
    display: grid;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 32px;
    background:
        radial-gradient(circle at top right, rgba(244, 219, 207, 0.3), transparent 32%),
        rgba(255, 252, 248, 0.94);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 18px 36px rgba(73, 48, 34, 0.08);
    backdrop-filter: blur(22px);
}

.composer-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
}

.composer-field {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0 2px;
}

.composer-attachments {
    display: flex;
    align-items: flex-start;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0;
    padding: 2px 2px 4px;
    overflow-x: auto;
    overflow-y: hidden;
}

.composer-attachments[hidden] {
    display: none;
}

.composer-attachment-card {
    position: relative;
    flex: 0 0 auto;
    border: 1px solid rgba(56, 43, 35, 0.1);
    background: rgba(255, 255, 255, 0.82);
    min-width: 0;
    box-shadow: 0 10px 18px rgba(73, 48, 34, 0.05);
}

.composer-attachment-card.is-image {
    width: 78px;
    height: 78px;
    padding: 4px;
    border-radius: 22px;
}

.composer-attachment-card.is-file {
    display: flex;
    align-items: center;
    width: min(280px, calc(100vw - 120px));
    min-height: 72px;
    padding: 12px 44px 12px 12px;
    border-radius: 22px;
}

.composer-attachment-preview {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(247, 238, 229, 0.75);
    display: grid;
    place-items: center;
}

.composer-attachment-image-button {
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.composer-attachment-file {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.composer-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.composer-attachment-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(182, 94, 67, 0.12);
    color: var(--accent-deep);
}

.composer-attachment-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.composer-attachment-copy {
    min-width: 0;
}

.message-attachment-copy {
    min-width: 0;
}

.composer-attachment-copy strong,
.message-attachment-copy strong {
    display: block;
    font-size: 13px;
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-attachment-copy span,
.message-attachment-copy span {
    display: block;
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.45;
}

.composer-attachment-remove {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 999px;
    background: rgba(22, 19, 17, 0.96);
    color: #fff;
    font: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.composer-attachment-card.is-image .composer-attachment-remove {
    top: -6px;
    right: -6px;
}

.composer-attachment-card.is-file .composer-attachment-remove {
    top: 8px;
    right: 8px;
}

#message-input {
    width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 132px;
    padding: 10px 0 8px;
    border: 0;
    border-radius: 0;
    outline: none;
    resize: none;
    overflow-y: hidden;
    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-main);
    background: transparent;
    box-shadow: none;
}

#message-input:focus {
    box-shadow: none;
}

#message-input::placeholder {
    color: rgba(112, 104, 92, 0.82);
}

.send-button {
    display: inline-grid;
    place-items: center;
    align-self: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    padding: 0;
    border-radius: 999px;
    background: #121212;
    color: #fff;
    box-shadow: 0 18px 30px rgba(18, 18, 18, 0.2);
}

.composer-attachment-button {
    display: inline-grid;
    place-items: center;
    align-self: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    padding: 0;
    border: 1px solid rgba(56, 43, 35, 0.12);
    border-radius: 999px;
    background: rgba(255, 251, 246, 0.94);
    color: var(--text-main);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.composer-attachment-button svg,
.send-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.composer-note {
    display: none;
}

.message-attachments {
    display: grid;
    gap: 10px;
}

.message-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.message-attachment-card {
    min-width: 0;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.82);
    color: inherit;
    text-decoration: none;
    box-shadow: 0 10px 18px rgba(73, 48, 34, 0.05);
}

.message-attachment-card.is-image {
    width: min(146px, 48vw);
    padding: 4px;
    font: inherit;
    cursor: zoom-in;
}

.message-attachment-card.is-file {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(260px, 100%);
    padding: 12px 14px;
}

.message.user .message-attachment-card {
    border-color: rgba(255, 244, 238, 0.18);
    background: rgba(255, 255, 255, 0.12);
}

.message-attachment-card:hover {
    transform: translateY(-1px);
}

.message-attachment-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 16px;
    background: rgba(247, 238, 229, 0.75);
    display: grid;
    place-items: center;
}

.message.user .message-attachment-preview {
    background: rgba(255, 255, 255, 0.12);
}

.message-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-attachment-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(182, 94, 67, 0.12);
    color: var(--accent-deep);
}

.message.user .message-attachment-icon {
    background: rgba(255, 255, 255, 0.12);
    color: #fff7f2;
}

.message-attachment-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 26;
    display: grid;
    place-items: center;
    padding: 18px;
}

.lightbox-modal[hidden] {
    display: none;
}

.lightbox-modal.is-closing {
    pointer-events: none;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(18, 16, 14, 0.72);
    backdrop-filter: blur(10px);
    cursor: pointer;
    animation: overlayFadeIn 0.22s ease;
}

.lightbox-modal.is-closing .lightbox-backdrop {
    animation: overlayFadeOut 0.18s ease forwards;
}

.lightbox-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 980px);
    max-height: calc(100dvh - 36px);
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 30px;
    background: rgba(18, 16, 14, 0.82);
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.35);
    animation: modalPanelIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.lightbox-modal.is-closing .lightbox-dialog {
    animation: modalPanelOut 0.18s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.lightbox-stage {
    display: grid;
    place-items: center;
    min-height: min(62dvh, 680px);
    max-height: calc(100dvh - 160px);
    overflow: auto;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.04);
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 180px);
    object-fit: contain;
    border-radius: 20px;
}

.lightbox-caption {
    min-height: 1.4em;
    margin: 0;
    color: rgba(255, 248, 243, 0.86);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}

.lightbox-close-button {
    position: absolute;
    top: 14px;
    right: 14px;
    padding: 9px 12px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 22;
    display: grid;
    place-items: center;
    padding: 18px;
}

.auth-modal[hidden] {
    display: none;
}

.auth-modal.is-closing {
    pointer-events: none;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(30, 26, 22, 0.34);
    backdrop-filter: blur(10px);
    cursor: pointer;
    animation: overlayFadeIn 0.22s ease;
}

.auth-modal.is-closing .auth-backdrop {
    animation: overlayFadeOut 0.18s ease forwards;
}

.auth-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    max-height: calc(100dvh - 36px);
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 28px;
    background: rgba(255, 251, 246, 0.96);
    box-shadow: 0 30px 80px rgba(56, 43, 35, 0.2);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    animation: modalPanelIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-modal.is-closing .auth-dialog {
    animation: modalPanelOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid rgba(56, 43, 35, 0.08);
}

.auth-header h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.08;
}

.auth-body {
    display: grid;
    gap: 16px;
    min-height: 0;
    overflow: auto;
    padding: 20px 24px 24px;
}

.toast-viewport {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 40;
    display: grid;
    gap: 12px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    padding: 14px 16px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 252, 248, 0.94);
    box-shadow: 0 22px 46px rgba(73, 48, 34, 0.16);
    color: var(--text-main);
    line-height: 1.65;
    opacity: 0;
    transform: translate3d(0, -12px, 0) scale(0.98);
    transition: opacity 220ms ease, transform 220ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

.toast.is-leaving {
    opacity: 0;
    transform: translate3d(0, -10px, 0) scale(0.98);
}

.toast-success {
    color: #246245;
    border-color: rgba(45, 125, 85, 0.2);
    background: rgba(245, 252, 247, 0.96);
}

.toast-error {
    color: #8d362d;
    border-color: rgba(176, 69, 56, 0.2);
    background: rgba(255, 247, 246, 0.96);
}

.toast-warning,
.toast-info {
    color: var(--accent-deep);
    border-color: rgba(185, 100, 72, 0.16);
    background: rgba(255, 249, 244, 0.96);
}

.auth-feedback {
    margin: 0;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    background: rgba(255, 252, 248, 0.9);
    color: var(--text-soft);
    line-height: 1.7;
}

.auth-feedback.is-error {
    color: #8d362d;
    background: rgba(176, 69, 56, 0.1);
    border-color: rgba(176, 69, 56, 0.18);
}

.auth-guest-view,
.auth-account-view,
.account-meta,
.account-actions {
    display: grid;
    gap: 12px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 8px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 20px;
    background: rgba(247, 238, 229, 0.7);
}

.auth-tab {
    padding: 13px 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.auth-tab.is-active {
    color: var(--accent-deep);
    border-color: rgba(182, 94, 67, 0.16);
    background: rgba(255, 252, 248, 0.96);
    box-shadow: 0 12px 20px rgba(146, 87, 62, 0.08);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form[hidden],
.auth-guest-view[hidden],
.auth-account-view[hidden] {
    display: none;
}

.field-block {
    display: grid;
    gap: 8px;
}

.field-inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.field-block span {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-soft);
}

.field-block input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid rgba(56, 43, 35, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--text-main);
    font: inherit;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field-block input:focus {
    border-color: rgba(182, 94, 67, 0.35);
    box-shadow: 0 0 0 4px rgba(182, 94, 67, 0.08);
}

.field-block input[readonly],
.field-block textarea[readonly] {
    color: var(--text-soft);
    cursor: default;
}

.auth-hint {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.8;
}

.account-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(255, 248, 242, 0.96), rgba(255, 253, 249, 0.94));
}

.account-profile-form {
    display: grid;
    gap: 14px;
}

.account-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.account-avatar-stack {
    display: grid;
    gap: 10px;
    justify-items: center;
}

.account-avatar {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    border-radius: 28px;
    background: linear-gradient(145deg, #faf3ea, #f0e1d1);
    border: 1px solid rgba(56, 43, 35, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
    overflow: hidden;
}

.account-avatar .avatar-initials {
    font-size: 34px;
}

.account-avatar-button {
    min-width: 128px;
}

.account-avatar-hint {
    margin: 0;
    max-width: 140px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.7;
    text-align: center;
}

.account-profile-main {
    display: grid;
    gap: 14px;
}

.account-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.account-card-top strong {
    font-size: 22px;
}

.account-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(244, 219, 207, 0.5);
    color: var(--accent-deep);
    font-size: 12px;
    font-weight: 700;
}

.account-email {
    margin: 0;
    color: var(--text-soft);
    font-size: 15px;
    word-break: break-all;
}

.account-email-block {
    display: grid;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 254, 251, 0.9);
}

.account-email-block span {
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
}

.account-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.account-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 254, 251, 0.9);
}

.account-meta-row span {
    color: var(--text-soft);
}

.account-meta-row strong {
    text-align: right;
}

.account-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.conversation-item:hover,
.ghost-button:hover,
.sidebar-primary-button:hover,
.primary-button:hover,
.secondary-button:hover,
.composer-attachment-button:hover,
.user-bar:hover,
.send-button:hover {
    transform: translateY(-1px);
}

.ghost-button:disabled,
.sidebar-primary-button:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.composer-attachment-button:disabled,
.user-bar:disabled,
.send-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 18px;
}

.settings-modal[hidden] {
    display: none;
}

.settings-modal.is-closing {
    pointer-events: none;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(30, 26, 22, 0.34);
    backdrop-filter: blur(10px);
    cursor: pointer;
    animation: overlayFadeIn 0.22s ease;
}

.settings-modal.is-closing .settings-backdrop {
    animation: overlayFadeOut 0.18s ease forwards;
}

.settings-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
    max-height: calc(100dvh - 36px);
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 28px;
    background: rgba(255, 251, 246, 0.94);
    box-shadow: 0 30px 80px rgba(56, 43, 35, 0.2);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    transform-origin: center center;
    animation: modalPanelIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-modal.is-closing .settings-dialog {
    animation: modalPanelOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid rgba(56, 43, 35, 0.08);
}

.settings-header h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.08;
}

.icon-button {
    padding: 10px 14px;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 999px;
    background: rgba(255, 251, 246, 0.94);
    color: var(--text-main);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.settings-body {
    display: grid;
    gap: 16px;
    min-height: 0;
    overflow: auto;
    padding: 20px 24px 24px;
}

.settings-form {
    display: grid;
    gap: 16px;
}

.settings-note {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid rgba(182, 94, 67, 0.14);
    border-radius: 16px;
    background: rgba(255, 248, 242, 0.9);
    color: var(--text-soft);
    line-height: 1.7;
}

.settings-field {
    gap: 10px;
}

.settings-model-list {
    display: grid;
    gap: 10px;
}

.settings-model-empty {
    padding: 16px 18px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 254, 251, 0.9);
    color: var(--text-soft);
    line-height: 1.7;
}

.settings-model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 254, 251, 0.92);
    color: var(--text-main);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

.settings-model-option:hover {
    transform: translateY(-1px);
    background: rgba(255, 251, 246, 0.96);
}

.settings-model-option:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.settings-model-option:focus-visible {
    border-color: rgba(182, 94, 67, 0.35);
    box-shadow: 0 0 0 4px rgba(182, 94, 67, 0.08);
}

.settings-model-option.is-selected {
    border-color: rgba(182, 94, 67, 0.28);
    background:
        radial-gradient(circle at top right, rgba(244, 219, 207, 0.3), transparent 36%),
        rgba(255, 250, 245, 0.98);
    box-shadow: 0 14px 24px rgba(157, 95, 68, 0.08);
}

.settings-model-option-main {
    min-width: 0;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.5;
}

.settings-model-option-tags {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-model-tag {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    background: rgba(250, 244, 237, 0.95);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.settings-model-tag.is-billing {
    color: var(--accent-deep);
    background: rgba(244, 219, 207, 0.5);
}

.settings-model-tag.is-consumption {
    color: var(--text-soft);
}

.field-block select,
.field-block textarea {
    width: 100%;
    border: 1px solid rgba(56, 43, 35, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--text-main);
    font: inherit;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field-block select {
    height: 48px;
    padding: 0 14px;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(56, 43, 35, 0.72) 50%),
        linear-gradient(135deg, rgba(56, 43, 35, 0.72) 50%, transparent 50%);
    background-position:
        calc(100% - 22px) calc(50% - 2px),
        calc(100% - 16px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.field-block textarea {
    min-height: 184px;
    padding: 14px;
    line-height: 1.7;
    resize: vertical;
}

.field-block select:focus,
.field-block textarea:focus {
    border-color: rgba(182, 94, 67, 0.35);
    box-shadow: 0 0 0 4px rgba(182, 94, 67, 0.08);
}

.settings-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.subscription-body {
    gap: 18px;
}

.subscription-summary {
    display: grid;
    gap: 10px;
    padding: 18px 20px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(244, 219, 207, 0.34), transparent 34%),
        linear-gradient(145deg, rgba(255, 248, 242, 0.98), rgba(255, 253, 249, 0.95));
}

.subscription-summary-label {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
}

.subscription-summary-main {
    display: grid;
    gap: 8px;
}

.subscription-summary-main strong {
    font-size: 26px;
    line-height: 1.08;
}

.subscription-summary-main p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.75;
}

.subscription-plan-list {
    display: grid;
    gap: 14px;
}

.subscription-plan-empty {
    padding: 18px 20px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 20px;
    background: rgba(255, 254, 251, 0.9);
    color: var(--text-soft);
    line-height: 1.75;
}

.subscription-plan-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(255, 248, 242, 0.96), rgba(255, 253, 249, 0.94));
}

.subscription-plan-card.is-current {
    border-color: rgba(182, 94, 67, 0.24);
    box-shadow: 0 16px 28px rgba(157, 95, 68, 0.1);
}

.subscription-plan-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.subscription-plan-heading {
    display: grid;
    gap: 8px;
}

.subscription-plan-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.subscription-plan-heading strong {
    font-size: 22px;
    line-height: 1.12;
}

.subscription-current-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(244, 219, 207, 0.55);
    color: var(--accent-deep);
    font-size: 12px;
    font-weight: 700;
}

.subscription-plan-code {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.subscription-price-grid {
    display: grid;
    grid-template-columns: minmax(140px, 1fr);
    gap: 10px;
    width: min(100%, 160px);
}

.subscription-price-card,
.subscription-plan-quota {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    border-radius: 18px;
    background: rgba(255, 254, 251, 0.9);
}

.subscription-price-card span,
.subscription-plan-quota span,
.subscription-models-label {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
}

.subscription-price-card strong,
.subscription-plan-quota strong {
    font-size: 22px;
    line-height: 1.08;
}

.subscription-models-section {
    display: grid;
    gap: 12px;
}

.subscription-models {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.subscription-model-chip,
.subscription-model-empty {
    display: inline-flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid rgba(56, 43, 35, 0.08);
    background: rgba(255, 254, 251, 0.92);
    font-size: 13px;
    line-height: 1.4;
}

.subscription-model-empty {
    color: var(--text-soft);
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 24;
    display: grid;
    place-items: center;
    padding: 18px;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal.is-closing {
    pointer-events: none;
}

.confirm-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(30, 26, 22, 0.3);
    backdrop-filter: blur(10px);
    cursor: pointer;
    animation: overlayFadeIn 0.22s ease;
}

.confirm-modal.is-closing .confirm-backdrop {
    animation: overlayFadeOut 0.18s ease forwards;
}

.confirm-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 430px);
    max-height: calc(100dvh - 36px);
    padding: 28px;
    border: 1px solid rgba(56, 43, 35, 0.1);
    border-radius: 30px;
    background:
        radial-gradient(circle at top right, rgba(245, 209, 195, 0.4), transparent 32%),
        rgba(255, 251, 246, 0.97);
    box-shadow: 0 30px 80px rgba(56, 43, 35, 0.22);
    transform-origin: center bottom;
    animation: confirmDialogIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.confirm-modal.is-closing .confirm-dialog {
    animation: confirmDialogOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.confirm-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 18px;
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(190, 101, 75, 0.18), rgba(150, 57, 37, 0.1));
    color: #a24733;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.confirm-icon svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.confirm-copy h3 {
    margin: 0;
    font-size: 28px;
    line-height: 1.08;
}

.confirm-copy p:last-child {
    margin: 12px 0 0;
    color: var(--text-soft);
    line-height: 1.8;
}

.confirm-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 22px;
}

.soft-button,
.danger-button {
    border: 0;
    border-radius: 18px;
    padding: 14px 18px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.soft-button {
    background: rgba(244, 236, 228, 0.9);
    color: var(--text-main);
    border: 1px solid rgba(56, 43, 35, 0.08);
}

.danger-button {
    background: linear-gradient(145deg, #c86d54, #9d3f2a);
    color: #fff9f6;
    box-shadow: 0 18px 28px rgba(157, 63, 42, 0.24);
}

.soft-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
}

.soft-button:disabled,
.danger-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@keyframes drift {
    0%,
    100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(18px, -12px, 0);
    }
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes overlayFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes modalPanelIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalPanelOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
}

@keyframes confirmDialogIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes confirmDialogOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
}

@keyframes menuPopoverIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes menuPopoverOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

@media (prefers-reduced-motion: reduce) {
    .user-menu,
    .user-menu.is-closing,
    .settings-backdrop,
    .auth-backdrop,
    .settings-dialog,
    .auth-dialog,
    .settings-modal.is-closing .settings-backdrop,
    .auth-modal.is-closing .auth-backdrop,
    .settings-modal.is-closing .settings-dialog,
    .auth-modal.is-closing .auth-dialog,
    .confirm-backdrop,
    .confirm-dialog,
    .confirm-modal.is-closing .confirm-backdrop,
    .confirm-modal.is-closing .confirm-dialog {
        animation: none;
    }
}

@media (max-width: 1120px) {
    .page-shell {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .mobile-sidebar-button {
        display: inline-flex;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10;
        border: 0;
        background: transparent;
        backdrop-filter: none;
        cursor: pointer;
    }

    .sidebar-backdrop[hidden] {
        display: none;
    }

    .brand-block {
        flex-direction: row;
        text-align: left;
    }

    .sidebar-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 11;
        width: min(344px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
        border-radius: 0 28px 28px 0;
        border-color: rgba(56, 43, 35, 0.08);
        background:
            linear-gradient(180deg, rgba(255, 250, 244, 0.98), rgba(252, 245, 236, 0.98)),
            radial-gradient(circle at top left, rgba(243, 210, 191, 0.22), transparent 34%);
        backdrop-filter: none;
        box-shadow: none;
        transform: translateX(calc(-100% - 24px));
        opacity: 0;
        pointer-events: none;
        transition: transform 0.22s ease, opacity 0.22s ease;
    }

    .sidebar-panel::before {
        display: none;
    }

    .sidebar-panel.is-mobile-open {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .conversation-sidebar {
        max-height: none;
    }

    .chat-header {
        padding-left: 24px;
    }

    .mobile-sidebar-button {
        position: static;
        align-self: center;
        margin-right: 2px;
        z-index: auto;
    }

    .user-menu {
        left: auto;
        right: 0;
        min-width: 170px;
        top: auto;
        bottom: calc(100% + 12px);
        transform-origin: right bottom;
    }
}

@media (max-width: 720px) {
    .page-shell {
        padding: 10px;
        gap: 10px;
    }

    .chat-panel {
        border-radius: 22px;
    }

    .sidebar-panel {
        width: min(332px, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
        border-radius: 0 24px 24px 0;
    }

    .brand-mark {
        background: transparent;
        box-shadow: none;
    }

    .conversation-sidebar {
        background: #fffdf8;
        box-shadow: none;
    }

    .conversation-sidebar-head {
        background: linear-gradient(180deg, rgba(255, 253, 248, 1), rgba(255, 253, 248, 0.95) 82%, rgba(255, 253, 248, 0));
    }

    .conversation-item {
        border-color: rgba(182, 94, 67, 0.14);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 245, 238, 0.9));
        box-shadow: none;
    }

    .conversation-item.is-active {
        background: linear-gradient(180deg, rgba(255, 242, 234, 0.98), rgba(248, 232, 220, 0.94));
    }

    .conversation-icon-button {
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 241, 233, 0.96));
    }

    .user-bar {
        background: linear-gradient(180deg, rgba(255, 251, 246, 0.96), rgba(252, 246, 240, 0.94));
        box-shadow: none;
    }

    .brand-block {
        flex-direction: row;
        text-align: left;
    }

    .sidebar-actions {
        margin-left: 0;
        justify-content: stretch;
    }

    .user-bar {
        width: 100%;
    }

    .user-menu {
        left: 0;
        right: 0;
        top: auto;
        bottom: calc(100% + 10px);
        min-width: 0;
        transform-origin: left bottom;
    }

    .chat-header {
        align-items: center;
        justify-content: space-between;
        padding: 16px;
    }

    .assistant-badge {
        flex: 1;
        gap: 12px;
        min-width: 0;
        align-items: center;
    }

    .chat-actions {
        width: auto;
        justify-content: flex-end;
        flex: 0 0 auto;
    }

    .assistant-avatar {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border-radius: 0;
    }

    .chat-heading h2 {
        font-size: clamp(16px, 7vw, 26px);
        line-height: 1.08;
    }

    .chat-heading .eyebrow {
        font-size: 10px;
        letter-spacing: 0.14em;
        margin-bottom: 4px;
    }

    .ghost-button {
        padding: 10px 14px;
        font-size: 14px;
    }

    .conversation-item-actions {
        gap: 6px;
    }

    .conversation-icon-button {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .conversation-icon-button svg {
        width: 15px;
        height: 15px;
    }

    .chat-empty-hero {
        width: calc(100% - 28px);
        bottom: calc(50% + 88px);
    }

    .chat-empty-hero strong {
        font-size: var(--empty-hero-title-size, clamp(24px, 10vw, 40px));
    }

    .chat-empty-hero span {
        font-size: 15px;
    }

    .message-list {
        padding: 18px 14px calc(var(--composer-space) + 20px);
    }

    .composer-wrap {
        bottom: max(10px, env(safe-area-inset-bottom));
        width: calc(100% - 20px);
    }

    .message-row {
        max-width: 100%;
    }

    .message-meta {
        gap: 8px;
        padding: 0 4px;
        font-size: 11px;
    }

    .message {
        padding: 14px 16px;
        border-radius: 20px;
        font-size: 15px;
        line-height: 1.72;
    }

    .composer {
        display: block;
    }

    .composer-shell {
        gap: 8px;
        padding: 8px 10px;
        border-radius: 26px;
    }

    #message-input {
        height: 42px;
        min-height: 42px;
        max-height: 108px;
        font-size: 15px;
        line-height: 1.55;
    }

    .composer-main {
        gap: 8px;
    }

    .composer-attachment-button,
    .send-button {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .composer-attachment-button svg,
    .send-button svg {
        width: 18px;
        height: 18px;
    }

    .composer-attachment-card.is-file {
        width: min(220px, calc(100vw - 104px));
    }

    .message-attachment-card.is-image {
        width: min(124px, 42vw);
    }

    .message-attachment-card.is-file {
        width: min(230px, 100%);
    }

    .lightbox-dialog {
        width: min(100%, calc(100vw - 20px));
        padding: 14px;
        border-radius: 24px;
    }

    .lightbox-stage {
        min-height: min(50dvh, 420px);
    }

    .field-inline,
    .auth-tabs {
        grid-template-columns: 1fr;
    }

    .secondary-button {
        width: 100%;
    }

    .settings-dialog {
        width: min(100%, calc(100vw - 20px));
        max-height: calc(100dvh - 20px);
        border-radius: 22px;
    }

    .subscription-dialog {
        width: min(100%, calc(100vw - 20px));
        max-height: calc(100dvh - 20px);
        border-radius: 22px;
    }

    .auth-dialog {
        width: min(100%, calc(100vw - 20px));
        max-height: calc(100dvh - 20px);
        border-radius: 22px;
    }

    .confirm-dialog {
        width: min(100%, calc(100vw - 20px));
        max-height: calc(100dvh - 20px);
        padding: 24px 20px;
        border-radius: 24px;
    }

    .confirm-actions {
        grid-template-columns: 1fr;
    }

    .mobile-sidebar-button {
        width: 38px;
        height: 38px;
        border-radius: 12px;
        margin-right: 4px;
    }

    .mobile-sidebar-button span {
        width: 15px;
    }

    .mobile-sidebar-button span + span {
        margin-top: 3px;
    }

    .mobile-sidebar-button[aria-expanded="true"] span:nth-child(1) {
        transform: translateY(5px) rotate(45deg);
    }

    .mobile-sidebar-button[aria-expanded="true"] span:nth-child(3) {
        transform: translateY(-5px) rotate(-45deg);
    }
}

@media (max-width: 720px), (max-height: 820px) {
    .settings-modal,
    .subscription-modal,
    .auth-modal,
    .confirm-modal,
    .lightbox-modal {
        align-items: start;
        padding: 10px;
        overflow: auto;
    }

    .settings-dialog,
    .subscription-dialog,
    .auth-dialog,
    .confirm-dialog,
    .lightbox-dialog {
        width: min(100%, calc(100vw - 20px));
        max-height: calc(100dvh - 20px);
    }

    .settings-header,
    .subscription-header,
    .auth-header {
        padding: 18px 18px 14px;
    }

    .settings-body,
    .subscription-body,
    .auth-body {
        padding: 16px 18px 18px;
    }

    .toast-viewport {
        top: 16px;
        right: 16px;
        left: 16px;
        width: auto;
    }

    .settings-model-option {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-model-option-tags {
        justify-content: flex-start;
    }

    .subscription-price-grid {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .subscription-summary-main strong,
    .subscription-plan-heading strong,
    .subscription-price-card strong,
    .subscription-plan-quota strong {
        font-size: 20px;
    }

    .account-hero,
    .account-meta,
    .account-actions {
        grid-template-columns: 1fr;
    }

    .account-avatar-stack {
        justify-items: stretch;
    }

    .account-avatar {
        margin-inline: auto;
    }

    .account-avatar-hint {
        max-width: none;
    }

    .confirm-dialog {
        padding: 22px 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: none;
    }
}
