/* ==========================================
   STYLES.CSS — Bản đồ Công an số (Soft UI)
   Token-driven: mọi màu/chữ/shadow/bo góc lấy từ tokens.733aa412b8.css.
   Không hardcode hex/px khi đã có token tương ứng.
   ========================================== */

/* sr-only fallback (chưa có trong output.d561a71cdb.css) */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.1);
    border-radius: var(--radius-pill);
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(15, 23, 42, 0.2);
}

.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

:root {
    --sheet-height: 85vh;
    --sheet-translate: 100%;
}

@media (max-width: 767px) {
    #detail-panel {
        height: var(--sheet-height) !important;
        transform: translate3d(0, var(--sheet-translate), 0) !important;
        -webkit-transform: translate3d(0, var(--sheet-translate), 0) !important;
        border-top-left-radius: var(--radius-2xl) !important;
        border-top-right-radius: var(--radius-2xl) !important;
        box-shadow: var(--shadow-sheet);
        background-color: var(--glass-fill-strong) !important;
        backdrop-filter: var(--blur-md) !important;
        -webkit-backdrop-filter: var(--blur-md) !important;
        transition: transform var(--dur-slow) var(--ease-sheet), visibility 0s linear;
    }
    #detail-panel[data-sheet-state="hidden"] {
        pointer-events: none;
        visibility: hidden;
    }
    #detail-panel[data-sheet-state="collapsed"],
    #detail-panel[data-sheet-state="expanded"] {
        pointer-events: auto;
        visibility: visible;
    }
    #detail-panel[data-dragging="true"],
    #detail-panel[data-animate="false"] {
        transition: none !important;
        will-change: transform;
    }
    #search-panel {
        transition: transform 0.3s var(--ease-smooth);
    }
    #drag-handle {
        touch-action: none;
        user-select: none;
    }
}

@media (min-width: 768px) {
    #detail-panel {
        transition: transform var(--dur-slow) var(--ease-sheet), visibility 0s linear;
    }
    #detail-panel[data-sheet-state="hidden"] {
        transform: translate3d(-100%, 0, 0) !important;
        visibility: hidden;
        pointer-events: none;
    }
    #detail-panel[data-sheet-state="collapsed"],
    #detail-panel[data-sheet-state="expanded"] {
        transform: translate3d(0, 0, 0) !important;
        visibility: visible;
        pointer-events: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    #detail-panel,
    #search-panel {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

.transparent-leaflet-icon {
    background: transparent !important;
    border: none !important;
}

.leaflet-control-zoom { display: none !important; }

/* --- Map Marker (teardrop pin) --- */
.marker-container { position: relative; width: var(--hit-min); height: var(--hit-min); display: flex; justify-content: center; align-items: center; }
.marker-icon {
    width: 38px; height: 38px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg) translateZ(0); display: flex; justify-content: center; align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); border: 2px solid var(--white); transition: all 0.3s var(--ease-spring); z-index: 10;
}
.marker-container:hover .marker-icon { transform: rotate(-45deg) scale(1.1) translateZ(0); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); }
.marker-inner { transform: rotate(45deg); color: var(--white); display: flex; justify-content: center; align-items: center; }

/* Color: Police = primary blue, ID = amber */
.marker-police .marker-icon { background: var(--color-primary); }
.marker-id .marker-icon { background: var(--color-cccd); }

@keyframes pulse-ring-green { 0% { transform: scale(0.8) translateZ(0); opacity: 0.8; } 100% { transform: scale(3.5) translateZ(0); opacity: 0; } }
@keyframes pulse-ring-amber { 0% { transform: scale(0.8) translateZ(0); opacity: 0.8; } 100% { transform: scale(3.5) translateZ(0); opacity: 0; } }
@keyframes pulse-ring-blue { 0% { transform: scale(0.8); opacity: 0.6; } 100% { transform: scale(2.6); opacity: 0; } }

.marker-selected .marker-icon {
    transform: rotate(-45deg) scale(1.2) translateZ(0); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 8px 24px rgba(0, 0, 0, 0.25); z-index: 999 !important;
}
.marker-selected::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 50%; z-index: 1; }
.marker-selected.marker-police::before { background-color: rgba(29, 78, 216, 0.4); animation: pulse-ring-green 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite; }
.marker-selected.marker-id::before { background-color: rgba(217, 119, 6, 0.4); animation: pulse-ring-amber 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite; }

/* --- Label tên trên marker --- */
.marker-label {
    position: absolute; top: -36px; left: 50%; transform: translate3d(-50%, 0, 0); background: var(--white); color: var(--text-strong); padding: 6px 14px; border-radius: var(--radius-lg);
    font-size: var(--text-sm); font-weight: var(--weight-bold); white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 30; font-family: var(--font-body); border: 1px solid rgba(0, 0, 0, 0.05);
}
.marker-label::after {
    content: ''; position: absolute; bottom: -5px; left: 50%; margin-left: -5px; border-width: 5px 5px 0; border-style: solid; border-color: var(--white) transparent transparent transparent;
}
@media (hover: hover) { .marker-container:hover .marker-label { opacity: 1; transform: translate3d(-50%, -6px, 0); } }
.marker-selected .marker-label { opacity: 1; transform: translate3d(-50%, -10px, 0); }
/* Zoom đủ gần → hiện tên mọi trụ sở (toggle bằng JS theo mức zoom) */
.show-marker-labels .marker-label { opacity: 1; transform: translate3d(-50%, -6px, 0); }

/* Vị trí người dùng */
.user-marker { background: var(--color-accent); border: 3px solid var(--white); border-radius: 50%; box-shadow: 0 0 16px rgba(37, 99, 235, 0.5); position: relative; }
.user-marker::before { content: ''; position: absolute; top: -14px; left: -14px; right: -14px; bottom: -14px; border-radius: 50%; background-color: rgba(37, 99, 235, 0.2); animation: pulse-ring-blue 2s infinite; }

/* --- Kết quả tìm kiếm (Cards) --- */
.result-list { list-style: none; margin: 0; }
.result-list-item { margin: 0 0 var(--space-2); }
.result-item {
    width: 100%; padding: var(--space-4) 14px; border-radius: var(--radius-lg); background: var(--glass-fill-strong); backdrop-filter: var(--blur-sm); border: 1px solid var(--glass-stroke); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow-card); color: inherit; font: inherit; text-align: left;
    transform: translateZ(0);
}
.result-item:hover { background: var(--white); transform: translate3d(0, -2px, 0); box-shadow: var(--shadow-card-hover); border-color: var(--white); }
.result-item:active { transform: scale(0.98) translateZ(0); box-shadow: var(--shadow-sm); }
.result-item:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.result-icon-box {
    width: var(--hit-min); height: var(--hit-min); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--white);
    background-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.bg-police { background-color: var(--color-primary); }
/* Card Công an: logo trơn, không nền/đổ bóng */
.result-icon-box--plain { background-color: transparent; box-shadow: none; }
.bg-id { background-color: var(--color-cccd); }

.result-content { flex: 1; min-width: 0; padding-top: 2px; }
.result-title { font-family: var(--font-display); font-weight: var(--weight-bold); font-size: var(--text-md); color: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: var(--space-1); letter-spacing: var(--tracking-tight); }
.result-address { font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: var(--weight-medium); }

.result-dist { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--color-nearby); background: var(--emerald-100); padding: 4px 11px 4px 9px; border-radius: var(--radius-pill); margin-top: var(--space-2); display: inline-flex; align-items: center; gap: 4px; }
.result-dist .material-symbols-outlined { font-size: 14px; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty-state span { font-size: 64px; opacity: 0.2; margin-bottom: 20px; color: var(--slate-300); display: block; }
.empty-state p { font-weight: var(--weight-semibold); font-size: var(--text-md); font-family: var(--font-display); }
.loading-state, .error-state { padding: var(--space-8) var(--space-4); text-align: center; color: var(--slate-600); font-weight: var(--weight-semibold); }
.data-retry-btn { margin-top: 14px; padding: 9px 14px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm); background: var(--white); color: var(--blue-900); font-weight: var(--weight-bold); cursor: pointer; }
.data-retry-btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* ==========================================
   AI CHATBOT WIDGET
   ========================================== */

/* AI launcher — pill nổi bật (ChatLauncher), góc dưới-TRÁI */
#ai-chat-launcher {
    position: fixed;
    bottom: 22px;
    left: var(--space-4);
    z-index: 2000;
    display: inline-flex;
}

.ai-launcher-pulse {
    position: absolute;
    left: 4px;
    top: 50%;
    margin-top: -28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(29, 78, 216, 0.35);
    animation: ds-chat-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

.ai-launcher-pulse--delay {
    animation-delay: 1.2s;
    background: rgba(29, 78, 216, 0.30);
}

@keyframes ds-chat-pulse {
    0% { transform: scale(0.85); opacity: 0.55; }
    70% { transform: scale(1.55); opacity: 0; }
    100% { opacity: 0; }
}

#ai-chat-toggle-btn {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    height: 64px;
    padding: 0 22px 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--text-on-brand);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 14px 34px rgba(29, 78, 216, 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.25);
    transition: transform var(--dur-base) var(--ease-spring), box-shadow var(--dur-base);
}

#ai-chat-toggle-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 20px 44px rgba(29, 78, 216, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

#ai-chat-toggle-btn:active {
    transform: scale(0.98);
}

.ai-launcher-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}

.ai-launcher-avatar img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.ai-launcher-dot {
    position: absolute;
    right: 1px;
    bottom: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--emerald-500);
    border: 2.5px solid var(--white);
}

.ai-launcher-text {
    text-align: left;
    line-height: 1.2;
}

.ai-launcher-title {
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-extrabold);
}

.ai-launcher-sub {
    display: block;
    margin-top: 2px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    color: rgba(255, 255, 255, 0.82);
}

#ai-chat-window {
    position: fixed;
    bottom: 100px;
    left: var(--space-5);
    z-index: 2000;
    width: var(--panel-w);
    max-width: calc(100vw - 32px);
    height: min(680px, 72vh);
    min-height: 460px;
    border-radius: var(--radius-xl);
    background: var(--surface-card);
    backdrop-filter: var(--blur-lg);
    -webkit-backdrop-filter: var(--blur-lg);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--shadow-pop);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
}

.ai-chat-window--hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s var(--ease-spring);
}

.ai-chat-window--visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
    transition: opacity 0.22s ease, transform 0.28s var(--ease-spring);
}

#ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 72px;
    padding: 14px var(--space-4);
    background: var(--surface-card);
    color: var(--text-on-brand);
    border-bottom: 1px solid var(--slate-100);
    flex-shrink: 0;
}

.ai-chat-header-main {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.ai-chat-header-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat-header-avatar img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.16));
}

.ai-chat-header-avatar span {
    position: absolute;
    right: 3px;
    bottom: 5px;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-pill);
    background: var(--emerald-500);
    border: 2px solid var(--white);
}

.ai-chat-title {
    font-family: var(--font-display);
    font-weight: var(--weight-extrabold);
    font-size: var(--text-base);
    line-height: var(--leading-tight);
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chat-subtitle {
    margin-top: 3px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-extrabold);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
}

#ai-chat-close-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

#ai-chat-close-btn:hover {
    color: var(--slate-800);
    background: var(--slate-100);
}

#ai-chat-close-btn .material-symbols-outlined {
    font-size: 20px;
}

#chatHistory {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--surface-muted);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 23, 42, 0.16) transparent;
}

#chatHistory::-webkit-scrollbar {
    width: 5px;
}

#chatHistory::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.16);
    border-radius: var(--radius-pill);
}

.ai-chat-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    animation: ai-chat-msg-in 0.2s ease;
}

@keyframes ai-chat-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-chat-row--assistant {
    justify-content: flex-start;
}

.ai-chat-row--user {
    justify-content: flex-end;
}

.ai-chat-avatar {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-top: 7px;
    flex-shrink: 0;
    opacity: 0.9;
}

.ai-chat-bubble {
    max-width: min(86%, 330px);
    padding: 13px 15px;
    border-radius: 18px;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    word-break: break-word;
}

.ai-chat-bubble--assistant {
    background: var(--surface-card);
    color: var(--text-body);
    border: 1px solid var(--slate-100);
    border-top-left-radius: 5px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

.ai-chat-bubble--user {
    background: var(--color-primary);
    color: var(--text-on-brand);
    border-top-right-radius: 5px;
    box-shadow: 0 8px 26px rgba(29, 78, 216, 0.16);
}

.ai-chat-bubble--error {
    border-color: var(--danger-100);
}

.lazy-feature-error {
    position: fixed;
    inset-inline: var(--space-4);
    top: var(--space-4);
    z-index: var(--z-overlay);
    margin-inline: auto;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-md);
    background: var(--warn-bg);
    color: var(--warn-fg);
    box-shadow: var(--shadow-card);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}

.ai-chat-label {
    margin: 0 0 5px;
    font-size: var(--text-xs);
    font-weight: var(--weight-extrabold);
    color: var(--color-primary);
}

.ai-chat-content {
    color: inherit;
}

.ai-chat-content p {
    margin: 0;
}

.ai-chat-content p + p,
.ai-chat-content ul,
.ai-chat-content ol {
    margin-top: var(--space-2);
}

.ai-chat-content ul,
.ai-chat-content ol {
    padding-left: var(--space-5);
}

.ai-chat-content a {
    color: var(--color-primary);
    font-weight: var(--weight-bold);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ai-chat-content code {
    background: var(--slate-100);
    border-radius: 6px;
    padding: 1px 5px;
    font-size: 0.92em;
}

.ai-chat-disclaimer {
    margin-top: 9px !important;
    padding-top: 9px;
    border-top: 1px solid var(--slate-100);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-style: italic;
}

.ai-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.ai-chat-typing span:not(:last-child) {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: ai-chat-dot 1.2s ease-in-out infinite;
}

.ai-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ai-chat-dot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.35; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-chat-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 11px;
    padding-top: 9px;
    border-top: 1px solid var(--slate-100);
}

.ai-chat-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    padding: 4px var(--space-2);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    transition: color 0.15s, background 0.15s;
}

.ai-chat-action-btn:hover {
    color: var(--slate-800);
    background: var(--slate-100);
}

.ai-chat-action-btn .material-symbols-outlined {
    font-size: 15px;
}

.ai-chat-action-btn--icon {
    min-width: 28px;
    justify-content: center;
    font-size: var(--text-2xs);
}

.ai-chat-action-btn.is-selected {
    color: var(--color-primary);
    background: var(--emerald-50);
}

/* Form báo cáo câu trả lời (hiện khi bấm 👎) */
.ai-chat-feedback-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    background: var(--surface-muted);
}

.ai-chat-feedback-title {
    margin: 0;
    color: var(--slate-800);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
}

.ai-chat-feedback-select,
.ai-chat-feedback-textarea,
.ai-chat-feedback-contact {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    background: var(--surface, #fff);
    color: var(--slate-800);
    font-family: var(--font-body);
    font-size: var(--text-xs);
}

.ai-chat-feedback-textarea {
    resize: vertical;
    min-height: 44px;
}

.ai-chat-feedback-select:focus-visible,
.ai-chat-feedback-textarea:focus-visible,
.ai-chat-feedback-contact:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

.ai-chat-feedback-form-actions {
    display: flex;
    gap: 8px;
}

.ai-chat-feedback-submit {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: #fff;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    cursor: pointer;
}

.ai-chat-feedback-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.ai-chat-feedback-skip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    cursor: pointer;
}

.ai-chat-feedback-skip:hover {
    background: var(--slate-100);
}

.ai-chat-feedback-status {
    margin: 9px 0 0;
    color: var(--color-primary);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
}

.ai-chat-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.ai-chat-source-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 100%;
}

.ai-chat-source-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 5px 9px;
    border-radius: var(--radius-pill);
    background: var(--slate-100);
    color: var(--text-muted);
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.ai-chat-source-chip:hover,
.ai-chat-source-chip:focus-visible {
    color: var(--color-primary);
    background: var(--slate-200);
}

.ai-chat-source-meta {
    color: var(--text-muted);
    font-size: var(--text-2xs);
    line-height: 1.35;
}

/* Nút mở toàn văn thủ tục để đối sánh với câu trả lời AI */
.ai-chat-source-compare {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    align-self: flex-start;
    margin-top: 2px;
    padding: 8px 12px;
    border: 1px solid var(--blue-100);
    border-radius: var(--radius-pill);
    background: var(--blue-50);
    color: var(--blue-700);
    font-family: var(--font-body);
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ai-chat-source-compare:hover {
    background: var(--blue-100);
    border-color: var(--blue-600);
}

.ai-chat-source-compare:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.ai-chat-source-compare .material-symbols-outlined { font-size: 16px; }

.ai-chat-source-compare-state {
    color: var(--text-muted);
    font-size: var(--text-2xs);
}

.ai-chat-verified-locations {
    display: grid;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.ai-chat-location-link {
    min-height: var(--hit-min);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    color: var(--color-primary);
    text-decoration: none;
    transition: background var(--dur-fast) var(--ease-smooth), border-color var(--dur-fast) var(--ease-smooth);
}

.ai-chat-location-link:hover {
    background: var(--surface-sunken);
    border-color: var(--color-accent);
}

.ai-chat-location-link:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.ai-chat-location-link--unavailable {
    color: var(--text-muted);
}

.ai-chat-location-link--unavailable:hover {
    background: var(--surface-muted);
    border-color: var(--border-hairline);
}

.ai-chat-location-link > span:last-child {
    display: grid;
    gap: var(--space-1);
}

.ai-chat-location-link strong {
    color: var(--text-body);
    font-size: var(--text-sm);
}

.ai-chat-location-link > span:last-child > span {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

body.ai-chat-modal-open {
    overflow: hidden;
}

.ai-chat-notice {
    margin: 9px 0 0;
    padding: var(--space-2) 10px;
    border-radius: 10px;
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-fg);
    font-size: var(--text-xs);
}

/* Quick-reply chips — nút trả lời nhanh cho câu hỏi follow-up của bot */
.ai-chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 0 44px; /* thẳng hàng với bubble (avatar 36px + gap 8px) */
}

.ai-chat-quick-reply {
    display: inline-flex;
    align-items: center;
    min-height: 36px; /* vùng chạm ngón tay trên mobile */
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    border: 1px solid var(--blue-200);
    color: var(--color-primary);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.ai-chat-quick-reply:hover,
.ai-chat-quick-reply:focus-visible {
    background: var(--blue-50);
    border-color: var(--color-primary);
}

/* Accordion chi tiết hồ sơ/trình tự — đáp án chính luôn hiện, chi tiết bấm mở */
.ai-chat-details {
    margin: 8px 0;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    overflow: hidden;
}

.ai-chat-details > summary {
    padding: 9px 12px;
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--text-strong);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ai-chat-details > summary::-webkit-details-marker {
    display: none;
}

.ai-chat-details > summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.ai-chat-details[open] > summary::after {
    transform: rotate(-135deg);
}

.ai-chat-details-body {
    padding: 0 12px 10px;
}

#turnstileContainer {
    display: flex;
    justify-content: center;
    padding: 10px var(--space-3);
    background: var(--surface-muted);
    border-top: 1px solid var(--slate-100);
}

#ai-chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px calc(13px + env(safe-area-inset-bottom, 0px));
    background: var(--surface-card);
    border-top: 1px solid var(--slate-100);
    flex-shrink: 0;
}

#fakeChatInput {
    width: 100%;
    min-width: 0;
    height: var(--control-h);
    padding: 0 var(--space-4);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--text-strong);
    font-family: var(--font-body);
    font-size: var(--text-base);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#fakeChatInput:focus {
    background: var(--white);
    border-color: var(--color-primary);
    box-shadow: var(--ring-primary);
}

#fakeChatInput:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

#chatSendBtn {
    width: var(--control-h);
    height: var(--control-h);
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--text-on-brand);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(29, 78, 216, 0.22);
    transition: transform 0.15s, opacity 0.15s, background 0.15s;
}

#chatSendBtn:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

#chatSendBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

#chatSendBtn .material-symbols-outlined {
    font-size: 23px;
}

.ai-chat-send-spinner {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-top-color: var(--white);
    animation: ai-chat-spin 0.8s linear infinite;
}

@keyframes ai-chat-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 767px) {
    #ai-chat-window {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        transform-origin: center;
    }

    #chatHistory {
        padding-bottom: 18px;
    }
}

@media (max-width: 480px) {
    #ai-chat-window {
        right: var(--space-3);
        left: var(--space-3);
        width: auto;
        max-width: none;
        top: 0;
        bottom: 0;
        height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
    }

    #ai-chat-launcher {
        left: var(--space-3);
        bottom: 18px;
    }

    #ai-chat-toggle-btn {
        height: 58px;
        padding: 0 18px 0 7px;
    }

    .ai-launcher-avatar {
        width: 44px;
        height: 44px;
    }

    .ai-launcher-avatar img {
        width: 36px;
        height: 36px;
    }

    #chatHistory {
        padding: 13px;
    }

    .ai-chat-bubble {
        max-width: 88%;
        font-size: var(--text-sm);
    }
}

/* Desktop: sidebar rộng 400px (md) / 420px (lg) → đẩy launcher + chat window sang phải sidebar */
@media (min-width: 768px) {
    #ai-chat-launcher {
        left: calc(400px + 16px);
        bottom: 28px;
    }

    #ai-chat-window {
        left: calc(400px + 16px);
    }
}

@media (min-width: 1024px) {
    #ai-chat-launcher {
        left: calc(420px + 16px);
    }

    #ai-chat-window {
        left: calc(420px + 16px);
    }
}

/* ==========================================
   DANH MỤC THỦ TỤC HÀNH CHÍNH (TTHC CATALOG)
   ========================================== */

/* Launcher — pill glass phụ, xếp phía trên launcher chat (cùng cụm góc dưới-trái) */
#tthc-catalog-launcher {
    position: fixed;
    bottom: 96px;
    left: var(--space-4);
    z-index: 1999;
    display: inline-flex;
}

/* Ẩn khi cửa sổ chat hoặc catalog đang mở để không đè lên nhau */
body.ai-chat-open #tthc-catalog-launcher,
body.tthc-catalog-open #tthc-catalog-launcher {
    display: none;
}

body.tthc-catalog-open #ai-chat-launcher {
    display: none;
}

#tthc-catalog-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--hit-min);
    padding: 0 16px;
    border: 1px solid var(--glass-stroke);
    border-radius: var(--radius-pill);
    background: var(--glass-fill-strong);
    backdrop-filter: var(--blur-md);
    -webkit-backdrop-filter: var(--blur-md);
    color: var(--color-primary);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: transform var(--dur-base) var(--ease-spring), box-shadow var(--dur-base);
}

#tthc-catalog-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
    background: var(--white);
}

#tthc-catalog-toggle-btn:active { transform: scale(0.98); }
#tthc-catalog-toggle-btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
#tthc-catalog-toggle-btn .material-symbols-outlined { font-size: 20px; }

/* Cửa sổ danh mục — cùng vị trí neo với chat nhưng rộng hơn */
#tthc-catalog-window {
    position: fixed;
    bottom: 100px;
    left: var(--space-5);
    z-index: 2001;
    width: min(520px, calc(100vw - 32px));
    height: min(720px, 78vh);
    min-height: 440px;
    border-radius: var(--radius-xl);
    background: var(--surface-card);
    backdrop-filter: var(--blur-lg);
    -webkit-backdrop-filter: var(--blur-lg);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--shadow-pop);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
}

.tthc-catalog-window--hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s var(--ease-spring);
}

.tthc-catalog-window--visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
    transition: opacity 0.22s ease, transform 0.28s var(--ease-spring);
}

.tthc-catalog-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 72px;
    padding: 14px var(--space-4);
    border-bottom: 1px solid var(--slate-100);
    flex-shrink: 0;
}

.tthc-catalog-header-text { min-width: 0; flex: 1; }

.tthc-catalog-title {
    font-family: var(--font-display);
    font-weight: var(--weight-extrabold);
    font-size: var(--text-base);
    line-height: var(--leading-tight);
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tthc-catalog-subtitle {
    margin-top: 3px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    line-height: 1.35;
}

.tthc-catalog-back,
#tthc-catalog-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.tthc-catalog-back:hover,
#tthc-catalog-close-btn:hover {
    color: var(--slate-800);
    background: var(--slate-100);
}

.tthc-catalog-back:focus-visible,
#tthc-catalog-close-btn:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.tthc-catalog-back .material-symbols-outlined,
#tthc-catalog-close-btn .material-symbols-outlined { font-size: 20px; }

/* Guard: các phần tử dùng thuộc tính [hidden] để ẩn cần thắng display của id/class */
#tthc-catalog-home-view[hidden],
#tthc-catalog-list-view[hidden],
#tthc-catalog-detail-view[hidden],
#tthc-catalog-back-btn[hidden],
#tthc-catalog-status[hidden] {
    display: none;
}

/* 3 view (home / list / detail) là con của cột flex; chỉ 1 hiện tại một lúc, mỗi cái tự cuộn */
#tthc-catalog-home-view,
#tthc-catalog-list-view,
#tthc-catalog-detail-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    animation: tthc-view-in var(--dur-base) var(--ease-smooth);
}

@keyframes tthc-view-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    #tthc-catalog-home-view,
    #tthc-catalog-list-view,
    #tthc-catalog-detail-view {
        animation: none;
    }
}

#tthc-catalog-status { padding: var(--space-2) var(--space-4); }
.tthc-status-notice {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-fg);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}

/* ---- Tầng 1: home (search-first + lưới lĩnh vực) ---- */
.tthc-hero {
    padding: var(--space-6) var(--space-4) var(--space-4);
}

.tthc-hero-title {
    margin: 0 0 var(--space-1);
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-extrabold);
    letter-spacing: var(--tracking-tight);
    color: var(--text-strong);
    text-wrap: balance;
}

.tthc-hero-sub {
    margin: 0 0 var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: var(--leading-snug);
}

.tthc-search {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--control-h);
    padding: 0 var(--space-1) 0 var(--space-4);
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    border: 1px solid var(--slate-200);
    transition: border-color var(--dur-base) var(--ease-smooth), box-shadow var(--dur-base), background var(--dur-base);
}

.tthc-search:focus-within {
    background: var(--white);
    border-color: var(--color-primary);
    box-shadow: var(--ring-primary);
}

.tthc-search .material-symbols-outlined { color: var(--text-muted); font-size: 22px; flex-shrink: 0; }

.tthc-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    outline: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-body);
}

.tthc-search-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--hit-min);
    min-height: var(--hit-min);
    flex-shrink: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--text-on-brand);
    cursor: pointer;
    transition: background var(--dur-base) var(--ease-smooth), transform var(--dur-fast) var(--ease-smooth);
}

.tthc-search-submit:hover { background: var(--color-primary-hover); }
.tthc-search-submit:active { transform: scale(0.98); }
.tthc-search-submit:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.tthc-search-submit .material-symbols-outlined { color: inherit; font-size: 20px; }

.tthc-suggests {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.tthc-suggest {
    min-height: var(--hit-min);
    border: 1px solid var(--slate-200);
    background: var(--surface-card);
    color: var(--slate-700);
    border-radius: var(--radius-pill);
    padding: 0 var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: background var(--dur-base) var(--ease-smooth), border-color var(--dur-base) var(--ease-smooth), color var(--dur-base) var(--ease-smooth);
}

.tthc-suggest:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--blue-50); }
.tthc-suggest:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.tthc-cluster { padding: 0 var(--space-4); }

.tthc-cluster-h {
    font-size: var(--text-2xs);
    font-weight: var(--weight-extrabold);
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
    color: var(--text-muted);
    margin: var(--space-4) 0 var(--space-3);
}

.tthc-tile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.tthc-tile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-lg);
    background: var(--surface-card);
    cursor: pointer;
    text-align: left;
    transition: transform var(--dur-base) var(--ease-smooth), box-shadow var(--dur-base), border-color var(--dur-base);
}

.tthc-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); border-color: transparent; }
.tthc-tile:active { transform: scale(0.98); }
.tthc-tile:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.tthc-tile-ic {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-50);
    color: var(--color-primary);
}

.tthc-tile-ic .material-symbols-outlined { font-size: 24px; font-variation-settings: 'FILL' 1; }
.tthc-tile-body { min-width: 0; }

.tthc-tile-name {
    display: block;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
    color: var(--text-strong);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

.tthc-tile-count {
    display: block;
    margin-top: 3px;
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Chừa khoảng thở dưới lưới lĩnh vực */
#tthc-catalog-home-view { padding-bottom: var(--space-6); }

/* ---- Tầng 2: danh sách thủ tục (phẳng, chia dòng) ---- */
.tthc-list-head { padding: var(--space-4) var(--space-4) var(--space-2); }

.tthc-list-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-extrabold);
    letter-spacing: var(--tracking-tight);
    color: var(--text-strong);
    text-wrap: balance;
}

.tthc-list-head span { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }

#tthc-catalog-list-view .result-list { padding: var(--space-2) var(--space-4) var(--space-6); }
#tthc-catalog-list-view .result-list-item { margin: 0; }

.tthc-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: 14px var(--space-3);
    border: 0;
    background: transparent;
    border-bottom: 1px solid var(--slate-100);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    transition: background var(--dur-base) var(--ease-smooth);
}

.tthc-row:hover { background: var(--surface-muted); }
.tthc-row:active { background: var(--surface-sunken); }
.tthc-row:focus-visible { outline: 3px solid var(--color-accent); outline-offset: -2px; }

.tthc-row-body { flex: 1; min-width: 0; }

.tthc-row-title {
    display: block;
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    color: var(--text-body);
    line-height: var(--leading-snug);
}

.tthc-row-meta { margin-top: 6px; display: flex; }

.tthc-cap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    background: var(--slate-100);
    color: var(--slate-600);
}

.tthc-cap .material-symbols-outlined { font-size: 14px; }
.tthc-cap.is-xa { background: var(--emerald-50); color: var(--emerald-700); }

.tthc-row-arrow { color: var(--slate-300); font-size: 22px; flex-shrink: 0; }

.tthc-empty {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
    list-style: none;
}

.tthc-empty .material-symbols-outlined {
    font-size: 48px;
    opacity: 0.3;
    display: block;
    margin-bottom: var(--space-2);
}

.tthc-empty p { font-weight: var(--weight-semibold); font-size: var(--text-sm); }

/* ---- Tầng 3: chi tiết (tóm tắt + note phí + accordion) ---- */
#tthc-catalog-detail-view { padding: var(--space-4) var(--space-4) var(--space-6); }

.tthc-detail-title {
    font-family: var(--font-display);
    font-weight: var(--weight-extrabold);
    font-size: var(--text-lg);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--text-strong);
    margin: 0 0 var(--space-3);
    text-wrap: balance;
}

.tthc-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.tthc-sum {
    display: flex;
    gap: var(--space-3);
    padding: 12px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.tthc-sum .material-symbols-outlined { font-size: 20px; color: var(--color-primary); flex-shrink: 0; }

.tthc-sum-label {
    display: block;
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-eyebrow);
    color: var(--text-muted);
    margin-bottom: 2px;
}

.tthc-sum-value { display: block; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-body); line-height: var(--leading-snug); }

.tthc-fee-note {
    display: flex;
    gap: var(--space-2);
    align-items: flex-start;
    padding: 11px 12px;
    border-radius: var(--radius-md);
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-fg);
    font-size: var(--text-xs);
    line-height: var(--leading-snug);
    margin-bottom: var(--space-4);
}

.tthc-fee-note .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }
.tthc-fee-note.is-known { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-800); }

.tthc-acc {
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    overflow: hidden;
    background: var(--surface-card);
}

.tthc-acc > summary {
    list-style: none;
    cursor: pointer;
    padding: 13px 14px;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
    color: var(--text-strong);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.tthc-acc > summary::-webkit-details-marker { display: none; }
.tthc-acc > summary:focus-visible { outline: 3px solid var(--color-accent); outline-offset: -3px; }

.tthc-acc-title { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.tthc-acc-title .material-symbols-outlined { font-size: 19px; color: var(--color-primary); flex-shrink: 0; }

.tthc-acc > summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform var(--dur-fast) var(--ease-smooth);
    flex-shrink: 0;
}

.tthc-acc[open] > summary::after { transform: rotate(-135deg); }

.tthc-acc-body {
    padding: 0 14px 14px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: var(--text-sm);
    line-height: 1.6;
    color: var(--text-body);
}

.tthc-detail-label { font-weight: var(--weight-bold); color: var(--text-strong); }

.tthc-detail-source {
    margin: var(--space-3) 0 0;
    font-size: var(--text-2xs);
    color: var(--text-muted);
}

body.tthc-catalog-modal-open { overflow: hidden; }

/* Desktop: đẩy launcher + cửa sổ catalog sang phải sidebar (như chat) */
@media (min-width: 768px) {
    #tthc-catalog-launcher { left: calc(400px + 16px); bottom: 104px; }
    #tthc-catalog-window { left: calc(400px + 16px); }
}

@media (min-width: 1024px) {
    #tthc-catalog-launcher { left: calc(420px + 16px); }
    #tthc-catalog-window { left: calc(420px + 16px); }
}

/* Mobile: cửa sổ danh mục toàn màn hình */
@media (max-width: 767px) {
    .tthc-summary-grid {
        grid-template-columns: 1fr;
    }

    #tthc-catalog-window {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        transform-origin: center;
    }
}

@media (max-width: 480px) {
    #tthc-catalog-launcher { left: var(--space-3); bottom: 84px; }
    #tthc-catalog-toggle-btn { font-size: var(--text-xs); }
}

/* ==========================================
   CIVIC MODERN MOBILE NAVIGATION + MAP PREVIEW
   ========================================== */

#mobile-bottom-nav {
    display: none;
}

.marker-container {
    width: 48px;
    height: 48px;
}

.marker-icon {
    width: 38px;
    height: 38px;
    box-shadow: var(--shadow-marker);
    transition: transform var(--dur-base) var(--ease-smooth), box-shadow var(--dur-base) var(--ease-smooth);
}

.marker-container:hover .marker-icon {
    box-shadow: var(--shadow-marker-selected);
}

.marker-selected .marker-icon {
    width: 48px;
    height: 48px;
    transform: rotate(-45deg) translateZ(0);
    box-shadow: var(--shadow-marker-selected);
}

.marker-selected::before {
    display: none;
}

.marker-cluster-civic {
    background: transparent;
    border: 0;
}

.marker-cluster-civic > div {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--cluster-size);
    height: var(--cluster-size);
    margin: calc((44px - var(--cluster-size)) / 2);
    border: 3px solid var(--white);
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    box-shadow: var(--shadow-cluster);
    color: var(--text-on-brand);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-extrabold);
    font-variant-numeric: tabular-nums;
}

.marker-cluster-civic--small { --cluster-size: 36px; }
.marker-cluster-civic--medium { --cluster-size: 40px; }
.marker-cluster-civic--large { --cluster-size: 44px; }

@media (max-width: 767px) {
    body {
        --sheet-height: min(76dvh, calc(100dvh - var(--mobile-nav-total-height) - var(--space-4)));
    }

    #mobile-bottom-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: var(--z-navigation);
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        height: var(--mobile-nav-total-height);
        padding: 0 var(--space-2) env(safe-area-inset-bottom, 0px);
        border-top: 1px solid var(--border-hairline);
        background: var(--glass-fill-strong);
        box-shadow: var(--shadow-sheet);
        backdrop-filter: var(--blur-md);
        -webkit-backdrop-filter: var(--blur-md);
    }

    #mobile-bottom-nav button {
        position: relative;
        display: flex;
        min-width: 0;
        min-height: var(--hit-min);
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 2px;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        font-family: var(--font-body);
        font-size: var(--text-xs);
        font-weight: var(--weight-semibold);
        cursor: pointer;
        transition: color var(--dur-fast) var(--ease-smooth), transform var(--dur-fast) var(--ease-smooth);
    }

    #mobile-bottom-nav button::after {
        position: absolute;
        right: var(--space-5);
        bottom: 0;
        left: var(--space-5);
        height: 3px;
        border-radius: var(--radius-pill) var(--radius-pill) 0 0;
        background: transparent;
        content: '';
    }

    #mobile-bottom-nav button[aria-current="page"] {
        color: var(--color-primary);
        font-weight: var(--weight-bold);
    }

    #mobile-bottom-nav button[aria-current="page"]::after {
        background: var(--color-primary);
    }

    #mobile-bottom-nav button:active {
        transform: scale(0.98);
    }

    #mobile-bottom-nav button:focus-visible {
        outline: 3px solid var(--color-accent);
        outline-offset: -3px;
    }

    #mobile-bottom-nav .material-symbols-outlined,
    #mobile-bottom-nav .mobile-nav-custom-icon {
        font-size: 24px;
        width: 24px;
        height: 24px;
        object-fit: contain;
    }

    #mobile-bottom-nav .mobile-nav-chatbot-icon {
        width: 24px;
        height: 24px;
        object-fit: contain;
    }

    #mobile-bottom-nav .mobile-nav-custom-icon,
    #mobile-bottom-nav .mobile-nav-chatbot-icon {
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        transform: translateZ(0);
        will-change: transform;
    }

    #mobile-bottom-nav button[aria-current="page"] .mobile-nav-custom-icon,
    #mobile-bottom-nav button[aria-current="page"] .mobile-nav-chatbot-icon {
        transform: scale(1.25);
        animation: nav-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    }

    @keyframes nav-pop {
        0% { transform: scale(1) translateY(0); }
        50% { transform: scale(1.3) translateY(-5px); }
        100% { transform: scale(1.25) translateY(0); }
    }

    .mobile-nav-ai-icon {
        position: relative;
        display: inline-flex;
    }

    .mobile-nav-ai-dot {
        position: absolute;
        top: -2px;
        right: -5px;
        width: 8px;
        height: 8px;
        border: 2px solid var(--white);
        border-radius: var(--radius-pill);
        background: var(--emerald-500);
    }

    body:not(.ai-nav-seen) .mobile-nav-ai-dot::after {
        position: absolute;
        inset: -4px;
        border: 1px solid var(--emerald-500);
        border-radius: inherit;
        animation: mobile-ai-attention 1.8s var(--ease-smooth) infinite;
        content: '';
    }

    #ai-chat-launcher,
    #tthc-catalog-launcher {
        display: none !important;
    }

    #mobile-search-btn {
        top: calc(var(--space-4) + env(safe-area-inset-top, 0px));
        z-index: var(--z-map-control);
    }

    #map-actions {
        right: var(--space-4);
        bottom: calc(var(--mobile-nav-total-height) + var(--space-4));
        z-index: var(--z-map-control);
        visibility: visible;
        transition: bottom var(--dur-base) var(--ease-smooth), opacity var(--dur-fast) var(--ease-smooth);
    }

    body.location-preview-open #map-actions {
        bottom: calc(var(--mobile-nav-total-height) + var(--location-preview-height) + var(--space-3));
    }

    body.location-detail-expanded #map-actions,
    body:not([data-active-tab="map"]) #map-actions,
    body:not([data-active-tab="map"]) #mobile-search-btn {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
    }

    #mobile-overlay {
        bottom: var(--mobile-nav-total-height);
        z-index: var(--z-overlay);
    }

    #search-panel {
        max-height: calc(100dvh - var(--mobile-nav-total-height));
        z-index: var(--z-panel);
    }

    #detail-panel {
        position: fixed !important;
        right: 0;
        left: 0;
        bottom: var(--mobile-nav-total-height) !important;
        height: var(--sheet-height) !important;
        z-index: var(--z-panel);
    }

    #location-preview {
        position: relative;
        display: flex;
        min-height: var(--location-preview-height);
        flex: 0 0 var(--location-preview-height);
        flex-direction: column;
        justify-content: space-between;
        gap: var(--space-2);
        padding: 30px var(--space-4) var(--space-3);
        border-bottom: 1px solid var(--border-hairline);
        background: var(--glass-fill-strong);
    }

    #preview-close-btn {
        position: absolute;
        top: var(--space-2);
        right: var(--space-2);
        display: flex;
        width: var(--hit-min);
        height: var(--hit-min);
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: var(--radius-pill);
        background: transparent;
        color: var(--text-muted);
        cursor: pointer;
    }

    #preview-close-btn:focus-visible {
        outline: 3px solid var(--color-accent);
        outline-offset: -3px;
    }

    .location-preview-main {
        display: flex;
        min-width: 0;
        align-items: center;
        gap: var(--space-3);
    }

    .location-preview-icon {
        display: flex;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-md);
        background: var(--blue-50);
        color: var(--color-primary);
    }

    .location-preview-icon.is-cccd {
        background: var(--amber-50);
        color: var(--color-cccd);
    }

    .location-preview-icon .material-symbols-outlined {
        font-size: 24px;
        font-variation-settings: 'FILL' 1;
    }

    .location-preview-copy {
        min-width: 0;
        flex: 1;
    }

    .location-preview-heading {
        display: flex;
        min-width: 0;
        align-items: flex-start;
        justify-content: space-between;
        gap: var(--space-2);
        padding-right: var(--space-7);
    }

    #location-preview-title {
        display: -webkit-box;
        min-width: 0;
        overflow: hidden;
        color: var(--text-strong);
        font-family: var(--font-display);
        font-size: var(--text-base);
        font-weight: var(--weight-extrabold);
        line-height: var(--leading-snug);
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    #location-preview-distance {
        flex: 0 0 auto;
        padding: var(--space-1) var(--space-2);
        border-radius: var(--radius-pill);
        background: var(--blue-50);
        color: var(--color-primary);
        font-size: var(--text-2xs);
        font-weight: var(--weight-bold);
        font-variant-numeric: tabular-nums;
    }

    #location-preview-address {
        overflow: hidden;
        margin-top: var(--space-1);
        color: var(--text-muted);
        font-size: var(--text-xs);
        line-height: var(--leading-snug);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .location-preview-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-2);
    }

    .location-preview-actions a,
    .location-preview-actions button {
        display: inline-flex;
        min-height: var(--hit-min);
        align-items: center;
        justify-content: center;
        gap: var(--space-2);
        border: 1px solid var(--border-hairline);
        border-radius: var(--radius-md);
        background: var(--surface-card);
        color: var(--text-body);
        font-family: var(--font-body);
        font-size: var(--text-xs);
        font-weight: var(--weight-bold);
        text-decoration: none;
    }

    .location-preview-actions a {
        border-color: var(--color-primary);
        background: var(--color-primary);
        color: var(--text-on-brand);
    }

    .location-preview-actions .material-symbols-outlined {
        font-size: 20px;
    }

    #detail-hero {
        display: block;
    }

    #detail-hero[hidden],
    #detail-panel[data-sheet-state="collapsed"] #detail-hero {
        display: none;
    }

    #detail-panel.has-detail-image[data-sheet-state="expanded"] #location-preview {
        display: none;
    }

    #detail-content {
        padding-top: var(--space-4);
        padding-bottom: var(--space-6);
        background: var(--surface-card);
    }

    #detail-panel[data-sheet-state="collapsed"] #detail-content {
        visibility: hidden;
        pointer-events: none;
    }

    #ai-chat-window,
    #tthc-catalog-window {
        top: 0;
        right: 0;
        bottom: var(--mobile-nav-total-height);
        left: 0;
        z-index: var(--z-panel);
        width: auto;
        height: auto;
        min-height: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.35s ease;
        will-change: transform, opacity;
    }

    .ai-chat-window--hidden,
    .tthc-catalog-window--hidden {
        opacity: 0;
        pointer-events: none;
    }

    body[data-active-tab="map"] #ai-chat-window {
        transform: translateX(100%);
    }
    body[data-active-tab="procedures"] #ai-chat-window {
        transform: translateX(-100%);
    }

    body[data-active-tab="map"] #tthc-catalog-window,
    body[data-active-tab="chat"] #tthc-catalog-window {
        transform: translateX(100%);
    }

    .ai-chat-window--visible,
    .tthc-catalog-window--visible {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0) !important;
    }

    #ai-chat-input-bar {
        padding-bottom: 13px;
    }

    body.ai-chat-modal-open,
    body.tthc-catalog-modal-open {
        overflow: hidden;
    }
}

@keyframes mobile-ai-attention {
    0% { transform: scale(0.7); opacity: 0.8; }
    70%, 100% { transform: scale(1.8); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-nav-ai-dot::after {
        animation: none !important;
    }

    .leaflet-cluster-anim .leaflet-marker-icon,
    .leaflet-cluster-anim .leaflet-marker-shadow {
        transition: none !important;
    }
}
