:root {
    --panel: #ffffff;
    --panel-soft: #f5f5f7;
    --panel-border: #d2d2d7;
    --surface: #f2f2f2;
    --sidebar: #fafafa;
    --sidebar-soft: #ffffff;
    --accent: #0071e3;
    --accent-strong: #0077ed;
    --text: #1d1d1f;
    --muted: #86868b;
}

* {
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

html, body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: #ffffff;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.5); border-radius: 999px; }

.intent-tab {
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    font-weight: 600;
}

.intent-tab:hover { border-color: rgba(34, 211, 238, 0.5); color: #67e8f9; }
.intent-tab.active { background: rgba(34, 211, 238, 0.18); border-color: rgba(34, 211, 238, 0.6); color: #67e8f9; }

.conversation-item {
    width: 100%;
    border-radius: 1rem;
    padding: 1rem 1.05rem;
    background: transparent;
    border: 1px solid transparent;
    text-align: left;
    box-shadow: none;
}

.conversation-item:hover {
    background: #f2f2f2;
    border-color: transparent;
    box-shadow: none;
}

.conversation-item.active {
    border-color: rgba(0, 113, 227, 0.28);
    background: #e1f0ff;
    box-shadow: none;
}

.conversation-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    border-radius: 0.9rem;
    padding: 0.75rem 0.85rem;
    font-size: 0.92rem;
    color: #1d1d1f;
    text-align: left;
    white-space: nowrap;
}

.conversation-menu-item:hover {
    background: #f5f9ff;
}

.chat-side-module {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-radius: 1rem;
    padding: 1rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    text-align: left;
    position: relative;
}

.chat-side-module.compact {
    gap: 1rem;
    padding: 0.95rem 1.1rem;
}

.chat-side-module:hover {
    background: #f2f2f2;
    border-color: transparent;
    box-shadow: none;
}

.chat-side-module.active {
    background: #e1f0ff;
    color: #0071e3;
}

.chat-side-module.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65rem;
    bottom: 0.65rem;
    width: 4px;
    border-radius: 0 999px 999px 0;
    background: #0071e3;
}

.chat-side-module-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 0;
    background: transparent;
    color: #86868b;
    flex: none;
    opacity: 0.7;
    font-size: 1.22rem;
}

.chat-side-module-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.chat-side-module-title {
    font-size: 20px;
    font-weight: 500;
    color: #1d1d1f;
}

.chat-side-module-desc {
    font-size: 0.78rem;
    line-height: 1.45;
    color: #64748b;
}

.chat-side-module.compact .chat-side-module-text {
    gap: 0;
}

.chat-side-module.compact .chat-side-module-title {
    font-size: 20px;
}

.chat-side-module.active .chat-side-module-title,
.chat-side-module.active .chat-side-module-icon {
    color: #0071e3;
    opacity: 1;
}

.chat-sidebar-brand-title {
    font-size: 38px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: #1d1d1f;
}

.conversation-item .truncate {
    font-size: 17px;
}

.conversation-item .text-\[11px\] {
    font-size: 14px !important;
}

.chat-language-panel {
    border-radius: 0;
    border: 0;
    background: transparent;
    padding: 0;
    min-width: 9rem;
    box-shadow: none;
}

.chat-language-label {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #9a9aa0;
}

.chat-language-select-wrap {
    position: relative;
    margin-top: 0;
}

.chat-language-select {
    width: 100%;
    appearance: none;
    border: 1px solid #d2d2d7;
    background: #ffffff;
    border-radius: 0.95rem;
    padding: 0.8rem 2.6rem 0.8rem 1rem;
    font-size: 1.12rem;
    font-weight: 600;
    color: #6f6f75;
    outline: none;
}

.chat-language-select:focus {
    border-color: rgba(0, 113, 227, 0.55);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.08);
}

.chat-language-icon {
    position: absolute;
    right: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.72rem;
    color: #86868b;
    pointer-events: none;
}

.chat-chip {
    border-radius: 999px;
    border: 1px solid transparent;
    background: #f2f2f2;
    color: #8a8a90;
    padding: 1rem 2rem;
    font-size: 1.45rem;
    font-weight: 600;
}

.chat-chip:hover {
    border-color: rgba(0, 113, 227, 0.35);
    color: #0071e3;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.06);
}

#chatWelcomeState.hidden,
#chatThread.hidden {
    display: none !important;
}

.message-user {
    max-width: min(36rem, 100%);
    border-radius: 1.2rem 1.2rem 0.35rem 1.2rem;
    background: linear-gradient(135deg, #0071e3 0%, #0077ed 100%);
    color: #ffffff;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    box-shadow: 0 14px 30px rgba(0, 113, 227, 0.18);
    margin-left: auto;
    margin-right: 0;
}

.message-assistant {
    width: 100%;
    max-width: none;
    border-radius: 0;
    background: transparent;
    border: 0;
    color: var(--text);
    padding: 0.35rem 0;
    box-shadow: none;
    margin-left: 0;
    margin-right: auto;
    font-size: 1rem;
    line-height: 1.8;
}

#chatThread .assistant-response-content {
    width: 100% !important;
    max-width: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.message-assistant strong { color: #0f172a; }

.message-assistant p {
    margin: 0 0 1rem;
}

.message-assistant p:last-child {
    margin-bottom: 0;
}

.message-assistant .assistant-section-title {
    margin-top: 1.5rem;
    margin-bottom: 0.55rem;
    font-size: 1.05rem;
    line-height: 1.55;
}

.message-assistant .assistant-section-title:first-child {
    margin-top: 0;
}

.message-assistant ol,
.message-assistant ul {
    padding-left: 1.45rem;
    margin: 0.35rem 0 1rem;
}

.message-assistant ul { list-style: disc; }
.message-assistant ol { list-style: decimal; }

.message-assistant li {
    margin: 0.35rem 0;
    padding-left: 0.15rem;
}

.message-assistant .assistant-table-wrap {
    width: 100%;
    margin: 0.7rem 0 1.2rem;
    overflow-x: auto;
}

.message-assistant table {
    width: 100%;
    min-width: 38rem;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.94rem;
    line-height: 1.6;
}

.message-assistant th,
.message-assistant td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.message-assistant th {
    color: #0f172a;
    font-weight: 700;
    background: #f8fafc;
}

.message-assistant .assistant-code-block {
    width: 100%;
    margin: 0.7rem 0 1.2rem;
    overflow-x: auto;
    border-radius: 0.75rem;
    background: #0f172a;
    padding: 1rem 1.1rem;
    color: #e2e8f0;
    font: 0.9rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre;
}

.message-assistant button[data-material-card],
.message-assistant button[data-material-group-toggle] {
    margin: 0 0.2rem;
    vertical-align: baseline;
    width: max-content;
    max-width: none;
    white-space: nowrap;
}

.message-assistant [data-material-group-menu] {
    width: max-content;
    max-width: none;
}

.typing-indicator {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.1rem 0.25rem;
}

.typing-indicator span {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: #0071e3;
    animation: typing 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

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

.chat-input {
    min-height: 3.5rem;
    max-height: 8rem;
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

.chat-input:focus,
.chat-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

#conversationManageBtn {
    display: none !important;
}

.chat-new-button {
    background: #0071e3;
    color: #ffffff;
    border: 1px solid transparent;
    box-shadow: 0 8px 18px rgba(0, 113, 227, 0.12);
}

.chat-new-button:hover {
    background: #0077ed;
}

/* 只修复高度和位置，不碰宽度，防止冲突 */
.chat-input-shell {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    margin-top: 0 !important;
}

.chat-input-shell .chat-input {
    min-height: 2rem !important;
}

.chat-plus-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #d2d2d7;
    background: #ffffff;
    color: #86868b;
    font-size: 0.95rem;
    transition: all 150ms ease;
    flex-shrink: 0;
}

.chat-input-shell .chat-input {
    min-height: 3rem;
}

.chat-input-shell #sendBtn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.chat-plus-button:hover,
.chat-plus-button.is-open {
    border-color: rgba(0, 113, 227, 0.35);
    color: #0071e3;
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.08);
}

.chat-tool-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.85rem);
    min-width: 13.5rem;
    padding: 0.45rem;
    border-radius: 1rem;
    border: 1px solid #e8e8ed;
    background: #ffffff;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    z-index: 30;
}

.chat-tool-menu-item {
    display: inline-flex;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
    border-radius: 0.8rem;
    border: 1px solid transparent;
    background: #ffffff;
    color: #1d1d1f;
    padding: 0.72rem 0.85rem;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    transition: all 150ms ease;
}

.chat-tool-menu-item:hover {
    background: #f5f9ff;
    border-color: rgba(0, 113, 227, 0.18);
    color: #0071e3;
}

.chat-tool-menu-item i {
    width: 1rem;
    text-align: center;
    color: #86868b;
}

.chat-tool-menu-item:hover i {
    color: #0071e3;
}

#materialCardModal img,
#materialCardModal video {
    box-shadow: 0 18px 44px rgba(148, 163, 184, 0.16);
}

#materialCardHeaderContent {
    min-width: 0;
    padding-right: 0;
}

#materialCardHeaderContent.has-media {
    /* 96px thumbnail + enough breathing room before the title reaches it. */
    padding-right: 9.75rem;
}

.material-card-favorite-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    background: #f1f5f9;
    color: #334155;
    padding: 0 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: none;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.material-card-favorite-button:hover {
    border-color: #94a3b8;
    background: #e2e8f0;
}

.material-card-favorite-button.is-favorite {
    border-color: #94a3b8;
    background: #e2e8f0;
    color: #334155;
    box-shadow: none;
}

.material-card-favorite-button.is-favorite:hover {
    border-color: #64748b;
    background: #cbd5e1;
}

#materialCardTitle {
    max-width: 100%;
    font-size: 2.5rem;
    line-height: 1.02;
    overflow-wrap: anywhere;
    word-break: normal;
}

@media (max-width: 520px) {
    #materialCardHeaderContent.has-media {
        padding-right: 9.75rem;
    }

    #materialCardTitle {
        font-size: 1.875rem;
        line-height: 1.06;
    }
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 1rem;
    padding: 0.75rem 0.9rem;
    color: #d7e3f5;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.admin-nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.admin-nav-link.active {
    color: #ffffff;
    border-color: rgba(147, 197, 253, 0.45);
    background: rgba(37, 99, 235, 0.22);
}

.admin-input,
.admin-textarea {
    width: 100%;
    border-radius: 1rem;
    border: 1px solid var(--panel-border);
    background: #ffffff;
    color: var(--text);
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
}

.admin-input::placeholder,
.admin-textarea::placeholder {
    color: #94a3b8;
}

.admin-input:focus,
.admin-textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.admin-textarea {
    resize: vertical;
    min-height: 7rem;
}

.admin-primary-btn,
.admin-secondary-btn,
.rule-tab {
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.admin-primary-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
}

.admin-primary-btn:hover {
    transform: translateY(-1px);
}

.admin-secondary-btn {
    border: 1px solid var(--panel-border);
    background: #ffffff;
    color: var(--text);
}

.admin-secondary-btn:hover {
    border-color: rgba(37, 99, 235, 0.35);
    color: var(--accent-strong);
}

.rule-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.85);
    color: var(--muted);
}

.rule-tab.active {
    border-color: rgba(37, 99, 235, 0.45);
    background: #eef4ff;
    color: var(--accent-strong);
}

.rule-version-card {
    border-radius: 1rem;
    border: 1px solid #d9e4f2;
    background: #ffffff;
    padding: 1rem;
}

.rule-version-card.active {
    border-color: #7dd3fc;
    background: linear-gradient(180deg, #f4fbff 0%, #ecf7ff 100%);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
}

.rule-version-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}

.rule-version-badge {
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    padding: 0.25rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.rule-version-desc {
    margin-top: 0.55rem;
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.55;
}

.rule-version-date {
    margin-top: 0.45rem;
    font-size: 0.76rem;
    color: #64748b;
}

.admin-danger-btn {
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(248, 113, 113, 0.28);
    background: #fff1f2;
    color: #be123c;
}

.admin-danger-btn:hover {
    border-color: rgba(244, 63, 94, 0.4);
    background: #ffe4e6;
}

.sub-rule-card {
    border-radius: 1.5rem;
    border: 1px solid #d9e4f2;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 1.2rem 1.25rem;
    box-shadow: 0 16px 42px rgba(148, 163, 184, 0.08);
}

.sub-rule-card.expanded {
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 18px 46px rgba(37, 99, 235, 0.10);
}

.sub-rule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sub-rule-drag-handle {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.85rem;
    border: 1px solid #d9e4f2;
    background: #eef4ff;
    color: #2563eb;
    flex: none;
}

.sub-rule-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}

.sub-rule-meta {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.72rem;
    font-weight: 600;
}

.rule-history-item {
    border-radius: 1rem;
    border: 1px solid #d9e4f2;
    background: #ffffff;
    padding: 0.95rem 1rem;
}

.rule-history-item.active {
    border-color: #93c5fd;
    background: linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%);
}
