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

:root {
    --primary: #006947;
    --primary-dark: #00543a;
    --ink: #0b1c30;
    --muted: #3c4a42;
    --soft: #f8f8f8;
    --line: rgba(187, 202, 191, 0.42);
    --line-strong: #bbcabf;
    --answer-bg: #ffffff;
    --user-bg: rgba(173, 237, 211, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 18px 45px rgba(0, 105, 71, 0.06);
}

html,
body {
    width: 100%;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #ffffff;
    color: var(--ink);
}

button,
textarea,
input {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #ffffff;
}

.sidebar {
    width: 280px;
    flex: 0 0 280px;
    background: var(--soft);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    transition: flex-basis 180ms ease, width 180ms ease;
}

.sidebar.collapsed {
    width: 100px;
    flex-basis: 100px;
}

.sidebar-header {
    height: 60px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-box {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 40px;
}

.logo-box img {
    width: 40px;
    height: 40px;
}

.logo-text {
    font-size: 24px;
    line-height: 1;
    color: var(--primary);
    font-weight: 800;
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.icon-button:hover {
    background: #edf3ef;
    color: var(--primary);
}

.sidebar-collapse-btn {
    margin-left: auto;
}

.sidebar.collapsed .collapse-icon {
    transform: scaleX(-1);
}

.new-chat-btn {
    height: 48px;
    margin: 16px;
    padding: 0 24px;
    border-radius: 6px;
    color: #ffffff;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 700;
    cursor: pointer;
}

.new-chat-btn:hover,
.send-btn:hover,
.clear-history-btn:hover {
    background: var(--primary-dark);
}

.history-section {
    flex: 1;
    min-height: 0;
    padding: 0 16px;
    overflow: hidden;
}

.history-title {
    padding: 12px;
    color: #6c7a71;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
}

.history-list {
    display: grid;
    gap: 8px;
    overflow-y: auto;
    max-height: calc(100vh - 240px);
    padding-bottom: 8px;
}

.history-item {
    padding: 12px;
    border-radius: 6px;
    background: #ffffff;
    color: var(--muted);
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item:hover,
.history-item.active {
    background: #eef6f1;
    color: var(--primary);
}

.empty-history {
    padding: 10px 12px;
    color: #8c9891;
    font-size: 13px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 4px;
}

.sidebar-link {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-align: left;
}

.sidebar-link:hover {
    background: #edf3ef;
    color: var(--primary);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .new-chat-btn span,
.sidebar.collapsed .history-title,
.sidebar.collapsed .history-list,
.sidebar.collapsed .sidebar-link span {
    display: none;
}

.sidebar.collapsed .new-chat-btn,
.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .history-section {
    padding-left: 8px;
    padding-right: 8px;
}

.main-content {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff;
}

.header {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: 60px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-title {
    font-size: 24px;
    color: var(--primary);
    font-weight: 800;
}

.header-chip {
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--soft);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.header-chip img {
    width: 18px;
    height: 18px;
}

.main-inner {
    width: min(100%, 48rem);
    flex: 1;
    overflow-y: auto;
    padding: 30px 0 118px;
    scroll-behavior: smooth;
}

.welcome-section {
    margin-bottom: 28px;
    padding-bottom: 30px;
    border: 1px solid #d9f1e7;
    border-radius: 8px;
    background-image: radial-gradient(circle at calc(100% - 50px) -40px, rgba(255, 251, 197, 0.45) 0%, transparent 35%), linear-gradient(90deg, #f4fcf8 0%, #ffffff 100%);
}

.welcome-content {
    padding: 38px 33px 0;
}

.welcome-title {
    font-size: 24px;
    line-height: 1.3;
    font-weight: 700;
    margin-bottom: 12px;
}

.welcome-subtitle {
    color: var(--muted);
    font-size: 16px;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    padding: 20px 30px 0;
}

.suggestion-card {
    min-height: 150px;
    padding: 22px;
    border: 1px solid rgba(187, 202, 191, 0.38);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    text-align: left;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.suggestion-card:hover {
    transform: translateY(-1px);
    border-color: #9cc8b5;
    box-shadow: var(--shadow);
}

.suggestion-card img {
    width: 24px;
    height: 24px;
    margin-bottom: 16px;
}

.suggestion-card strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.43;
    margin-bottom: 12px;
}

.suggestion-card span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.messages {
    display: grid;
    gap: 8px;
}

.message-block {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.message-block.user {
    justify-items: end;
}

.message-block.assistant {
    justify-items: start;
}

.bubble {
    max-width: 80%;
    border: 1px solid var(--line);
    font-size: 16px;
    line-height: 1.62;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.user .bubble {
    background: var(--user-bg);
    border-radius: 8px 0 8px 8px;
    padding: 20px 22px;
}

.assistant .bubble {
    background: var(--answer-bg);
    border-radius: 0 8px 8px 8px;
    padding: 22px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.compact .assistant .bubble,
.compact .user .bubble {
    padding: 14px 16px;
    font-size: 14px;
}

.response-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 14px;
}

.response-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    display: grid;
    place-items: center;
}

.response-avatar img {
    width: 28px;
    height: 28px;
}

.message-time {
    width: 80%;
    color: #6c7a71;
    font-size: 10px;
    font-family: "JetBrains Mono", Consolas, monospace;
}

.user .message-time {
    text-align: right;
}

.assistant .message-time {
    text-align: left;
}

.references,
.evidence {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(187, 202, 191, 0.35);
    display: grid;
    gap: 8px;
}

.references h3,
.evidence h3 {
    font-size: 12px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.references a {
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
}

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

.evidence-card {
    padding: 10px 12px;
    border-radius: 8px;
    background: #f8fbf9;
    border: 1px solid rgba(187, 202, 191, 0.32);
}

.evidence-card strong {
    display: block;
    color: var(--ink);
    font-size: 13px;
    margin-bottom: 4px;
}

.evidence-card p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.backend-note {
    margin-top: 12px;
    color: #6c7a71;
    font-size: 12px;
}

.runtime-note {
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(187, 202, 191, 0.42);
    border-radius: 8px;
    background: #f8fbf9;
    color: #5f6f66;
    font-size: 12px;
    line-height: 1.45;
}

.loading-dot {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loading-dot i {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--primary);
    animation: pulse 900ms infinite ease-in-out;
}

.loading-dot i:nth-child(2) {
    animation-delay: 120ms;
}

.loading-dot i:nth-child(3) {
    animation-delay: 240ms;
}

@keyframes pulse {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.floating-input {
    position: absolute;
    left: 50%;
    bottom: 24px;
    width: min(calc(100% - 48px), 48rem);
    transform: translateX(-50%);
    z-index: 25;
}

.input-wrapper {
    padding: 12px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 150px;
    padding: 10px 12px;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.45;
}

.chat-input::placeholder {
    color: #9ca9a3;
}

.send-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 8px;
    background: var(--primary);
    display: grid;
    place-items: center;
    cursor: pointer;
}

.send-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.send-btn img {
    width: 24px;
    height: 24px;
}

.panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(11, 28, 48, 0.22);
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 50;
    width: min(420px, 100vw);
    height: 100vh;
    padding: 22px;
    background: #ffffff;
    border-left: 1px solid var(--line);
    box-shadow: -24px 0 70px rgba(11, 28, 48, 0.16);
    transform: translateX(105%);
    transition: transform 180ms ease;
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    font-size: 24px;
    color: var(--primary);
}

.panel-header p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
}

.panel-close {
    font-size: 26px;
    line-height: 1;
}

.panel-body {
    padding-top: 18px;
    display: grid;
    gap: 14px;
}

.setting-row {
    min-height: 74px;
    padding: 14px;
    border: 1px solid rgba(187, 202, 191, 0.42);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.setting-row strong,
.support-item strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
    margin-bottom: 4px;
}

.setting-row small,
.support-item span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.setting-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.clear-history-btn {
    height: 42px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
}

.support-body {
    gap: 12px;
}

.support-item {
    padding: 14px;
    border: 1px solid rgba(187, 202, 191, 0.42);
    border-radius: 8px;
    background: #fbfdfc;
}

@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        max-height: 214px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar.collapsed {
        width: 100%;
        flex-basis: auto;
        max-height: 60px;
    }

    .history-list {
        max-height: 74px;
    }

    .main-content {
        min-height: 0;
    }

    .main-inner {
        width: 100%;
        padding: 18px 12px 112px;
    }

    .header {
        position: relative;
        flex-wrap: wrap;
        height: auto;
        min-height: 60px;
    }

    .suggestions-grid {
        grid-template-columns: 1fr;
        padding: 16px 16px 0;
    }

    .welcome-content {
        padding: 28px 18px 0;
    }

    .bubble,
    .message-time {
        max-width: 100%;
        width: 100%;
    }

    .floating-input {
        position: fixed;
        width: calc(100% - 24px);
        bottom: 12px;
    }
}

@media (max-width: 560px) {
    .header-chip span {
        display: none;
    }

    .welcome-title,
    .header-title {
        font-size: 20px;
    }

    .sidebar-header {
        padding-right: 10px;
    }

    .new-chat-btn {
        margin: 10px 12px;
    }
}
