:root {

    --accent: #1F6B5C;
    --accent-hover: #0F766E;
    --accent-bg: rgba(31,107,92,0.08);
    --accent-bg-strong: rgba(31,107,92,0.14);
    --bg: #FFFFFF;
    --sidebar-bg: #F3F8F6;
    --surface: #FFFFFF;
    --surface-raised: #ffffff;
    --surface-hover: #F3F8F6;
    --text: #111827;
    --text-2: #4B5563;
    --text-3: #6B7280;
    --text-4: #9CA3AF;

    --text-inv: #fff;

    --topbar-bg: #163F38;
    --topbar-text: #FFFFFF;
    --topbar-sub: #D1D5DB;

    --border: #DCE7E2;
    --shadow-1: 0 1px 2px rgba(28,33,31,0.03);
    --shadow-2: 0 4px 18px rgba(28,33,31,0.05);
    --shadow-3: 0 10px 30px rgba(28,33,31,0.08);
    --shadow-input: none;
    --shadow-input-focus: 0 0 0 3px rgba(31,107,92,0.12);
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 16px;

    --radius-full: 9999px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    font-size: 17px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Top Bar ===== */
.topbar {
    height: 48px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 20;
    background: var(--topbar-bg);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo {
    display: flex;
    align-items: center;
}

.topbar-logo img { height: 26px; }

.topbar-divider {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.2);
}

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

.topbar-edition {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.topbar-edition.edition-free {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
}

.topbar-edition.edition-standard {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;

}
.text-btn {
 height: 34px;
 padding: 0 12px;
 display: inline-flex;
 align-items: center;
 justify-content: center;
 border-radius: 8px;
 border: 1px solid transparent;
 background: transparent;
 color: var(--topbar-text);
 font-size: 12.5px;
 font-family: inherit;
 font-weight: 600;
 cursor: pointer;
 transition: all 0.15s;
}
.text-btn:hover {
 color: var(--topbar-text);
 background: rgba(255,255,255,0.1);
 border-color: rgba(255,255,255,0.15);
}

.menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--topbar-sub);
    cursor: pointer;
    transition: all 0.15s;
}
.menu-btn:hover { color: var(--topbar-text); background: rgba(255,255,255,0.1); }
@media (max-width: 768px) {
    .menu-btn { display: flex; }
}

.mode-dropdown {
    display: none;
    position: relative;
}
.mode-dropdown.active { display: inline-flex; }

.mode-select {
    height: 34px;
    padding: 0 28px 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: var(--topbar-text);
    font-size: 12.5px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all 0.15s;
}
.mode-select option {
    background: #FFFFFF;
    color: var(--text);
}
.mode-select:hover {
    color: var(--topbar-text);
    background-color: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}
.mode-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.15s;
}

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

.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== Main ===== */
.main {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
}

/* ===== Drawer ===== */
.drawer-backdrop {
    display: none;
}

.drawer {
    width: 400px;
    min-width: 400px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 768px) {
    .drawer-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.2);
        backdrop-filter: blur(2px);
        z-index: 50;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }
    .drawer-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
    .drawer {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 51;
        border-right: none;
        box-shadow: var(--shadow-3);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .drawer.open {
        transform: translateX(0);
    }
}

.drawer-header {
    padding: 16px 20px;
    display: none;
    align-items: center;
    justify-content: space-between;
}
@media (max-width: 768px) {
    .drawer-header { display: flex; }
}

.drawer-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.drawer-close {
    width: 30px;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 18px;
}

.drawer-close:hover { background: var(--surface-hover); color: var(--text); }

@media (max-width: 768px) {
    .drawer-close { display: flex; }
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 20px;
}

.drawer-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

.drawer-section {
    margin-bottom: 24px;
}

.drawer-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.drawer-text {
    font-size: 14.5px;
    color: var(--text);
    line-height: 1.85;
}

.drawer-text a {
    color: var(--accent);
    text-decoration: none;
}

.drawer-text a:hover { text-decoration: underline; }

.terms-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(31,107,92,0.25);
    padding-bottom: 1px;
    transition: border-color 0.15s;
}
.terms-link:hover {
    border-color: var(--accent);
}

.ref-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.ref-chip {
    font-size: 12.5px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: var(--accent-bg);
    color: var(--accent);
    text-decoration: none;
    transition: background 0.15s;
}

.ref-chip:hover { background: var(--accent-bg-strong); }

.ref-list {
    list-style: none;
    font-size: 14px;
    color: var(--text-2);
}

.ref-list li {
    padding: 4px 0 4px 16px;
    position: relative;
}

.ref-list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 13px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-4);
}

.ref-list .abbr { color: var(--text-3); font-size: 12.5px; }

/* ===== Chat ===== */
.chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: auto;
}

.chat-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 24px 24px;
}

/* --- Welcome --- */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 24px 28px;
    text-align: center;
    max-width: 960px;
    margin: 0 auto;
}

.welcome-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-bg);
    border: 1px solid rgba(31,107,92,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    flex-shrink: 0;
}

.welcome-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.welcome-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.welcome-copy {
    min-width: 0;
}

.eyebrow {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 6px;
}

.welcome h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 32px;
}

.welcome-sub {
    font-size: 16px;
    color: var(--text-3);
    max-width: 620px;
    margin-bottom: 32px;
}

.welcome-cards-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    max-width: 620px;
    width: 100%;
    margin: 0 auto 8px;
    text-align: left;
}

.welcome-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 620px;
    width: 100%;
    margin: 0 auto 32px;
}

.welcome-card {
    background: var(--surface);
    border-radius: 10px;
    padding: 14px 16px 14px 18px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
}

.welcome-card:hover {
    background: var(--surface-raised);
    border-color: rgba(31,107,92,0.20);
    transform: translateY(-1px);
}

.welcome-card-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
}

.welcome-notice {
    font-size: 13px;
    color: var(--text-4);
}

/* --- Trust badges --- */
.trust-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 24px;
}

.trust-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(31,107,92,0.06);
    border: 1px solid rgba(31,107,92,0.10);
    padding: 5px 14px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 5px;
}

.trust-badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* --- Topic chips --- */
.topic-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 28px;
}

.topic-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-4);
    white-space: nowrap;
}

.topic-chip {
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    padding: 4px 13px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-3);
    cursor: pointer;
    transition: all 0.15s;
}

.topic-chip:hover {
    border-color: rgba(31,107,92,0.24);
    color: var(--accent);
    background: rgba(31,107,92,0.05);
}

/* --- Search scope tags --- */
.scope-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.scope-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-4);
    white-space: nowrap;
}

.scope-tag {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-3);
    font-weight: 600;
}

/* --- Messages --- */
.msg {
    margin-bottom: 8px;
    animation: msgIn 0.2s ease-out;
}

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

.msg-user {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}

.msg-user .msg-bubble {
    background: var(--accent);
    color: var(--text-inv);
    padding: 10px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
    max-width: 72%;
    font-size: 16.5px;
    line-height: 1.7;
}

.msg-bot {
    display: flex;
    justify-content: flex-start;
}

.msg-bot .msg-wrap {
    max-width: 100%;
    width: 100%;
    position: relative;
}

.msg-bot .msg-bubble {
    background: var(--surface);
    color: var(--text);
    padding: 20px 24px;
    border-radius: 12px;
    max-width: 100%;
    width: 100%;
    font-size: 17px;
    line-height: 1.85;
    box-shadow: none;
    border: 1px solid var(--border);
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-raised);
    color: var(--text-4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.msg-bot .msg-wrap:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); background: var(--surface-hover); }
.copy-btn svg { width: 16px; height: 16px; }

/* --- Bot markdown --- */
.msg-bot .msg-bubble strong { color: var(--text); font-weight: 600; }

.msg-bot .md-h1 {
    font-size: 19px; font-weight: 700; color: var(--text);
    margin: 20px 0 8px; padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-bg-strong);
}
.msg-bot .md-h2 {
    font-size: 18px; font-weight: 600; color: var(--text);
    margin: 18px 0 6px;
}
.msg-bot .md-h3 {
    font-size: 17px; font-weight: 600; color: var(--accent);
    margin: 14px 0 4px;
}
.msg-bot .md-h1:first-child, .msg-bot .md-h2:first-child, .msg-bot .md-h3:first-child { margin-top: 0; }

.msg-bot .md-list { margin: 8px 0; padding-left: 22px; }
.msg-bot .md-list li { margin-bottom: 3px; }

.msg-bot .md-blockquote {
    border-left: 3px solid var(--accent-bg-strong);
    background: var(--sidebar-bg);
    padding: 10px 16px; margin: 12px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-2); font-size: 14px;
}

.msg-bot .md-note {
    background: var(--accent-bg);
    border-left: 3px solid var(--accent);
    padding: 10px 16px; margin: 12px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 14px;
}

.msg-bot .md-warning {
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    padding: 10px 16px; margin: 12px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 14px;
}

.msg-bot .md-hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.msg-bot p { margin-bottom: 6px; }
.msg-bot p:last-child { margin-bottom: 0; }

/* --- Citations --- */
.citations {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--sidebar-bg);
    border-radius: var(--radius);
}

.citations-title {
    font-size: 11px; font-weight: 700;
    color: var(--text-4); text-transform: uppercase;
    letter-spacing: 0.08em; margin-bottom: 8px;
}

.citation {
    display: block;
    padding: 7px 12px;
    margin-bottom: 4px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    transition: background 0.15s;
}

.citation:hover { background: var(--accent-bg); }
.citation-text { color: var(--text-2); }

/* --- Article link --- */
.article-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    background: var(--accent-bg);
    padding: 1px 5px;
    border-radius: 4px;
    transition: all 0.15s;
}
.article-link:hover { background: var(--accent); color: #fff; }

/* ===== Scroll-to-bottom ===== */
.jump-bottom {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: none;
    padding: 6px 18px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-2);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-3);
    display: none;
    align-items: center;
    gap: 4px;
    z-index: 5;
    transition: all 0.15s;
}

.jump-bottom:hover { color: var(--text); box-shadow: var(--shadow-3); }
.jump-bottom.visible { display: flex; }
.jump-bottom svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ===== Input Dock ===== */
.input-dock {
    flex-shrink: 0;
    padding: 0 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-box {
    max-width: 960px;
    width: 100%;
}

/* mode */
.mode-bar {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.mode-bar.active { display: flex; }

.mode-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-4);
}

.mode-switch {
    display: flex;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2px;
}

.mode-opt {
    padding: 4px 14px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-3);
    background: none;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.15s;
}

.mode-opt.on {
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
    border: 1px solid var(--border);
}

.mode-opt:hover:not(.on) { color: var(--text-2); }

/* input field */
.input-field {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface);
    border-radius: 14px;
    padding: 6px 6px 6px 20px;
    box-shadow: var(--shadow-input);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.input-field:focus-within {
    box-shadow: var(--shadow-input-focus);
}

.input-field textarea {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16.5px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
    padding: 8px 0;
    resize: none;
    min-height: 120px;
    max-height: 220px;
    line-height: 1.5;
    overflow-y: auto;
}

.input-field textarea::placeholder { color: var(--text-4); }

.send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { background: var(--text-4); cursor: not-allowed; transform: none; }
.send-btn span { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.send-btn svg { width: 18px; height: 18px; fill: currentColor; }
.send-btn.stop-mode { background: #c0392b; }
.send-btn.stop-mode:hover { background: #a93226; }
.send-btn.stop-mode svg { fill: #fff; width: 30px; height: 30px; }

.input-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-4);
    margin-top: 8px;
}

/* loading */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-4);
    font-size: 14px;
    padding: 20px 24px;
}

.dots { display: flex; gap: 4px; }
.dots span {
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.4s infinite ease-in-out both;
}
.dots span:nth-child(1) { animation-delay: -0.32s; }
.dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes pulse { 0%,80%,100% { transform: scale(0); } 40% { transform: scale(1); } }

.warn-box {
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 14.5px;
}

/* ===== History Panel ===== */
.history-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.2);
    backdrop-filter: blur(2px);
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.history-backdrop.open { opacity: 1; pointer-events: auto; }

.history-panel {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 320px;
    background: var(--surface);
    box-shadow: var(--shadow-3);
    z-index: 61;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.history-panel.open { transform: translateX(0); }

.history-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.history-title { font-size: 14px; font-weight: 600; color: var(--text); }
.history-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius); border: none;
    background: transparent; color: var(--text-3);
    cursor: pointer; font-size: 18px;
}
.history-close:hover { background: var(--surface-hover); color: var(--text); }

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}
.history-empty {
    text-align: center;
    color: var(--text-4);
    font-size: 13px;
    padding: 40px 16px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}
.history-item:hover { background: var(--surface-hover); }
.history-item.active { background: var(--accent-bg); }

.history-item-body {
    flex: 1;
    min-width: 0;
}
.history-item-title {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item.active .history-item-title { color: var(--accent); font-weight: 600; }
.history-item-date {
    font-size: 11px;
    color: var(--text-4);
    margin-top: 2px;
}

.history-item-del {
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px; border: none;
    background: transparent; color: var(--text-4);
    cursor: pointer; font-size: 14px;
    opacity: 0; transition: opacity 0.12s, color 0.12s;
    flex-shrink: 0;
}
.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { color: #c0392b; background: rgba(192,57,43,0.08); }

.history-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.history-clear-btn {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-3);
    font-size: 12.5px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.history-clear-btn:hover { color: #c0392b; border-color: #c0392b; background: rgba(192,57,43,0.04); }

/* ===== Auth Overlay ===== */
.auth-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}
.auth-overlay.active { display: flex; }

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 40px 36px 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-3);
}

.auth-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--accent);
}

.auth-card h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 24px;
}

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

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.auth-input:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-input-focus);
}
.auth-input::placeholder { color: var(--text-4); }

.auth-btn {
    width: 100%;
    height: 44px;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.auth-btn:hover { background: var(--accent-hover); }
.auth-btn:disabled { background: var(--text-4); cursor: not-allowed; }

.auth-error {
    margin-top: 12px;
    font-size: 13px;
    color: #c0392b;
    min-height: 20px;
}

.auth-back {
    display: inline-block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.15s;
}
.auth-back:hover { color: var(--text); }

/* ===== Mobile ===== */
@media (max-width: 640px) {
    .welcome h1 { font-size: 26px; }
    .welcome-head { align-items: flex-start; }
    .welcome-cards { grid-template-columns: 1fr; }
    .msg-user .msg-bubble { max-width: 88%; }
    .chat-inner { padding: 16px; }
    .input-dock { padding: 0 12px 14px; }

    .history-panel { width: 100%; }
    .send-btn { width: 40px; height: 40px; min-width: 40px; }
    .send-btn span { font-size: 12px; }
}
