/* ============================================================
   花花世界 · 品牌助手 — Botanical Luxury
   Design direction: Organic warmth meets editorial refinement.
   Deep forest greens, warm amber gold, living textures.
   ============================================================ */

:root {
    /* ====== Theme-independent structure ====== */
    /* Brand amber — used as FILL / border / dot in both themes (light enough
       to carry dark text). Text-amber lives in --accent-text (theme-aware). */
    --amber: #C8A44E;
    --amber-glow: #E8C96A;
    --amber-deep: #8A6D2E;
    --sage: #7BA05B;
    --terracotta: #C17B4E;

    /* Amber alpha tints read as gold over any background → theme-independent */
    --primary: #C8A44E;
    --primary-light: rgba(200, 164, 78, 0.12);
    --accent: #C8A44E;
    --accent-light: rgba(200, 164, 78, 0.12);
    --warm: #C17B4E;
    --warm-light: rgba(193, 123, 78, 0.12);

    /* === Fonts === */
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", sans-serif;
    --font-display: "Noto Serif SC", "Playfair Display", "Songti SC", serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 26px;
    --transition: 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);

    /* ====== 夜间 · 深夜编辑室 (default) ====== */
    --primary-dark: #0C0D12;
    --accent-text: #E8C96A;          /* text-safe accent on dark */

    --bg: #0C0D12;
    --bg-gradient: radial-gradient(120% 80% at 12% -10%, #181924 0%, #0C0D12 58%);
    --surface: rgba(255, 255, 255, 0.045);
    --surface-border: rgba(255, 255, 255, 0.09);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.07);
    --hairline-fill: rgba(255, 255, 255, 0.06);

    --text: #F0EAE0;
    --text-secondary: #ADA69C;
    --text-muted: #847E76;

    --user-bubble: rgba(200, 164, 78, 0.14);
    --user-bubble-text: #F1E6CC;
    --assistant-bubble: rgba(255, 255, 255, 0.035);
    --assistant-bubble-border: rgba(255, 255, 255, 0.08);

    --danger: #F0918C;
    --danger-bg: rgba(224, 75, 74, 0.14);
    --danger-border: rgba(224, 75, 74, 0.32);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.35);

    /* Immersive surfaces (landing / auth) */
    --surf-ink: #F0EAE0;
    --surf-ink-rgb: 240, 234, 224;   /* alpha-text base */
    --surf-card: rgba(255, 255, 255, 0.035);
    --surf-chip: rgba(255, 255, 255, 0.04);

    --landing-bg: #0C0D12;
    --landing-header-bg: rgba(16, 17, 25, 0.62);
    --landing-card: rgba(255, 255, 255, 0.025);
    --landing-card-hover: rgba(200, 164, 78, 0.06);
    --landing-border: rgba(255, 255, 255, 0.08);
    --landing-glow-1: rgba(200, 164, 78, 0.16);
    --landing-glow-2: rgba(200, 164, 78, 0.1);
    --landing-glow-3: rgba(193, 123, 78, 0.07);
    --orb-opacity: 0.25;
}

/* ====== 日间 · 白色风格 ====== */
:root[data-theme="light"] {
    --primary-dark: #1E1C18;
    --accent-text: #8A6D2E;          /* deep amber, text-safe on white */

    --bg: #F6F5F2;
    --bg-gradient: radial-gradient(120% 80% at 12% -10%, #FFFFFF 0%, #F1F0EC 60%);
    --surface: #FFFFFF;
    --surface-border: rgba(30, 28, 24, 0.12);
    --glass: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(30, 28, 24, 0.09);
    --hairline-fill: rgba(30, 28, 24, 0.05);

    --text: #211E18;
    --text-secondary: #5E574D;
    --text-muted: #6C6459;

    --user-bubble: rgba(200, 164, 78, 0.2);
    --user-bubble-text: #423310;
    --assistant-bubble: #FFFFFF;
    --assistant-bubble-border: rgba(30, 28, 24, 0.1);

    --danger: #C23A30;
    --danger-bg: rgba(194, 58, 48, 0.1);
    --danger-border: rgba(194, 58, 48, 0.28);

    --shadow-sm: 0 1px 3px rgba(30, 28, 24, 0.06);
    --shadow-md: 0 4px 18px rgba(30, 28, 24, 0.09);
    --shadow-lg: 0 16px 44px rgba(30, 28, 24, 0.14);
    --shadow-glass: 0 6px 28px rgba(30, 28, 24, 0.08);

    --surf-ink: #211E18;
    --surf-ink-rgb: 33, 30, 24;
    --surf-card: #FFFFFF;
    --surf-chip: #F0EFEA;

    --landing-bg: #F6F5F2;
    --landing-header-bg: rgba(255, 255, 255, 0.78);
    --landing-card: #FFFFFF;
    --landing-card-hover: #FFFFFF;
    --landing-border: rgba(30, 28, 24, 0.1);
    --landing-glow-1: rgba(200, 164, 78, 0.22);
    --landing-glow-2: rgba(200, 164, 78, 0.14);
    --landing-glow-3: rgba(193, 123, 78, 0.1);
    --orb-opacity: 0.5;
}

/* ============================================================
   BASE
   ============================================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-ui);
    background: var(--landing-bg);
    color: var(--text);
    font-weight: 400;
    line-height: 1.7;
}


/* ============================================================
   AUTH PAGE
   ============================================================ */

.auth-page {
    min-height: 100vh;
    background: var(--landing-bg);
    color: var(--surf-ink);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.auth-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(200,164,78,0.3));
}

.auth-logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--surf-ink);
    font-family: var(--font-display);
}

.auth-card {
    width: 100%;
    background: var(--surf-card);
    border: 1px solid rgba(200, 164, 78, 0.12);
    border-radius: 20px;
    padding: 32px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--surf-chip);
    border-radius: 12px;
    padding: 3px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(var(--surf-ink-rgb), 0.5);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.auth-tab.active {
    background: rgba(200, 164, 78, 0.12);
    color: var(--accent-text);
}

.auth-tab:hover:not(.active) {
    color: rgba(var(--surf-ink-rgb), 0.7);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.auth-form.active {
    display: flex;
}

.register-coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    text-align: center;
}

.register-coming-icon {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.register-coming-title {
    font-size: 18px;
    font-weight: 600;
    color: rgba(var(--surf-ink-rgb), 0.85);
    margin: 0 0 8px 0;
}

.register-coming-desc {
    font-size: 14px;
    color: rgba(var(--surf-ink-rgb), 0.65);
    margin: 0;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-label {
    font-size: 12px;
    font-weight: 500;
    color: rgba(var(--surf-ink-rgb), 0.6);
    letter-spacing: 0.04em;
}

.auth-input {
    padding: 12px 14px;
    border: 1px solid rgba(200, 164, 78, 0.12);
    border-radius: 12px;
    background: var(--surf-card);
    color: var(--surf-ink);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}

.auth-input:focus {
    border-color: var(--amber);
    background: rgba(200, 164, 78, 0.04);
    box-shadow: 0 0 0 3px rgba(200, 164, 78, 0.08);
}

.auth-input::placeholder {
    color: rgba(var(--surf-ink-rgb), 0.5);
}

.auth-btn {
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #E8C96A, #C8A44E);
    color: #1A1206;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity var(--transition), box-shadow var(--transition), transform var(--transition);
    margin-top: 4px;
}

.auth-btn:hover {
    opacity: 0.94;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(200, 164, 78, 0.3);
}

.auth-btn:active {
    transform: translateY(0);
}

.auth-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-error {
    font-size: 13px;
    color: #FCA5A5;
    text-align: center;
    min-height: 20px;
}

.auth-footer {
    font-size: 12px;
    color: rgba(var(--surf-ink-rgb), 0.35);
    letter-spacing: 0.06em;
}

/* Auth link in nav */
.auth-link {
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: rgba(var(--surf-ink-rgb), 0.5);
    transition: color var(--transition);
    position: relative;
    padding: 0;
}

.auth-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--amber);
    transition: width 0.4s ease;
}

.auth-link:hover {
    color: rgba(var(--surf-ink-rgb), 0.7);
}

.auth-link:hover::after {
    width: 100%;
}

/* Sidebar user row */
.sidebar-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
}

.sidebar-user-name {
    color: var(--accent-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-btn {
    background: none;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sidebar-logout-btn:hover {
    color: #FCA5A5;
    border-color: rgba(220, 38, 38, 0.3);
    background: rgba(220, 38, 38, 0.08);
}

/* API Key settings */
.api-key-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.api-key-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.api-key-user {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.logout-link {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.logout-link:hover {
    color: #FCA5A5;
}

.api-key-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.api-key-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.api-key-hint {
    font-size: 11px;
    color: var(--text-muted);
    min-height: 16px;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing {
    min-height: 100vh;
    background: var(--landing-bg);
    color: var(--surf-ink);
    position: relative;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* === Organic floating shapes (replace geometric orbs) === */
.landing-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.landing-orb {
    position: absolute;
    border-radius: 60% 40% 55% 45% / 55% 45% 55% 45%;
    filter: blur(100px);
    opacity: var(--orb-opacity);
    animation: petalFloat 14s ease-in-out infinite;
}

.orb-1 {
    width: 520px;
    height: 520px;
    background: radial-gradient(circle at 40% 50%, var(--amber-glow), rgba(200,164,78,0.25));
    top: -180px;
    right: -120px;
    border-radius: 65% 35% 50% 50% / 45% 55% 45% 55%;
    animation-delay: 0s;
}

.orb-2 {
    width: 420px;
    height: 420px;
    background: radial-gradient(circle at 60% 40%, var(--amber), rgba(200,164,78,0.18));
    bottom: -140px;
    left: -80px;
    border-radius: 40% 60% 50% 50% / 60% 40% 60% 40%;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 380px;
    background: radial-gradient(ellipse at 50% 40%, var(--terracotta), rgba(193,123,78,0.12));
    top: 35%;
    left: 55%;
    border-radius: 50% 50% 45% 55% / 55% 50% 50% 45%;
    animation-delay: -9s;
}

@keyframes petalFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
    25% { transform: translate(25px, -20px) rotate(3deg) scale(1.04); }
    50% { transform: translate(-15px, 25px) rotate(-2deg) scale(0.97); }
    75% { transform: translate(-20px, -15px) rotate(2deg) scale(1.02); }
}

.landing-content {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 36px 72px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin: 0 -8px;
    background: var(--landing-header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(200, 164, 78, 0.06);
    border-radius: 16px;
    position: sticky;
    top: 8px;
    z-index: 10;
}

.landing-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.landing-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(200,164,78,0.25));
    transition: filter var(--transition);
}

.landing-logo:hover .landing-logo-img {
    filter: drop-shadow(0 0 14px rgba(200,164,78,0.4));
}

/* Refined SVG logo */

.landing-logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--surf-ink);
    font-family: var(--font-display);
}

.landing-nav {
    display: flex;
    gap: 32px;
}

.landing-nav-link {
    color: rgba(var(--surf-ink-rgb), 0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    transition: color var(--transition);
    position: relative;
}

.landing-nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--amber);
    transition: width 0.4s ease;
}

.landing-nav-link:hover {
    color: rgba(var(--surf-ink-rgb), 0.85);
}
.landing-nav-link:hover::after {
    width: 100%;
}

/* Landing page username */
.landing-nav-user {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-text);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.landing-nav-user::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sage);
    box-shadow: 0 0 6px rgba(123,160,91,0.5);
}

/* Chat page header username */
.chat-user-info {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-text);
    padding: 0 4px 0 8px;
    border-left: 1px solid var(--glass-border);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

/* === Hero === */
.hero {
    text-align: center;
    padding: 100px 0 72px;
    animation: heroReveal 1s cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

.hero-title {
    font-size: clamp(40px, 7vw, 64px);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: 0.02em;
    margin-bottom: 28px;
    font-family: var(--font-display);
}

.hero-title-line {
    display: block;
    color: var(--surf-ink);
}

.hero-title-line.accent {
    color: var(--accent-text);
    font-style: italic;
    letter-spacing: 0.04em;
}

.hero-desc {
    font-size: 17px;
    color: rgba(var(--surf-ink-rgb), 0.75);
    max-width: 460px;
    margin: 0 auto;
    line-height: 1.8;
    font-weight: 400;
}

/* === Tool Grid === */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}

.tool-card {
    position: relative;
    background: var(--landing-card);
    border: 1px solid var(--landing-border);
    border-radius: 24px;
    padding: 28px;
    cursor: pointer;
    transition: background-color 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
                border-color 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
                box-shadow 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tool-card.disabled {
    cursor: default;
}

.tool-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(500px at 50% -10%, rgba(200,164,78,0.04), transparent);
    opacity: 0;
    transition: opacity 0.45s;
    pointer-events: none;
}

.tool-card:hover {
    background: var(--landing-card-hover);
    border-color: rgba(200, 164, 78, 0.25);
    transform: translateY(-3px);
    box-shadow: 0 16px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(200,164,78,0.08);
}

.tool-card.disabled:hover {
    background: var(--landing-card);
    border-color: var(--landing-border);
    transform: none;
    box-shadow: none;
}

.tool-card.disabled:hover::before {
    opacity: 0;
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card.featured {
    border-color: rgba(200, 164, 78, 0.2);
    background: rgba(200, 164, 78, 0.04);
}

.tool-card.featured:hover {
    border-color: rgba(200, 164, 78, 0.4);
    box-shadow: 0 16px 60px rgba(0,0,0,0.4), 0 0 80px rgba(200,164,78,0.06);
}

.tool-card-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(600px at 50% -30%, rgba(200,164,78,0.06), transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.45s;
}

.tool-card.featured:hover .tool-card-glow {
    opacity: 1;
}

.tool-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--surf-chip);
    border: 1px solid rgba(200,164,78,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(var(--surf-ink-rgb),0.4);
    flex-shrink: 0;
    transition: all 0.45s ease;
}

.tool-card:hover .tool-card-icon {
    border-color: rgba(200,164,78,0.3);
    color: var(--accent-text);
    background: rgba(200,164,78,0.06);
}

.tool-card.disabled:hover .tool-card-icon {
    border-color: rgba(200,164,78,0.12);
    color: rgba(var(--surf-ink-rgb),0.4);
    background: var(--surf-chip);
}

.tool-card.featured .tool-card-icon {
    background: rgba(200,164,78,0.08);
    border-color: rgba(200,164,78,0.2);
    color: var(--accent-text);
}

.tool-card-body {
    flex: 1;
}

.tool-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--surf-ink);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
    font-family: var(--font-ui);
}

.tool-card-desc {
    font-size: 13px;
    color: rgba(var(--surf-ink-rgb),0.72);
    line-height: 1.7;
    font-weight: 400;
}

.tool-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tool-card-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(200,164,78,0.1);
    color: var(--accent-text);
    letter-spacing: 0.04em;
}

.tool-card-badge.outline {
    background: transparent;
    border: 1px solid rgba(var(--surf-ink-rgb),0.14);
    color: rgba(var(--surf-ink-rgb),0.42);
}

.tool-card-arrow {
    color: rgba(var(--surf-ink-rgb),0.2);
    font-size: 18px;
    transition: all 0.35s ease;
    font-family: "Playfair Display", serif;
}

.tool-card:hover .tool-card-arrow {
    color: var(--accent-text);
    transform: translateX(4px);
}

.tool-card.disabled:hover .tool-card-arrow {
    color: rgba(var(--surf-ink-rgb),0.2);
    transform: none;
}

.landing-footer {
    text-align: center;
    padding: 72px 0 0;
    font-size: 12px;
    color: rgba(var(--surf-ink-rgb),0.4);
    letter-spacing: 0.06em;
    font-weight: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.landing-icp a {
    color: rgba(var(--surf-ink-rgb),0.35);
    text-decoration: none;
    transition: color 0.2s;
}

.landing-icp a:hover {
    color: rgba(var(--surf-ink-rgb),0.7);
}

/* ============================================================
   CHAT PAGE LAYOUT
   ============================================================ */

.chat-layout {
    display: flex;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background: var(--bg);
    background-image: var(--bg-gradient);
    font-family: var(--font-ui);
}

.chat-layout.visible {
    display: flex;
}

.landing.hidden {
    display: none;
}

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

.app {
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* === SIDEBAR === */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--glass);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-back-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 8px;
    width: 100%;
}

.sidebar-back-btn:hover {
    background: var(--accent-light);
    border-color: var(--amber);
    color: var(--accent-text);
}

.sidebar-new-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-new-btn:hover {
    background: var(--accent-light);
    border-color: var(--amber);
    color: var(--accent-text);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-list::-webkit-scrollbar { width: 3px; }
.sidebar-list::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
    user-select: none;
}

.conv-item:hover {
    background: var(--surface);
    color: var(--text);
}

.conv-item.active {
    background: var(--accent-light);
    color: var(--text);
}

.conv-icon { flex-shrink: 0; opacity: 0.5; }
.conv-item.active .conv-icon { opacity: 1; color: var(--accent-text); }

.conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-del {
    width: 22px; height: 22px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.conv-item:hover .conv-del { display: flex; }
.conv-del:hover { background: var(--danger-bg); color: var(--danger); }

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--glass-border);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-brand { font-weight: 500; }

.sidebar-icp a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
    opacity: 0.7;
    font-size: 11px;
}

.sidebar-icp a:hover {
    opacity: 1;
}

/* === HEADER === */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    flex-shrink: 0;
    background: var(--glass);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #E8C96A, #C8A44E);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #1A1206;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    font-family: var(--font-ui);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.mobile-chat-actions {
    display: none;
}

.mobile-header-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.mobile-header-btn:hover {
    background: var(--accent-light);
    border-color: var(--amber);
    color: var(--accent-text);
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--surface);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
    font-family: inherit;
    color: var(--text-secondary);
    font-size: 13px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-btn:hover {
    background: var(--accent-light);
    color: var(--accent-text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.header-btn:active { transform: scale(0.97); }
.header-btn-icon { font-size: 16px; line-height: 1; }
.header-btn-label { font-size: 13px; font-weight: 500; }

/* === CHAT CONTAINER === */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* === WELCOME === */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 40px 20px;
    animation: welcomeReveal 0.8s cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

.welcome-icon {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, #E8C96A, #C8A44E, #A07E34);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    margin-bottom: 24px;
    box-shadow: 0 12px 40px rgba(200,164,78,0.22);
    animation: gentleBloom 4s ease-in-out infinite;
}

@keyframes gentleBloom {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.welcome h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
    font-family: var(--font-ui);
    letter-spacing: 0.03em;
}

.welcome p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.8;
    margin-bottom: 32px;
    font-weight: 300;
}

.suggestion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 520px;
}

.suggestion-tag {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
    font-weight: 400;
}

.suggestion-tag:hover {
    background: var(--surface);
    border-color: var(--amber);
    color: var(--accent-text);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(200,164,78,0.1);
}
.suggestion-tag:active { transform: translateY(0) scale(0.98); }

/* === MESSAGES === */
.message {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.75;
    word-wrap: break-word;
    animation: messageIn 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
    position: relative;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
    background: var(--user-bubble);
    color: var(--user-bubble-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.message.user + .message.user {
    margin-top: 2px;
    border-top-right-radius: var(--radius-md);
}

.message.assistant {
    background: var(--assistant-bubble);
    border: 1px solid var(--assistant-bubble-border);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-glass);
}

.message.assistant + .message.assistant {
    margin-top: 2px;
    border-top-left-radius: var(--radius-md);
}

.message.assistant:not(.streaming) { padding-bottom: 40px; }

.message-actions {
    position: absolute;
    bottom: 6px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

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

.message-actions button {
    width: 28px; height: 28px;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: var(--glass);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.message-actions button:hover {
    background: var(--surface);
    color: var(--accent-text);
    border-color: var(--amber);
    transform: translateY(-1px);
}

.message-actions button.copied {
    color: #7BA05B;
    border-color: rgba(123,160,91,0.3);
    background: var(--primary-light);
}

.message-timestamp {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.message.user .message-timestamp { color: rgba(241,230,204,0.55); }

.message-files {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.file-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--hairline-fill);
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.user .file-tag {
    background: rgba(200,164,78,0.16);
    color: #D9CBA6;
}

.file-tag svg {
    flex-shrink: 0;
}

/* === MARKDOWN === */
.message-content p { margin: 0 0 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 6px 0; padding-left: 20px; }
.message-content li { margin-bottom: 3px; }

.message-content code {
    background: rgba(200,164,78,0.12);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
    color: var(--accent-text);
}

.message.user .message-content code {
    background: var(--hairline-fill);
    color: var(--user-bubble-text);
}

.message-content pre {
    background: #0A0B10;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 10px 0;
    overflow-x: auto;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: #D4CFC6;
    font-size: 13px;
    line-height: 1.6;
}

.message-content strong { font-weight: 700; }

.message-content a {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(200,164,78,0.3);
}
.message.user .message-content a { color: rgba(var(--surf-ink-rgb),0.85); }

.message-content blockquote {
    border-left: 3px solid var(--amber);
    padding-left: 14px;
    margin: 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 14px 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 13px;
}

.message-content th, .message-content td {
    border: 1px solid var(--glass-border);
    padding: 6px 10px;
    text-align: left;
}

.message-content th {
    background: var(--accent-light);
    font-weight: 600;
}

.message-content h1, .message-content h2, .message-content h3 {
    margin: 14px 0 8px;
    font-weight: 700;
    line-height: 1.3;
    font-family: var(--font-ui);
}

.message-content h1 { font-size: 18px; }
.message-content h2 { font-size: 16px; }
.message-content h3 { font-size: 15px; }

/* === TYPING INDICATOR === */
.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: var(--assistant-bubble);
    border: 1px solid var(--assistant-bubble-border);
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-glass);
}

.typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--amber);
    animation: typingPulse 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* === INPUT AREA === */
.input-area {
    padding: 14px 20px 18px;
    flex-shrink: 0;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: 6px 6px 6px 18px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(200,164,78,0.08), var(--shadow-md);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.6;
}

#messageInput::placeholder { color: var(--text-muted); }

#sendBtn {
    width: 40px; height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8C96A, #C8A44E);
    color: #1A1206;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color var(--transition), box-shadow var(--transition), transform var(--transition);
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(200,164,78,0.28);
}

#sendBtn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 4px 18px rgba(200,164,78,0.4);
}
#sendBtn:active:not(:disabled) { transform: scale(0.95); }
#sendBtn:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.4;
}

.input-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    padding: 6px 4px 0;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

#convStatus {
    font-size: 11px;
    color: var(--accent-text);
    font-weight: 500;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === BRAND SELECTOR === */

.brand-selector {
    position: relative;
    flex-shrink: 0;
}

.brand-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: var(--glass);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.brand-selector-btn:hover {
    background: var(--accent-light);
    border-color: var(--amber);
    color: var(--accent-text);
}

.brand-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.dot-auto { background: #7BA05B; }
.dot-haidebao { background: var(--amber); }
.dot-none { background: var(--text-muted); }

.brand-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    min-width: 240px;
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 4px;
}

.brand-dropdown.open { display: block; }

.brand-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.brand-dropdown-item:hover { background: var(--accent-light); }

.brand-dropdown-item.active {
    background: var(--accent-light);
}

.brand-item-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}

.brand-item-desc {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

.brand-dropdown-item.active .brand-item-label { color: var(--accent-text); }

.brand-star {
    background: none;
    border: none;
    padding: 0 0 0 4px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color var(--transition);
    user-select: none;
}
.brand-star:hover { color: var(--accent-text); }
.brand-star.active { color: var(--accent-text); }

@media (max-width: 640px) {
    .brand-selector-btn { font-size: 10px; padding: 1px 6px; }
}

/* === CONNECTION STATUS === */
.connection-status {
    position: fixed;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    transition: all var(--transition);
    pointer-events: none;
}

.connection-status.show { opacity: 1; pointer-events: auto; }

.connection-status.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.connection-status.connecting {
    background: var(--warm-light);
    color: var(--warm);
    border: 1px solid rgba(193,123,78,0.2);
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 9, 13, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-ui);
    letter-spacing: 0.02em;
}

.modal-close {
    width: 30px; height: 30px;
    font-size: 14px;
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-section { margin-bottom: 22px; }
.modal-section:last-child { margin-bottom: 0; }

.modal-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

/* === CHANGELOG === */

.changelog-body {
    max-height: 60vh;
    overflow-y: auto;
}

.changelog-entry {
    padding: 18px 0;
    border-bottom: 1px solid var(--glass-border);
}

.changelog-entry:last-child { border-bottom: none; }

.changelog-version {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-ui);
}

.changelog-date {
    font-size: 11px;
    color: var(--text-muted);
    margin: 2px 0 10px;
}

.changelog-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.changelog-items li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    padding: 3px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.changelog-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 3px;
    line-height: 1.5;
}

.changelog-tag.new { background: var(--primary-light); color: #7BA05B; }
.changelog-tag.fix { background: var(--accent-light); color: var(--accent-text); }
.changelog-tag.change { background: var(--warm-light); color: var(--warm); }

/* === BUTTONS === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #E8C96A, #C8A44E);
    color: #1A1206;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: opacity var(--transition), box-shadow var(--transition), transform var(--transition);
    white-space: nowrap;
}

.btn-primary:hover {
    opacity: 0.94;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(200,164,78,0.3);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--glass);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), transform var(--transition);
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--amber);
}
.btn-secondary:active { transform: scale(0.98); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.icon-btn {
    width: 32px; height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--surface);
    color: var(--text);
}
.icon-btn:active { transform: scale(0.95); }

/* === UPLOAD ZONE === */
.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--glass);
}

.upload-zone:hover {
    border-color: var(--amber);
    background: var(--accent-light);
}

.upload-zone.dragover {
    border-color: var(--amber);
    background: var(--accent-light);
    transform: scale(1.01);
}

.upload-icon { font-size: 32px; margin-bottom: 8px; }

.upload-text {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}

.upload-hint { font-size: 12px; color: var(--text-muted); }

.upload-status {
    margin-top: 8px;
    font-size: 13px;
    min-height: 0;
    transition: all var(--transition);
}

.upload-status.success { color: #7BA05B; }
.upload-status.error { color: var(--danger); }
.upload-status .file-name { font-weight: 500; }

/* === WIKI ACTIONS === */
.wiki-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wiki-action-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: var(--glass);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    font-family: inherit;
}

.wiki-action-btn:hover {
    background: var(--surface);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.wiki-action-btn:active { transform: translateY(0); }
.wiki-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wiki-action-btn.primary .action-icon { font-size: 20px; }
.wiki-action-btn.secondary .action-icon { font-size: 20px; }

.action-text {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.action-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === WIKI LOG === */
.wiki-log {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 14px;
    max-height: 160px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
}

.log-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 8px;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.log-entry:last-child { border-bottom: none; }

.log-time {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 2px;
}

.log-msg { color: var(--text); word-break: break-all; white-space: pre-wrap; }
.log-msg.success { color: #7BA05B; }
.log-msg.error { color: var(--danger); }
.log-msg.warning { color: #C9A227; }

/* === SPINNER === */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* === MODAL LARGE === */
.modal-lg { max-width: 660px; }

/* === SETTINGS === */
.settings-provider-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.settings-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.provider-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.provider-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

.provider-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.provider-card.active {
    border-color: var(--amber);
    background: var(--accent-light);
}

.provider-card-info { flex: 1; min-width: 0; }

.provider-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.provider-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.provider-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.provider-btn {
    padding: 5px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.provider-btn:hover { background: var(--surface); color: var(--text); }

.provider-btn.active-btn {
    background: var(--amber);
    border-color: var(--amber);
    color: #1A1206;
}

.provider-btn.danger { color: var(--danger); }
.provider-btn.danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

.provider-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-lg);
    background: var(--amber);
    color: #1A1206;
    font-size: 10px;
    font-weight: 600;
}

/* === PROVIDER EDITOR === */
.editor-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 18px 0;
}

.editor-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 12px 0 18px;
}

.field-row { display: flex; gap: 12px; }

.field-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.field-input {
    padding: 9px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.field-input:focus { border-color: var(--amber); }
.field-input::placeholder { color: var(--text-muted); }

.field-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.editor-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* === SKILL SELECTOR === */
.skill-selector { position: relative; }

.skill-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 170px;
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.skill-dropdown.open { display: block; }

.skill-dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.skill-dropdown-item:hover { background: var(--accent-light); }

.skill-dropdown-item.active {
    background: var(--accent-light);
    color: var(--accent-text);
    font-weight: 500;
}

.skill-dropdown-item::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 8px;
    background: var(--text-muted);
    vertical-align: middle;
}

.skill-dropdown-item.active::before { background: var(--amber); }
.skill-dropdown-item[data-skill=""]::before { background: #7BA05B; }

/* === MODEL SWITCHER === */
.model-switcher { position: relative; }

.model-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 210px;
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 6px;
    margin-top: 4px;
}

.model-dropdown.open { display: block; }

.model-dropdown-group { padding: 6px 0; }
.model-dropdown-group + .model-dropdown-group {
    border-top: 1px solid var(--glass-border);
}

.model-dropdown-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 6px 10px 4px;
}

.model-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.model-dropdown-item:hover { background: var(--accent-light); }

.model-dropdown-item.active {
    background: var(--accent-light);
    color: var(--accent-text);
    font-weight: 500;
}

.model-dropdown-item .model-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.model-dropdown-item.active .model-dot { background: var(--amber); }
.model-dropdown-item .model-name { flex: 1; }

.model-dropdown-item .model-check {
    font-size: 12px;
    color: var(--accent-text);
    opacity: 0;
}

.model-dropdown-item.active .model-check { opacity: 1; }

/* === PARAMETER CONTROLS === */
.param-controls {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.param-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.param-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.param-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-text);
    min-width: 30px;
    text-align: right;
}

.param-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.param-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--glass-border);
    outline: none;
    cursor: pointer;
}

.param-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8C96A, #C8A44E);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(200,164,78,0.35);
    transition: transform 0.15s;
}

.param-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.param-slider::-moz-range-thumb {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #E8C96A, #C8A44E);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(200,164,78,0.35);
}

.param-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 2px;
}

.param-input {
    padding: 9px 12px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--glass);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    max-width: 160px;
}

.param-input:focus { border-color: var(--amber); }

/* === TOGGLE === */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    width: 44px; height: 24px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--text-muted);
    border-radius: 24px;
    transition: all var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: #FBF6ED;
    border-radius: 50%;
    transition: all var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #C8A44E, #8A6D2E);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(200,164,78,0.18);
}

/* === THINKING BLOCK === */
.thinking-block {
    margin-bottom: 14px;
    background: var(--hairline-fill);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.thinking-block summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
}

.thinking-block summary:hover { color: var(--text-secondary); }

.thinking-content {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.7;
    white-space: pre-wrap;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
}

.message.thinking .thinking-content {
    color: var(--text-secondary);
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 100;
    padding: 10px 18px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    background: #1C1D28;
    color: #F0EAE0;
    border: 1px solid rgba(200,164,78,0.2);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === HISTORY MODAL === */
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#historyList {
    max-height: 60vh;
    overflow-y: auto;
}

.history-round {
    margin-bottom: 16px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.history-round:last-child { margin-bottom: 0; }

.history-round-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 14px;
    background: var(--glass);
    border-bottom: 1px solid var(--glass-border);
}

.history-exchange {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-msg {
    display: flex;
    gap: 8px;
    font-size: 13px;
    line-height: 1.6;
}

.history-msg-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 20px;
    padding-top: 1px;
}

.history-msg.user .history-msg-label { color: var(--sage); }
.history-msg.assistant .history-msg-label { color: var(--accent-text); }

.history-msg-text {
    color: var(--text);
    word-break: break-word;
    white-space: pre-wrap;
}

/* === SHIMMER === */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(90deg,
        var(--glass) 25%,
        var(--surface) 50%,
        var(--glass) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ============================================================
   IMAGE UPLOAD & PREVIEW
   ============================================================ */

.input-icon-btn {
    width: 36px; height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.input-icon-btn:hover {
    background: var(--accent-light);
    color: var(--accent-text);
}

.image-preview {
    display: none;
    gap: 8px;
    padding: 8px 6px 0;
    flex-wrap: wrap;
}

.image-preview-item {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    flex-shrink: 0;
}

.image-preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px; height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.image-preview-item:hover .image-preview-remove {
    opacity: 1;
}

.image-preview-size {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 9px;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.3;
}

/* === IMAGES IN MESSAGE BUBBLES === */

.message-images {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.message-image-wrap {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.message-image-wrap:hover {
    transform: scale(1.03);
}

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

.message.user .message-image-wrap {
    border-color: rgba(200,164,78,0.25);
}


@media (max-width: 640px) {
    .message-image-wrap {
        width: 90px;
        height: 90px;
    }
}

/* ============================================================
   FILE UPLOAD & PREVIEW
   ============================================================ */

.file-preview {
    display: none;
    gap: 6px;
    padding: 4px 6px 0;
    flex-wrap: wrap;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    flex-shrink: 0;
    animation: fileIn 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

.file-preview-item.uploading {
    opacity: 0.7;
}

.file-preview-icon {
    color: var(--accent-text);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.file-preview-name {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    font-weight: 500;
}

.file-preview-remove {
    width: 18px; height: 18px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
}

.file-preview-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Skill editor upload zone */
.skill-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px;
    margin-top: 8px;
    border: 1.5px dashed var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--glass);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
    font-size: 13px;
}
.skill-upload-zone:hover,
.skill-upload-zone.dragover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--glass));
    color: var(--text);
}
.skill-upload-zone.dragover .upload-zone-icon svg {
    stroke: var(--accent);
}
.upload-zone-icon svg {
    transition: stroke 0.2s;
}

/* ============================================================
   MULTIMODAL CONFIG
   ============================================================ */

.multimodal-config {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.multimodal-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.multimodal-card.active {
    border-color: var(--amber);
    background: var(--accent-light);
}

.multimodal-card-indicator {
    display: none;
}

.multimodal-card-info {
    flex: 1;
    min-width: 0;
}

.multimodal-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.multimodal-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.multimodal-card-actions {
    flex-shrink: 0;
}

.multimodal-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    font-size: 12px;
}

.multimodal-info-label {
    color: var(--text-muted);
}

.multimodal-info-value {
    color: var(--text);
    font-weight: 500;
}

.multimodal-editor-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.toggle-label {
    font-size: 13px;
    color: var(--text);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .tool-grid {
        grid-template-columns: 1fr;
        max-width: 400px;
    }

    .hero {
        padding: 56px 0 44px;
    }

    .hero-title {
        font-size: 36px;
    }

    .hero-desc {
        font-size: 15px;
    }

    .landing-content {
        padding: 16px 20px 48px;
    }
}

@media (max-width: 640px) {
    .chat-layout { flex-direction: column; }
    .sidebar { display: none; }

    .layout { max-width: none; }
    .app { max-width: none; }

    header {
        padding: 10px 14px 8px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .brand {
        flex: 1 1 auto;
        max-width: calc(100% - 88px);
    }

    .brand-text {
        flex: 1;
    }

    .brand-name { font-size: 15px; }
    .brand-icon { width: 32px; height: 32px; font-size: 16px; }
    .brand-subtitle { display: none; }

    .mobile-chat-actions {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    .header-actions {
        order: 3;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .header-actions::-webkit-scrollbar { display: none; }

    .header-actions > * {
        flex: 0 0 auto;
    }

    .header-btn {
        padding: 7px 11px;
        border-radius: var(--radius-sm);
        white-space: nowrap;
    }

    .header-btn-label {
        font-size: 12px;
    }

    .chat-container { padding: 14px; }

    .welcome { padding: 24px 16px; }
    .welcome-icon {
        width: 64px; height: 64px;
        font-size: 30px;
        border-radius: 22px;
    }
    .welcome h2 { font-size: 20px; }

    .suggestion-tag {
        font-size: 12px;
        padding: 8px 16px;
        white-space: normal;
    }

    .message {
        max-width: 90%;
        font-size: 13px;
        padding: 12px 14px;
    }

    .input-area { padding: 10px 14px 14px; }
    .input-wrapper { padding: 4px 4px 4px 12px; }

    .message.assistant:not(.streaming) { padding-bottom: 32px; }

    .field-row { flex-direction: column; gap: 12px; }
    .settings-provider-header { flex-direction: column; }
    .provider-card { flex-wrap: wrap; }
    .provider-card-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 4px;
    }

    .skill-dropdown.open,
    .model-dropdown.open {
        position: fixed;
        top: 96px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
        bottom: auto;
        min-width: 200px;
        max-width: calc(100vw - 32px);
    }
}

@media (min-width: 1024px) {
    .app { padding: 0 20px; }
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */

/* Show the icon of the mode you'll switch TO: sun in dark, moon in light. */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-flex; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: inline-flex; }

.theme-toggle-icon { display: inline-flex; align-items: center; }

/* Landing nav variant */
.landing-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--landing-border);
    border-radius: 50%;
    background: var(--landing-card);
    color: var(--surf-ink);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition), background-color var(--transition);
}

.landing-theme-toggle:hover {
    border-color: var(--amber);
    color: var(--accent-text);
    background: var(--landing-card-hover);
}

/* Auth page variant — top-right corner */
.auth-theme-toggle {
    position: absolute;
    top: 22px;
    right: 22px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--surf-border, var(--landing-border));
    border-radius: 50%;
    background: var(--surf-card);
    color: var(--surf-ink);
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color var(--transition), color var(--transition), transform var(--transition);
}

.auth-theme-toggle:hover {
    border-color: var(--amber);
    color: var(--accent-text);
    transform: translateY(-1px);
}

/* ============================================================
   FOCUS VISIBLE — keyboard navigation
   ============================================================ */

:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
    border-radius: 4px;
}

.auth-input:focus-visible,
.field-input:focus-visible,
.param-input:focus-visible {
    outline: none;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .landing-orb { animation: none; }
    .hero { animation: none; opacity: 1; transform: none; }
    .welcome { animation: none; opacity: 1; transform: none; }
    .welcome-icon { animation: none; }
    .message { animation: none; opacity: 1; transform: none; }
    .typing-dot { animation: none; opacity: 0.6; transform: none; }
    .shimmer { animation: none; }
    .modal { animation: none; opacity: 1; transform: none; }
    .modal-overlay { animation: none; }
    .file-preview-item { animation: none; }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
