: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-user-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    max-width: none;
}

.message-user-actions {
    display: flex;
    gap: 0.85rem;
    margin-top: 0.55rem;
    padding-right: 0.35rem;
    color: #6f665d;
}

.message-user-action {
    display: inline-flex;
    width: 1.65rem;
    height: 1.65rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.45rem;
    color: inherit;
    font-size: 0.95rem;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.message-user-action:hover,
.message-user-action:focus-visible {
    color: #0071e3;
    background: #eef6ff;
    outline: none;
}

.message-user-edit-box {
    width: min(100%, 64rem);
    min-width: min(36rem, 100%);
    border-radius: 1.2rem;
    background: #f4f4f5;
    padding: 0.9rem 0.9rem 0.7rem;
    color: #1d1d1f;
}

.message-user-edit-input {
    width: 100%;
    min-height: 5.5rem;
    resize: vertical;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1.55;
}

.message-user-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
    margin-top: 0.35rem;
}

.message-user-edit-cancel,
.message-user-edit-send {
    border-radius: 0.8rem;
    padding: 0.45rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.message-user-edit-cancel {
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4b5563;
}

.message-user-edit-send {
    background: #1d1d1f;
    color: #fff;
}

.chat-toast {
    position: fixed;
    z-index: 120;
    left: 50%;
    bottom: 2rem;
    max-width: min(90vw, 28rem);
    border: 1px solid transparent;
    border-radius: 9999px;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 0.5rem);
    transition: opacity 160ms ease, transform 160ms ease;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.chat-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.chat-toast-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
}

.chat-toast-error {
    border-color: #fecdd3;
    background: #fff1f2;
    color: #be123c;
}

.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 a {
    color: #4f67a1;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.message-assistant a:hover {
    color: #2f4d91;
}

.message-assistant a.assistant-external-link {
    display: inline-flex;
    align-items: baseline;
    gap: 0.18em;
    white-space: nowrap;
}

.message-assistant a.assistant-external-link::after {
    content: "↗";
    font-size: 0.92em;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.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: 52rem;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.94rem;
    line-height: 1.6;
}

.message-assistant th:first-child,
.message-assistant td:first-child {
    width: 14rem;
    min-width: 14rem;
    white-space: nowrap;
}

.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-composer {
    box-sizing: border-box;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

.chat-input-legal {
    max-width: 64rem;
    margin-right: auto;
    margin-left: auto;
    overflow-wrap: anywhere;
}

.chat-input-legal a {
    display: inline-flex;
    align-items: baseline;
    gap: 0.22rem;
    color: #4f6fae;
    font-weight: 600;
    text-decoration: none;
}

.chat-input-legal a:hover {
    color: #0071e3;
    text-decoration: underline;
    text-underline-offset: 0.16rem;
}

.chat-input-legal a i {
    font-size: 0.68rem;
}

/* Keep the two legal documents visually distinct and easy to select. */
.m-guide-legal-tabs {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.m-guide-legal-tab {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.5rem 0.1rem;
    border-bottom: 2px solid transparent;
    color: #2563eb;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.25rem;
    transition: color 150ms ease, border-color 150ms ease;
}

.m-guide-legal-tab:hover,
.m-guide-legal-tab.is-active {
    color: #1d4ed8;
    border-bottom-color: #2563eb;
}

.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;
}

.chat-guide-entry-row {
    display: flex;
    align-items: center;
    padding: 0 1.5rem 0.45rem;
}

.message-assistant-actions { display:flex; align-items:center; gap:.25rem; margin-top:1rem; padding-top:.65rem; border-top:1px solid #eef0f3; }
.message-assistant-action { display:inline-flex; align-items:center; justify-content:center; width:2rem; height:2rem; border-radius:.65rem; color:#86868b; transition:background 150ms ease,color 150ms ease; }
.message-assistant-action:hover, .message-assistant-action.is-active { background:#f0f6ff; color:#0071e3; }

.my-space-tab { border-bottom: 2px solid transparent; color: #86868b; transition: color 150ms ease, border-color 150ms ease; }
.my-space-tab:hover, .my-space-tab.is-active { border-color: #0071e3; color: #0071e3; }
.my-space-tab:focus { outline: none; }
.my-space-tab:focus-visible { outline: 2px solid rgba(0, 113, 227, 0.35); outline-offset: 3px; border-radius: 4px; }

.chat-guide-entry {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.25rem;
    padding: 0.42rem 0.8rem;
    border: 1px solid #e4e4e9;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: #424245;
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 150ms ease;
}

.chat-guide-entry:hover,
.chat-guide-entry.is-open {
    border-color: rgba(0, 113, 227, 0.2);
    background: rgba(0, 113, 227, 0.07);
    color: #0071e3;
}

.chat-guide-entry i {
    font-size: 0.85rem;
}

.material-guide-panel {
    position: absolute;
    z-index: 48;
    right: 0;
    bottom: calc(100% + 0.75rem);
    left: 0;
    width: min(100%, 860px);
    max-height: min(72vh, 680px);
    overflow: auto;
    border: 1px solid #d2d2d7;
    border-radius: 1.75rem;
    background: rgba(245, 245, 247, 0.98);
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(20px);
}

.material-guide-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.35rem 1.5rem 1.1rem;
    border-bottom: 1px solid #e3e3e8;
    background: rgba(255, 255, 255, 0.94);
}

.material-guide-title {
    color: #111827;
    font-size: 1.2rem;
    font-weight: 750;
    line-height: 1.4;
}

.material-guide-description {
    margin-top: 0.25rem;
    color: #86868b;
    font-size: 0.84rem;
    line-height: 1.5;
}

.material-guide-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    border-radius: 999px;
    color: #86868b;
    transition: background 150ms ease, color 150ms ease;
}

.material-guide-close:hover {
    background: #f2f2f7;
    color: #1d1d1f;
}

.material-guide-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 1rem 1.5rem 1.2rem;
}

.material-guide-field {
    min-width: 0;
    padding: 1rem;
    border: 1px solid #e1e1e6;
    border-radius: 1.15rem;
    background: #ffffff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.035);
}

.material-guide-field.is-wide {
    grid-column: 1 / -1;
}

.material-guide-field-label {
    margin-bottom: 0.65rem;
    color: #1d1d1f;
    font-size: 0.9rem;
    font-weight: 700;
}

.material-guide-optional {
    margin-left: 0.35rem;
    color: #9a9aa1;
    font-size: 0.75rem;
    font-weight: 500;
}

.material-guide-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.material-guide-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.15rem;
    padding: 0.4rem 0.78rem;
    border: 1px solid #d2d2d7;
    border-radius: 999px;
    background: #fdfdfe;
    color: #424245;
    font-size: 0.84rem;
    line-height: 1.2;
    transition: all 140ms ease;
}

.material-guide-chip:hover {
    border-color: rgba(0, 113, 227, 0.42);
    color: #0071e3;
}

.material-guide-chip.is-selected {
    border-color: #0071e3;
    background: #0071e3;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.18);
}

.material-guide-text-input {
    width: 100%;
    margin-top: 0.8rem;
    padding: 0.72rem 0.8rem;
    border: 1px solid #d2d2d7;
    border-radius: 0.85rem;
    background: #f5f5f7;
    color: #1d1d1f;
    font-size: 0.86rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.material-guide-text-input:focus {
    border-color: rgba(0, 113, 227, 0.65);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.material-guide-empty-options {
    color: #9a9aa1;
    font-size: 0.8rem;
}

.material-guide-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: 0.95rem 1.5rem 1.2rem;
    border-top: 1px solid #e3e3e8;
    background: rgba(255, 255, 255, 0.94);
}

.material-guide-cancel,
.material-guide-apply {
    min-height: 2.45rem;
    padding: 0.55rem 1rem;
    border-radius: 0.8rem;
    font-size: 0.88rem;
    font-weight: 700;
    transition: all 150ms ease;
}

.material-guide-cancel {
    border: 1px solid #d9dce2;
    background: #ffffff;
    color: #515154;
}

.material-guide-cancel:hover {
    background: #f5f5f7;
}

.material-guide-apply {
    border: 1px solid #0071e3;
    background: #0071e3;
    color: #ffffff;
    box-shadow: 0 5px 14px rgba(0, 113, 227, 0.18);
}

.material-guide-apply:hover {
    background: #0077ed;
}

@media (max-width: 1024px) {
    .material-guide-panel {
        position: fixed;
        top: 50%;
        right: auto;
        bottom: auto;
        left: 50%;
        width: min(760px, calc(100vw - 2rem));
        max-height: calc(100vh - 2rem);
        transform: translate(-50%, -50%);
    }
}

@media (max-width: 760px) {
    .material-guide-panel {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
        border-radius: 1.2rem;
    }

    .material-guide-fields {
        grid-template-columns: 1fr;
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .material-guide-field.is-wide {
        grid-column: auto;
    }

    .material-guide-header,
    .material-guide-footer {
        padding-right: 1rem;
        padding-left: 1rem;
    }
}

#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;
}

/* The prebuilt Tailwind bundle does not include arbitrary top-[Npx] classes.
   Keep the media thumbnail position in ordinary CSS so it can be adjusted
   reliably and is not lost at runtime. */
#materialCardMediaThumbs {
    top: 110px !important;
}

.material-card-action-grid {
    /* Legacy responsive references: repeat(3) and repeat(2) remain valid
       layout targets for narrow cards while the default uses four actions. */
    /* grid-template-columns: repeat(3, minmax(0, 1fr)); legacy reference */
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (max-width: 640px) {
    .material-card-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.material-card-action-grid.two-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.material-card-action-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 3rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    background: #f1f5f9;
    color: #334155;
    padding: 0;
    font-size: 1.15rem;
    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-action-button:hover:not(:disabled) {
    border-color: #94a3b8;
    background: #e2e8f0;
}

.material-card-action-button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

.material-card-action-button::after {
    position: absolute;
    z-index: 10;
    left: 50%;
    bottom: calc(100% + 0.55rem);
    max-width: 9rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.45rem;
    background: #1e293b;
    color: #fff;
    content: attr(data-tooltip);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 0.2rem);
    transition: opacity 120ms ease, transform 120ms ease;
    white-space: nowrap;
}

.material-card-action-button:hover::after,
.material-card-action-button:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

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

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

.favorite-card-heart {
    position: absolute;
    z-index: 2;
    top: 0.75rem;
    right: 0.75rem;
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 9999px;
    background: rgba(255,255,255,0.92);
    color: #334155;
    box-shadow: 0 4px 14px rgba(15,23,42,0.12);
    transition: background-color 150ms ease, transform 150ms ease;
}

.favorite-card-heart:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.favorite-card-heart::after {
    position: absolute;
    right: 0;
    top: calc(100% + 0.45rem);
    z-index: 10;
    padding: 0.3rem 0.5rem;
    border-radius: 0.4rem;
    background: #1e293b;
    color: #fff;
    content: attr(data-tooltip);
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

.favorite-card-heart:hover::after,
.favorite-card-heart:focus-visible::after {
    opacity: 1;
}

.my-space-card-action {
    display: inline-flex;
    min-width: 0;
    min-height: 2.5rem;
    align-items: center;
    justify-content: center;
    border: 1px solid #dbe3ef;
    border-radius: 0.75rem;
    padding: 0.5rem 0.4rem;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.my-space-card-action:hover:not(:disabled) {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.my-space-card-action-primary {
    border-color: #dbe3ef;
    background: #fff;
    color: #334155 !important;
}

#materialCardFavoriteButton,
#materialCardFavoriteButton i,
#materialCardFavoriteButton.is-favorite,
#materialCardFavoriteButton.is-favorite i {
    color: #334155 !important;
}

.my-space-card-action-disabled {
    cursor: not-allowed;
    color: #94a3b8;
    background: #f8fafc;
}

#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-nav-group { border-radius: 1rem; }

.admin-nav-group-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid transparent;
    border-radius: 1rem;
    padding: 0.75rem 0.9rem;
    color: #d7e3f5;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    list-style: none;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.admin-nav-group-summary::-webkit-details-marker { display: none; }

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

.admin-nav-group-summary.active { border-color: rgba(147, 197, 253, 0.22); }

.admin-nav-group-chevron {
    font-size: 0.7rem;
    transition: transform 160ms ease;
}

.admin-nav-group[open] .admin-nav-group-chevron { transform: rotate(180deg); }

.admin-nav-submenu {
    margin: 0.3rem 0 0.45rem 1rem;
    padding-left: 0.65rem;
    border-left: 1px solid rgba(191, 219, 254, 0.22);
}

.admin-nav-sub-link {
    border-radius: 0.8rem;
    padding-top: 0.62rem;
    padding-bottom: 0.62rem;
    font-size: 0.88rem;
}

.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;
}

/* Compact multilingual glossary layout. Explicit CSS avoids relying on
   generated arbitrary Tailwind grid classes in the admin page. */
.terminology-table {
    display: grid;
    grid-template-columns: minmax(140px, 1.1fr) minmax(170px, 1.2fr) repeat(4, minmax(140px, 1fr)) minmax(110px, .75fr) 132px;
    gap: 1rem;
    align-items: center;
}

.terminology-form-table {
    display: block;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
}

.terminology-form-header,
.terminology-form-inputs {
    display: grid;
    grid-template-columns: minmax(140px, 1.1fr) minmax(170px, 1.2fr) repeat(4, minmax(140px, 1fr)) minmax(110px, .75fr) 132px;
    gap: 1rem;
    align-items: center;
    min-width: 1180px;
    padding: .8rem 1rem;
}

.terminology-form-header {
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    font-size: .75rem;
    font-weight: 700;
}

.terminology-form-inputs { padding-top: 1rem; padding-bottom: 1rem; }
.terminology-form-inputs > div { min-width: 0; }
.terminology-form-inputs .admin-input { min-height: 2.8rem; }
.terminology-form-actions { display: flex; align-items: center; gap: .4rem; }

.terminology-form-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-bottom: 1px solid #e2e8f0;
}

.terminology-form-cell {
    min-width: 0;
    padding: .8rem 1rem 1rem;
    border-right: 1px solid #e2e8f0;
}

.terminology-form-cell:last-child { border-right: 0; }
.terminology-form-cell label {
    display: block;
    margin-bottom: .45rem;
    color: #475569;
    font-size: .82rem;
    font-weight: 600;
}
.terminology-form-cell .admin-input { min-height: 2.8rem; }
.terminology-form-row-category { grid-template-columns: 1fr; }
.terminology-form-row-category .terminology-form-cell { border-right: 0; }
.terminology-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    padding: .8rem 1rem;
}

@media (max-width: 1200px) {
    .terminology-table { min-width: 1180px; }
}
@media (max-width: 700px) {
    .terminology-table { min-width: 1180px; }
    .terminology-form-header,
    .terminology-form-inputs { min-width: 1180px; }
}

.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%);
}
