/* AI Tử Vi - Vận Hạn 2026 Production Theme */
:root {
    --bg-primary: #0a0f1d;
    --bg-secondary: #131c31;
    --bg-card: #1a2540;
    --border-color: #2a3b63;
    --border-gold: #d4af37;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-gold: #fbbf24;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-blue: #38bdf8;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
    --font-serif: "Times New Roman", "Noto Serif", Georgia, serif;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #0d1527 0%, #172340 100%);
    border-bottom: 2px solid var(--border-gold);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    color: var(--text-gold);
}

.logo-text h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fff;
}

.logo-text span {
    font-size: 0.8rem;
    color: var(--text-gold);
    background: rgba(212, 175, 55, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

/* Nav Tabs */
nav.tab-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0.5rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--text-gold);
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--border-gold);
}

/* Main Layout */
main {
    max-width: 1440px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Form Section */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input, .form-group select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--text-gold);
}

.btn-primary {
    background: linear-gradient(135deg, #d4af37 0%, #b8972e 100%);
    color: #0f172a;
    font-weight: 700;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.preset-actions {
    margin-top: 1rem;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-preset {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-preset:hover {
    color: var(--text-gold);
    border-color: var(--text-gold);
}

/* 4x4 Thiên Địa Bàn Grid */
.tuvi-grid-wrapper {
    overflow-x: auto;
    padding-bottom: 1.5rem;
}

.tuvi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(240px, 1fr));
    grid-template-rows: repeat(4, minmax(200px, 1fr));
    gap: 8px;
    min-width: 980px;
    background: #060913;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid var(--border-gold);
}

.tuvi-grid.chart-load-error {
    display: block;
    min-width: 0;
    width: 100%;
    min-height: 0;
    padding: 16px;
}

/* Palace Cell Mapping (Traditional Clockwise) */
.cung-slot-6  { grid-column: 1; grid-row: 1; } /* Tỵ */
.cung-slot-7  { grid-column: 2; grid-row: 1; } /* Ngọ */
.cung-slot-8  { grid-column: 3; grid-row: 1; } /* Mùi */
.cung-slot-9  { grid-column: 4; grid-row: 1; } /* Thân */
.cung-slot-5  { grid-column: 1; grid-row: 2; } /* Thìn */
.cung-slot-10 { grid-column: 4; grid-row: 2; } /* Dậu */
.cung-slot-4  { grid-column: 1; grid-row: 3; } /* Mão */
.cung-slot-11 { grid-column: 4; grid-row: 3; } /* Tuất */
.cung-slot-3  { grid-column: 1; grid-row: 4; } /* Dần */
.cung-slot-2  { grid-column: 2; grid-row: 4; } /* Sửu */
.cung-slot-1  { grid-column: 3; grid-row: 4; } /* Tý */
.cung-slot-12 { grid-column: 4; grid-row: 4; } /* Hợi */

.thien-ban-center {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background: linear-gradient(135deg, #131c33 0%, #1e2c50 100%);
    border: 2px solid var(--border-gold);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-primary);
}

.thien-ban-center h2 {
    color: var(--text-gold);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-serif);
}

.thien-ban-center .sub-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.thien-ban-center .badge-banmenh {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    margin-top: 6px;
}

.cung-cell {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.cung-cell:hover {
    border-color: var(--text-gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
}

.cung-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.cung-name-badge {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-gold);
}

.cung-than-badge {
    background: #dc2626;
    color: white;
    font-size: 0.7rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.cung-stars-body {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 0.8rem;
}

.chinh-tinh-box {
    grid-column: 1 / 3;
    text-align: center;
    margin-bottom: 4px;
    padding: 2px;
}

.star-chinh {
    font-size: 0.95rem;
    font-weight: 800;
}

.star-dactinh {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 2px;
}

.cung-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px dashed var(--border-color);
    padding-top: 4px;
    margin-top: 4px;
}

/* Five-Element Star Colors */
.hanhKim { color: #94a3b8 !important; font-weight: 600; }
.hanhMoc { color: #22c55e !important; font-weight: 600; }
.hanhThuy { color: #38bdf8 !important; font-weight: 600; }
.hanhHoa { color: #f87171 !important; font-weight: 600; }
.hanhTho { color: #fbbf24 !important; font-weight: 600; }

/* Bát Tự Hà Lạc Hexagram */
.hexagram-card {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 2rem;
    align-items: center;
}

.hexagram-visual {
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    width: 120px;
}

.hex-line {
    height: 12px;
    border-radius: 2px;
}

.hex-yang {
    background: #d4af37;
}

.hex-yin {
    display: flex;
    justify-content: space-between;
}

.hex-yin::before, .hex-yin::after {
    content: "";
    width: 44%;
    height: 100%;
    background: #38bdf8;
    border-radius: 2px;
}

.hex-moving {
    box-shadow: 0 0 10px #ef4444;
    border: 1px solid #ef4444;
}

/* Reading Viewer */
.reading-viewer {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 1.5rem;
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-gold);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.reading-body {
    font-size: 1.05rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.toggle-container {
    display: flex;
    gap: 6px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.toggle-btn.active {
    background: var(--text-gold);
    color: #0f172a;
}

/* Chatbot Widget */
.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-bubble {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.bubble-bot {
    align-self: flex-start;
    background: #17233f;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #d4af37 0%, #b8972e 100%);
    color: #0f172a;
    font-weight: 500;
}

.chat-input-row {
    display: flex;
    gap: 10px;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-input-row input {
    flex-grow: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 6px;
}

.chat-actions-container {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

.btn-new-chat-session {
    background: linear-gradient(135deg, #d4af37 0%, #b8972e 100%);
    color: #0f172a;
    border: 1px solid var(--border-gold);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-new-chat-session:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.btn-new-chat-session:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-session-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    width: 100%;
}

.chat-session-divider::before,
.chat-session-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed var(--border-color);
}

.chat-session-divider span {
    padding: 0 12px;
    color: var(--text-gold);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border: 2px solid var(--border-gold);
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Turnstile Verification Modal Dialog */
.turnstile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 15, 29, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 1rem;
    box-sizing: border-box;
}

.turnstile-modal-overlay[hidden] {
    display: none !important;
}

.turnstile-modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    width: 100%;
    max-width: 360px;
    box-sizing: border-box;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    text-align: center;
    position: relative;
}

.turnstile-modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-gold);
    margin: 0;
}

.turnstile-widget-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 65px;
    width: 100%;
    overflow: hidden;
}

.turnstile-modal-cancel-btn {
    padding: 0.5rem 1.5rem;
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.turnstile-modal-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.reading-validation-notice {
    color: var(--text-gold, #fbbf24);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 8px 0;
}

.reading-error {
    color: #fca5a5 !important;
    border-left: 3px solid #ef4444;
    padding-left: 10px;
}

/* Android-inspired light interface */
:root {
    --bg-primary: #fffdf9;
    --bg-secondary: #fff8f1;
    --bg-card: #fff;
    --border-color: #e0e0e0;
    --border-gold: #f79009;
    --text-primary: #292929;
    --text-secondary: #626262;
    --text-gold: #b45100;
    --shadow-soft: 0 3px 16px rgba(85, 55, 28, .07);
}
header { background: #fff; border-bottom: 1px solid var(--border-color); box-shadow: none; padding: 12px 16px; gap: 12px; flex-wrap: wrap; position: static; }
.logo-area { min-width: 0; }
.logo-icon { color: #f79009; }
.logo-text h1 { color: #1a1a1a; font-family: var(--font-serif); font-size: 1.1rem; }
.logo-text span { color: #8a520c; background: #fff4ea; border: 0; padding: 0; }
#system-status-indicator { white-space: normal; }
nav.tab-nav { background: #fff; padding: 0 16px; gap: 0; flex-wrap: wrap; overflow: visible; }
.tab-btn { padding: 11px 12px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; white-space: normal; }
.tab-btn:hover { background: #fff8f1; }
.tab-btn.active { background: transparent; color: #9a3f00; border-color: #f79009; }
main { padding: 0 16px; margin: 20px auto; }
.form-card, .reading-viewer, .chat-container { border-radius: 8px; }
.form-title { font: 700 1.4rem/1.35 var(--font-serif); text-align: center; margin-bottom: 22px; color: #171717; }
.form-group input, .form-group select { background: #fff; min-width: 0; }
.btn-primary { background: #9a3f00; color: white; }
.btn-primary:hover { background: #7c3200; box-shadow: 0 4px 12px rgba(154, 63, 0, .25); }
.btn-preset { background: #fff; }
.tuvi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(180px, auto)); min-width: 0; gap: 0; padding: 0; border: 1px solid #d1d5db; border-radius: 0; background: white; }
.tuvi-grid-wrapper { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }
.cung-cell { min-width: 0; border-radius: 0; padding: 7px; overflow-wrap: anywhere; }
.cung-cell:hover { transform: none; }
.cung-header { align-items: flex-start; }
.cung-name-badge { color: #252525; font-family: var(--font-serif); }
.thien-ban-center { background: #fffdf9; border: 1px solid #d1d5db; border-radius: 0; padding: 12px; min-width: 0; position: relative; }
.thien-ban-center h2 { color: #9a3f00; }
.thien-ban-center .badge-banmenh { color: #a92121; }
.hanhKim, .hanhThuy { color: #252525 !important; }
.hanhMoc { color: #15803d !important; }
.hanhHoa { color: #c62828 !important; }
.hanhTho { color: #b45309 !important; }
.hex-yang, .hex-yin::before, .hex-yin::after { background: #222; }
.reading-header { gap: 12px; flex-wrap: wrap; }
.reading-header > div { min-width: 0; flex-wrap: wrap; }
.toggle-btn.active { background: #9a3f00; color: #fff; }
.bubble-bot { background: #fff8f1; }
.bubble-user { background: #9a3f00; color: #fff; }
.lookup-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.cycle-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cycle-controls select { padding: 6px; border: 1px solid var(--border-color); border-radius: 6px; background: white; }
.cycle-controls .active { color: #a34a00; border-color: #f79009; background: #fff4ea; }
.chat-input-row input { min-width: 0; }
.modal-overlay { background: rgba(30, 20, 10, .5); }
.reading-error { color: #a71919 !important; }
@media (max-width: 768px) {
    main { padding: 0 16px; margin: 16px auto; }
    header { padding: 12px 16px; }
    nav.tab-nav { padding: 0 16px; }
    .lookup-layout { grid-template-columns: minmax(0, 1fr); }
    .reading-viewer, .form-card { padding: 16px; }
    .reading-header > div { width: 100%; }
    .reading-header select { max-width: 100%; }
    /* Grid 12 cung scrollable horizontally without distorting aspect ratio or squishing stars */
    .tuvi-grid { min-width: 620px; grid-template-rows: repeat(4, minmax(140px, auto)); }
    .cung-cell { padding: 4px; }
    .cung-name-badge, .cung-stars-body, .cung-footer, .star-chinh { font-size: .65rem; line-height: 1.3; }
    .cung-footer { display: block; }
    .thien-ban-center { padding: 8px; }
    .thien-ban-center h2 { font-size: .95rem; }
    .thien-ban-center .sub-info { font-size: .68rem; line-height: 1.3; }
    .thien-ban-center .badge-banmenh { font-size: .68rem; }
    .form-group { width: 100%; min-width: 0 !important; }
    .form-group select, .form-group input { width: 100%; max-width: 100%; }
    .btn-primary, .btn-preset { max-width: 100%; white-space: normal; }
}

/* Safety & Layout Invariants */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Error formatting with Setup Hint separation */
.error-main-message {
    font-weight: 600;
    margin-bottom: 6px;
    color: #991b1b;
    line-height: 1.45;
}
.error-setup-hint {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff4ea;
    border-left: 3px solid #f79009;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #8a520c;
    line-height: 1.45;
    word-break: break-word;
}
.error-hint-label {
    font-weight: 700;
    color: #b45100;
}

/* Chat session badge */
.chat-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    display: inline-block;
}
.chat-badge.status-ready {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}
.chat-badge.status-loading {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}
.chat-badge.status-typing {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.chat-badge.status-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}


/* On-Demand AI & Local Reading Styles */
.local-reading-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.reading-local-notice {
    font-size: 0.85rem;
    color: var(--text-gold, #b45100);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.local-section-box {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color);
}

.local-section-box:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.local-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.local-section-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.ai-action-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.25rem 0;
    padding: 12px 16px;
    background: #fff4ea;
    border: 1px solid rgba(247, 144, 9, 0.3);
    border-radius: 8px;
    flex-wrap: wrap;
}

.btn-ai-reading {
    background: #9a3f00;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-ai-reading:hover:not(:disabled) {
    background: #7c3200;
    box-shadow: 0 4px 12px rgba(154, 63, 0, 0.3);
}

.btn-ai-reading:disabled {
    background: #d1d5db;
    color: #6b7280;
    cursor: not-allowed;
    box-shadow: none;
}

.ai-action-note {
    font-size: 0.85rem;
    color: #8a520c;
    flex: 1;
    min-width: 220px;
    line-height: 1.4;
}

.ai-reading-container {
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.ai-reading-body {
    max-width: 75ch;
    margin-left: auto;
    margin-right: auto;
    font-size: 1.02rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ai-reading-body.reading-error {
    white-space: pre-wrap;
}

/* AI reading: formatted markdown, colors tuned for the light cream page */
.ai-heading {
    font-family: var(--font-serif);
    font-weight: 700;
    line-height: 1.4;
    color: #92400e;
    margin-top: 1.5rem;
    margin-bottom: 0.6rem;
}

.ai-heading:first-child {
    margin-top: 0.2rem;
}

.ai-heading-1 {
    font-size: 1.35rem;
    color: #92400e;
    border-bottom: 1px solid rgba(146, 64, 14, 0.30);
    padding-bottom: 0.35rem;
}

.ai-heading-2 {
    font-size: 1.22rem;
    color: #b45309;
    border-bottom: 1px solid rgba(146, 64, 14, 0.20);
    padding-bottom: 0.25rem;
}

.ai-heading-3 {
    font-size: 1.12rem;
    color: #92400e;
    border-left: 3px solid var(--border-gold);
    padding-left: 0.6rem;
}

.ai-heading-4,
.ai-heading-5,
.ai-heading-6 {
    font-size: 1.04rem;
    color: #b45309;
}

.ai-paragraph {
    margin: 0.85rem 0;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-paragraph:first-child {
    margin-top: 0;
}

.ai-paragraph:last-child {
    margin-bottom: 0;
}

.ai-divider {
    border: 0;
    border-top: 1px solid rgba(146, 64, 14, 0.22);
    margin: 1.4rem 0;
}

.ai-list {
    margin: 0.6rem 0 0.85rem 1.6rem;
    padding: 0;
    line-height: 1.75;
}

.ai-list-unordered {
    list-style-type: disc;
}

.ai-list-ordered {
    list-style-type: decimal;
}

.ai-list-item {
    margin: 0.35rem 0;
    word-break: break-word;
}

.ai-list .ai-list {
    margin: 0.25rem 0 0.25rem 1.4rem;
}

.ai-list-item::marker {
    color: #b45309;
}

.ai-bold,
.ai-reading-body strong,
.reading-body strong,
.bubble-bot strong {
    font-weight: 700;
    color: #7c2d12;
}

.ai-italic,
.ai-reading-body em,
.reading-body em,
.bubble-bot em {
    font-style: italic;
    color: #475569;
}

.ai-citation-badge {
    display: inline-block;
    font-size: 0.82em;
    padding: 1px 7px;
    margin: 0 3px;
    border-radius: 4px;
    background: rgba(126, 34, 206, 0.09);
    color: #6b21a8;
    border: 1px solid rgba(126, 34, 206, 0.30);
    vertical-align: baseline;
    font-weight: normal;
    word-break: break-word;
}

.ai-unsourced-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 6px 12px;
    background: rgba(126, 34, 206, 0.06);
    border-left: 3px solid #9333ea;
    border-radius: 4px;
    display: block;
    line-height: 1.5;
}

.reading-subtopic-notice {
    font-size: 0.85rem;
    color: var(--text-secondary, #626262);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.local-day-card {
    line-height: 1.6;
}

.local-day-card p {
    margin: 4px 0;
}

.bubble-bot .ai-heading {
    margin-top: 0.8rem;
    margin-bottom: 0.4rem;
    font-size: 1.08rem;
}

.bubble-bot .ai-heading:first-child {
    margin-top: 0;
}

.bubble-bot .ai-paragraph {
    margin: 0.45rem 0;
    line-height: 1.65;
}

.bubble-bot .ai-list {
    margin: 0.35rem 0 0.45rem 1.3rem;
}

.bubble-bot .ai-divider {
    margin: 0.75rem 0;
}

.chat-token-cost {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
}

.hexagram-info {
    width: 100%;
}

/* Lunar leap & calendar controls */
.calendar-hint {
    font-size: 0.8rem;
    color: var(--text-gold);
    margin-top: 4px;
    line-height: 1.35;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
    padding-top: 28px;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--border-gold);
    cursor: pointer;
}

.form-error-alert {
    margin-top: 1rem;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid var(--accent-red);
    border-radius: 6px;
    color: #a71919;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
}

/* Reading coverage badge */
.coverage-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    line-height: 1.4;
    margin-right: 8px;
    margin-bottom: 4px;
    vertical-align: middle;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

.coverage-badge.badge-coverage-sourced {
    background: #fff4ea;
    color: #b45100;
    border: 1px solid #f79009;
}

.coverage-badge.badge-coverage-partial {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.coverage-badge.badge-coverage-ai_only {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

.coverage-badge.badge-coverage-unknown {
    background: #fff8f1;
    color: #9a3412;
    border: 1px solid #fdba74;
}

.reading-label-audit-notice,
.reading-citation-warning-notice {
    display: block;
    font-size: 0.78rem;
    color: #b45100;
    margin-top: 4px;
    font-style: italic;
    word-break: break-word;
    max-width: 100%;
}

/* -------------------------------------------------------------
   MÀN CHÀO GỌN (WELCOME ONBOARDING CARD)
   ------------------------------------------------------------- */
.welcome-card {
    background: #fffdf9;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-soft);
    box-sizing: border-box;
    max-width: 100%;
}

.welcome-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.welcome-emblem {
    font-size: 2.2rem;
    color: #76251D;
    line-height: 1;
}

.welcome-header-text {
    flex: 1;
    min-width: 200px;
}

.welcome-title {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    color: #1a1a1a;
    font-weight: 700;
    line-height: 1.3;
}

.welcome-subtitle {
    font-size: 0.8rem;
    color: #8a520c;
    background: #fff4ea;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 2px;
}

.welcome-desc {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #4a5568;
    margin-bottom: 14px;
    word-break: break-word;
}

.welcome-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.welcome-pill {
    font-size: 0.78rem;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.welcome-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-welcome-start {
    display: inline-block;
    text-decoration: none;
    padding: 9px 20px;
    font-weight: 600;
    font-size: 0.92rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* -------------------------------------------------------------
   QUẢN LÝ LÁ SỐ (DANH SÁCH HỒ SƠ ĐÃ LƯU)
   ------------------------------------------------------------- */
.profile-manager-card {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.profile-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.profile-manager-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: #1a1a1a;
    font-weight: 700;
}

.profile-manager-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.profile-manager-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.saved-profiles-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.profile-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.profile-card:hover {
    border-color: var(--border-gold);
    box-shadow: 0 2px 8px rgba(247, 144, 9, 0.1);
}

.profile-card-info {
    flex: 1;
    min-width: 200px;
}

.profile-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a1a1a;
    margin-bottom: 3px;
    word-break: break-word;
}

.profile-card-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.profile-card-time {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 3px;
}

.btn-load-profile {
    background: #fff4ea;
    color: #c45c00;
    border: 1px solid #f79009;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-load-profile:hover {
    background: #f79009;
    color: #fff;
}

.profile-empty-state {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 16px;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.profile-load-error {
    font-size: 0.85rem;
    color: #b91c1c;
    padding: 12px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    border-radius: 6px;
}

/* -------------------------------------------------------------
   NGUYỆT VẬN (12 THÁNG DẠNG ACCORDION)
   ------------------------------------------------------------- */
.reading-hypothesis-notice {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid #f79009;
    border-radius: 4px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #92400e;
    line-height: 1.5;
    margin-bottom: 14px;
    word-break: break-word;
}

.nguyet-van-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.accordion-item {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    width: 100%;
}

.accordion-item.active {
    border-color: var(--border-gold);
    box-shadow: 0 2px 8px rgba(247, 144, 9, 0.12);
}

.accordion-header {
    padding: 10px 14px;
    background: #fffdf9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 8px;
}

.accordion-header:hover {
    background: #fff8f1;
}

.accordion-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.accordion-month-title {
    font-weight: 700;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: #1a1a1a;
}

.accordion-palace-tag {
    font-size: 0.78rem;
    color: #c45c00;
    background: #fff4ea;
    border: 1px solid rgba(247, 144, 9, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.badge-hypothesis-tag {
    font-size: 0.72rem;
    color: #8a520c;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 1px 6px;
    border-radius: 4px;
    font-style: italic;
}

.accordion-icon {
    font-size: 0.72rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.9rem;
    line-height: 1.6;
    display: none;
    box-sizing: border-box;
}

.accordion-item.active .accordion-body {
    display: block;
}

.accordion-body-loading {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 10px 0;
}

/* ========================================================
   Khoảng trống giao diện Android (T48):
   1. Dấu triện đỏ cổ truyền trên Thiên Bàn (.thien-ban-seal)
   2. Thanh phản hồi / tương tác bài luận (.reading-feedback-bar)
   3. Phân loại hồ sơ & đếm số lượng (.profile-count-badge, .profile-tag-badge)
   ======================================================== */

.thien-ban-seal {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    border: 2px solid #a92121;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #a92121;
    font-size: 0.60rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 1px;
    opacity: 0.88;
    transform: rotate(-3deg);
    pointer-events: none;
    box-shadow: inset 0 0 0 1px #a92121;
    background: rgba(255, 253, 249, 0.75);
    font-family: var(--font-serif, serif);
    user-select: none;
    box-sizing: border-box;
}

.thien-ban-seal .seal-line {
    display: block;
}

@media (max-width: 768px) {
    .thien-ban-seal {
        width: 36px;
        height: 36px;
        font-size: 0.50rem;
        bottom: 4px;
        right: 4px;
    }
}

.reading-feedback-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 10px;
    background: #fffdf9;
    border: 1px dashed #e5e7eb;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    box-sizing: border-box;
}

.feedback-label {
    font-weight: 600;
    color: #4b5563;
    font-size: 0.8rem;
}

.feedback-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-feedback {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.78rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-feedback:hover {
    border-color: #f79009;
    color: #c45c00;
}

.btn-feedback.active {
    background: #fff4ea;
    border-color: #f79009;
    color: #c45c00;
    font-weight: 600;
}

.feedback-msg {
    font-size: 0.78rem;
    color: #15803d;
    font-style: italic;
    margin-left: 4px;
}

.profile-manager-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-count-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: #9a3f00;
    background: #fff4ea;
    border: 1px solid #fbd38d;
    padding: 2px 8px;
    border-radius: 12px;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}

.profile-tag-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
}

.badge-primary-profile {
    background: #fff4ea;
    color: #c45c00;
    border: 1px solid #f79009;
}

.badge-other-profile {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.profile-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-copy-profile, .btn-delete-profile {
    background: #ffffff;
    color: #4b5563;
    border: 1px solid #d1d5db;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 32px;
}

.btn-copy-profile:hover, .btn-delete-profile:hover {
    border-color: #f79009;
    color: #c45c00;
}


/* Input Limits & Character Counters (LE-248) */
.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-counter {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

.char-counter.limit-reached {
    color: #ef4444;
    font-weight: 600;
}

.chat-counter-bar {
    display: flex;
    justify-content: flex-end;
    padding: 4px 1rem 0 1rem;
    background: var(--bg-secondary);
}

.error-id-badge {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #ef4444;
    font-family: monospace;
    word-break: break-all;
    background: rgba(239, 68, 68, 0.1);
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    display: inline-block;
}

/* ==========================================================================
   SCORE RADAR & PALACE SCORING (v2.2 Self-designed)
   ========================================================================== */
.score-radar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-soft);
    width: 100%;
    box-sizing: border-box;
}

.score-card-header {
    margin-bottom: 1.25rem;
}

.score-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 0.75rem;
}

.score-title {
    color: var(--text-gold);
    font-size: 1.25rem;
    font-weight: 700;
}

.score-version-badge {
    background: rgba(251, 191, 36, 0.15);
    color: var(--text-gold);
    border: 1px solid rgba(251, 191, 36, 0.4);
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.score-warning-notice {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--accent-red);
    color: #a71919;
    padding: 0.75rem 1rem;
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
}

.score-radar-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
    margin-bottom: 1.25rem;
}

@media (max-width: 900px) {
    .score-radar-layout {
        grid-template-columns: 1fr;
    }
}

.radar-visual-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}

.radar-chart-container {
    width: 100%;
    max-width: 440px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-height: 280px;
}

.radar-chart-container svg {
    width: 100%;
    height: auto;
    max-width: 420px;
    display: block;
}

.radar-loading-state {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 2rem;
    text-align: center;
}

.radar-grid-polygon {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 1;
}

.radar-grid-baseline {
    fill: none;
    stroke: var(--border-gold);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
    opacity: 0.8;
}

.radar-axis-line {
    stroke: var(--border-color);
    stroke-width: 1;
    opacity: 0.6;
}

.radar-data-polygon {
    fill: rgba(251, 191, 36, 0.25);
    stroke: var(--text-gold);
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.radar-point {
    fill: var(--text-gold);
    stroke: var(--bg-primary);
    stroke-width: 2;
    cursor: pointer;
    transition: r 0.2s, fill 0.2s;
}

.radar-point:hover, .radar-point.active {
    r: 7;
    fill: #fff;
    stroke: var(--text-gold);
}

.radar-axis-label {
    fill: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: fill 0.2s, font-weight 0.2s;
    user-select: none;
}

.radar-axis-label:hover, .radar-axis-label.active {
    fill: var(--text-gold);
    font-weight: 700;
}

.radar-palace-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 1rem;
    justify-content: center;
    width: 100%;
}

.radar-palace-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    gap: 4px;
    align-items: center;
    transition: all 0.2s;
}

.radar-palace-btn:hover {
    color: var(--text-primary);
    border-color: #b45309;
}

.radar-palace-btn.active {
    background: #fff4ea;
    border-color: #f79009;
    color: #8a3b00;
    font-weight: 600;
}

.radar-palace-score-pill {
    font-size: 0.7rem;
    font-weight: 700;
    background: #334155;
    color: #ffffff;
    padding: 1px 5px;
    border-radius: 3px;
}

.radar-detail-col {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
    box-sizing: border-box;
    width: 100%;
}

.score-palace-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.score-detail-placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 2rem 1rem;
    text-align: center;
}

.score-palace-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.score-palace-name {
    color: var(--text-gold);
    font-size: 1.15rem;
    font-weight: 700;
}

.score-palace-score-badge {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    padding: 4px 12px;
    border-radius: 6px;
}

.score-palace-warning {
    margin: 0.25rem 0;
    font-size: 0.8rem;
}

.score-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.score-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.score-badge-raw {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
}

.score-badge-clamped {
    background: #fee2e2;
    border: 1px solid #dc2626;
    color: #991b1b;
}

.score-badge-source-no-grade {
    background: #e0f2fe;
    border: 1px solid #0284c7;
    color: #0369a1;
}

.score-badge-missing-grade {
    background: #fef3c7;
    border: 1px solid #d97706;
    color: #92400e;
}

.score-badge-flags {
    background: #f3e8ff;
    border: 1px solid #9333ea;
    color: #6b21a8;
}

.score-badge-than {
    background: #dcfce7;
    border: 1px solid #16a34a;
    color: #166534;
}

.score-baseline-explanation {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.score-baseline-explanation strong {
    color: #b45309;
}

.score-components-box {
    margin-top: 0.5rem;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
}

.score-components-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.score-components-table th, .score-components-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.score-components-table th {
    background: var(--bg-card);
    color: var(--text-gold);
    font-weight: 600;
}

.score-components-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.score-contrib-pos {
    color: #166534;
    font-weight: 600;
}

.score-contrib-neg {
    color: #b91c1c;
    font-weight: 600;
}

.score-contrib-zero {
    color: var(--text-secondary);
}

.score-technical-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
}

.score-tech-header {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.score-tech-title {
    color: var(--text-gold);
    font-weight: 700;
}

.score-tech-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.score-tech-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.score-tech-item {
    display: flex;
    gap: 6px;
    align-items: center;
}

.score-tech-label {
    color: var(--text-secondary);
}

.score-tech-value {
    color: var(--text-primary);
    font-weight: 700;
}

/* Touch targets stay at least 24 px and the chart grid says it scrolls sideways on narrow screens. */
button, select, input:not([type="hidden"]) { min-height: 24px; }
.checkbox-label input[type="checkbox"] { min-width: 24px; min-height: 24px; }
.grid-scroll-hint { display: none; margin: 0 0 6px; font-size: .8rem; color: var(--text-secondary); text-align: center; }
@media (max-width: 768px) {
    .grid-scroll-hint { display: block; }
}
