.ai-write-btn {
    background: rgba(179, 147, 89, 0.15);
    border: 1px solid rgba(179, 147, 89, 0.3);
    color: var(--gold);
    border-radius: 4px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-write-btn:hover { background: rgba(179, 147, 89, 0.3); transform: scale(1.05); }
.tool-mini-card {
    background: rgba(179, 147, 89, 0.05); border: 1px solid rgba(179, 147, 89, 0.2);
    border-radius: 8px; padding: 15px; text-align: center; color: var(--text);
    text-decoration: none; transition: all 0.3s ease;
}
.tool-mini-card:hover { background: rgba(179, 147, 89, 0.15); transform: translateY(-3px); border-color: var(--gold); }

/* Status Bar */
.status-bar {
    background: var(--header-bg); border-bottom: 1px solid var(--border);
    padding: 12px 40px; display: flex; justify-content: space-between;
    align-items: center; font-size: 0.7rem; font-weight: 700; color: var(--muted);
    letter-spacing: 1px;
}
.status-left { display: flex; gap: 30px; }
.status-right { display: flex; gap: 20px; color: var(--gold); }
.theme-switch-btn { font-size: 1.2rem; background: transparent; border: none; cursor: pointer; color: var(--text); }

.btn-lang {
    background: none; border: 1px solid var(--border); color: var(--text);
    padding: 8px 18px; border-radius: 2px; cursor: pointer; font-size: 0.65rem; font-weight: 900;
}
/* Bento Grid */
.grid {
    max-width: 1400px; margin: 40px auto 120px;
    display: grid; grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(170px, auto); gap: 15px; padding: 0 20px;
}

/* Grid Column Spans */
.col-full { grid-column: 1 / -1; }
.c-8 { grid-column: span 8; } .c-4 { grid-column: span 4; } 
.c-6 { grid-column: span 6; } .r-2 { grid-row: span 2; }
.c-12 { grid-column: span 12; }
.title { margin-bottom: 15px; }

.card {
    /* background and border are in common.css */
    padding: 35px; transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; position: relative;
}
.card:hover { border-color: #333; transform: translateY(-3px); }
.content { color: var(--muted); font-size: 0.95rem; line-height: 1.7; z-index: 1; }
.z-1 { z-index: 1; }
.p-15 { padding: 15px !important; }

.greeting-text { font-size: 1.3rem; font-weight: 900; color: var(--gold); margin-bottom: 8px; letter-spacing: -0.5px; }
.quote-text { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }
.timer-lbl { margin-bottom: 10px; text-align: center; }
.ops-title { font-size: 1.1rem; font-weight: 900; margin-bottom: 10px; }
.ops-content { font-size: 0.85rem; }
.stream-lbl { margin-bottom: 0; }
.stream-btn { background: transparent; border: 1px solid rgba(179,147,89,0.3); color: var(--gold); border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 0.75rem; font-weight: bold; }
.video-container { position: relative; width: 100%; height: 0; padding-bottom: 56.25%; margin-top: 10px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

/* Daily Habits & Streak */
.streak-badge { background: rgba(179, 147, 89, 0.1); color: var(--gold); padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 0.8rem; border: 1px solid rgba(179, 147, 89, 0.3); display: flex; align-items: center; gap: 6px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
.task-list { display: flex; flex-direction: column; gap: 12px; margin-top: 5px; }
.task-item { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 12px 15px; background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: 8px; transition: 0.3s; }
.task-item:hover { background: rgba(255,255,255,0.04); border-color: rgba(179, 147, 89, 0.3); }
.task-item input { accent-color: var(--gold); width: 18px; height: 18px; cursor: pointer; }
.task-item span { color: var(--text); font-size: 0.95rem; font-weight: 500; transition: 0.3s; }
.task-item.completed span { text-decoration: line-through; color: var(--muted); }

/* Purpose Box */
.purpose-box { margin-top: 22px; padding: 16px; background: rgba(179, 147, 89, 0.08); border-right: 3px solid var(--gold); border-radius: 6px; font-size: 0.88rem; color: var(--text); line-height: 1.7; }
html[dir="ltr"] .purpose-box { border-right: none; border-left: 3px solid var(--gold); }
.purpose-box strong { color: var(--gold); }

/* Daily Note / Journal */
.note-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.note-lbl { font-size: 0.75rem; color: var(--muted); margin-bottom: 8px; display: block; }
.note-input-wrap { display: flex; gap: 8px; }
.note-input { 
    width: 100%; background: transparent; border: none; color: var(--gold); 
    font-family: inherit; font-size: 0.95rem; outline: none; 
    border-bottom: 1px dashed var(--border); padding-bottom: 6px; transition: 0.3s; flex: 1;
}
.note-input:focus { border-bottom-color: var(--gold); }

.exp-input-group { display: flex; gap: 10px; margin-bottom: 15px; }
.exp-desc { flex: 2; padding: 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: inherit; }
.exp-amt { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: inherit; }
.exp-add-btn { background: var(--gold); color: #000; border: none; border-radius: 4px; padding: 0 15px; font-weight: bold; cursor: pointer; font-size: 1.2rem; }
.exp-list-wrap { max-height: 115px; overflow-y: auto; font-size: 0.9rem; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.exp-empty { text-align: center; color: var(--muted); padding: 15px; font-size: 0.85rem; border: 1px dashed rgba(179,147,89,0.2); border-radius: 4px; }
.exp-item { display: flex; justify-content: space-between; align-items: center; background: rgba(179, 147, 89, 0.05); padding: 5px 10px; border-radius: 4px; }
.exp-item-val { color: var(--gold); margin: 0 10px; }
.exp-del-btn { background: none; border: none; color: #ef4444; cursor: pointer; font-weight: bold; font-size: 1.2rem; line-height: 1; }
.exp-clear-btn { margin-inline-start: 10px; border-color: rgba(239, 68, 68, 0.3); color: #ef4444; }
.exp-total-wrap { font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.exp-total-val-wrap { color: var(--gold); font-size: 1.1rem; }

.market-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.market-lbl { margin-bottom: 0; white-space: nowrap; }
.market-controls { display: flex; gap: 4px; flex: 1; max-width: 180px; }
.market-sym-input { flex: 1; width: 100%; padding: 4px 6px; font-size: 0.75rem; border: 1px solid rgba(179,147,89,0.3); border-radius: 4px; background: transparent; color: inherit; text-transform: uppercase; }
.market-interval-select { padding: 4px; font-size: 0.75rem; border: 1px solid rgba(179,147,89,0.3); border-radius: 4px; background: transparent; color: inherit; }
.market-search-btn { background: var(--gold); color: #000; border: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 0.75rem; font-weight: bold; }
.tv-widget-container { position: relative; height: 180px; width: 100%; border-radius: 4px; overflow: hidden; }
.tv-widget-tall { height: 280px; }
.tv-widget-inner { position: relative; z-index: 1; height: 100%; width: 100%; }

.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; margin-top: 15px; }
.tool-icon { font-size: 1.8rem; margin-bottom: 8px; }
.tool-title { font-weight: 700; font-size: 0.95rem; }

/* Ticker */
.ticker-w { position: fixed; bottom: 0; width: 100%; background: #000; border-top: 1px solid var(--border); padding: 15px 0; overflow: hidden; z-index: 1000; }
.tick { display: flex; white-space: nowrap; animation: tick 60s linear infinite; }
.tick-i { padding: 0 40px; font-size: 0.75rem; font-weight: 500; color: var(--muted); }
@keyframes tick { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

/* Focus Timer Widget */
.timer-widget {
    margin-top: auto; /* Pushes to the bottom */
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center;
}
.timer-display {
    font-size: 2.5rem; font-weight: 900; color: var(--gold);
    letter-spacing: 2px; margin-bottom: 15px; font-variant-numeric: tabular-nums;
}
.timer-btn {
    background: rgba(179, 147, 89, 0.1); border: 1px solid rgba(179, 147, 89, 0.3);
    color: var(--gold); padding: 10px 20px; border-radius: 4px; cursor: pointer;
    font-weight: 700; font-size: 0.8rem; transition: 0.3s;
}
.timer-btn:hover { background: rgba(179, 147, 89, 0.2); border-color: var(--gold); }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

.quote-bg { position: absolute; right: 20px; bottom: -20px; font-size: 6rem; color: #121214; z-index: 0; font-family: serif; line-height: 1; }

/* Responsive Design for Mobile & Tablets */
@media (max-width: 900px) {
    .c-8, .c-4, .c-6 { grid-column: span 12; }
    .r-2 { grid-row: auto; }
    header { flex-direction: column; gap: 15px; padding: 15px 20px; }
    .status-bar { flex-direction: column; gap: 10px; }
}

/* AI Builder Layout */
.builder-main {
    display: block;
    max-width: 1600px;
    margin: 10px auto;
    padding: 0 20px;
    height: calc(100vh - 100px);
    overflow: hidden;
}
#ai-builder-root {
    height: 100%;
}

/* Ad Space */
.ad-space-card {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(192, 159, 107, 0.3);
    background: rgba(0,0,0,0.2);
    min-height: 150px;
}
.ad-space-text {
    color: #555;
    font-size: 0.9em;
}

/* Daily Quiz */
.quiz-title {
    color: var(--gold);
    margin: 10px 0;
}
.quiz-question {
    font-size: 1.1em;
    margin-bottom: 15px;
}
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Highlighted Tool Card */
.tool-mini-card.highlight-pro {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.05);
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}
.tool-icon.animated-breathe {
    animation: breatheAnim 3s infinite;
}
.tool-title.highlight-text {
    color: #38bdf8;
}

/* ================= NEW UI TEMPLATES STYLES (FROM ui-templates.js) ================= */

/* General Modal Overrides (applying common desktop styles) */
.ui-modal {
    padding: 40px;
    max-width: 500px;
    width: 100%; /* Ensure it takes full width on small screens */
}

/* Morning Briefing Modal */
.morning-briefing-title {
    font-size: 2em;
    margin-bottom: 15px;
}

.morning-briefing-welcome {
    font-size: 1.1em;
    color: #ccc;
    margin-bottom: 25px;
}

.morning-briefing-stats-container {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(192, 159, 107, 0.2);
}

.morning-briefing-stat-label {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 5px;
}

.morning-briefing-stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #38bdf8;
}

.morning-briefing-stat-value-expense {
    font-size: 1.8em;
    font-weight: bold;
    color: #ef4444;
}

.morning-briefing-insight {
    font-size: 1.1em;
    font-style: italic;
    line-height: 1.8;
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(192,159,107,0.1);
}

.morning-briefing-btn {
    box-shadow: 0 4px 15px rgba(192, 159, 107, 0.3);
}

/* API Modal */
.api-modal {
    padding: 30px;
    max-width: 500px;
}

.api-key-input, .api-secret-input {
    margin-bottom: 25px;
}

.api-modal-actions {
    display: flex;
    gap: 10px;
}

.api-save-btn {
    flex: 1;
}

.api-cancel-btn {
    padding: 12px 20px;
}

/* Settings Modal */
.settings-modal {
    padding: 30px;
    max-width: 500px;
}

.settings-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

.settings-option.settings-clear-data {
    margin-bottom: 30px;
    border-bottom: none;
}

.settings-label {
    font-size: 1.1em;
}

.settings-label-danger {
    color: #ef4444;
}

.ui-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.settings-clear-btn {
    padding: 8px 15px;
    font-size: 1em;
}

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

.settings-save-btn {
    flex: 1;
    padding: 15px;
    font-size: 1.1em;
}

/* Auth Modal */
.auth-modal {
    padding: 40px;
    max-width: 400px;
}

.auth-title {
    margin-bottom: 20px;
}

.auth-input {
    background: rgba(255,255,255,0.05);
    border-color: rgba(212,175,55,0.3);
    padding: 12px;
}

.auth-password-input {
    margin-bottom: 25px;
}

.auth-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-login-btn, .auth-register-btn {
    flex: 1;
}

.auth-divider {
    margin: 20px 0;
    color: #888;
    font-size: 0.9em;
}

.auth-google-btn {
    width: 100%;
    background: #fff;
    color: #000;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* SOS Modal */
.sos-modal-checklist {
    max-width: 500px;
    padding: 25px;
    border-radius: 10px;
    border: none;
}

.sos-checklist-item {
    display: block;
    margin-bottom: 20px;
    font-size: 1.1em;
    cursor: pointer;
}

.sos-checklist-item input[type="checkbox"] {
    transform: scale(1.5);
    margin: 0 15px;
}

.sos-checklist-item-last {
    margin-bottom: 10px;
}

.sos-close-btn {
    margin-top: 40px;
}

/* Risk Calculator Modal */
.risk-calc-modal {
    padding: 30px;
    max-width: 400px;
}

.risk-calc-input-group {
    margin-bottom: 15px;
}

.risk-calc-label {
    font-size: 0.9em;
    color: #ccc;
}

.risk-calc-result {
    font-size: 1.5em;
    font-weight: bold;
    color: #ef4444;
    margin-bottom: 20px;
    display: none;
    background: rgba(239,68,68,0.1);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(239,68,68,0.3);
}

.risk-calc-actions {
    display: flex;
    gap: 10px;
}

.risk-calc-btn {
    flex: 2;
}

.risk-close-btn {
    flex: 1;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 768px) {
    .ui-modal {
        padding: 20px;
        max-width: 90%;
        border-radius: 15px;
    }

    .morning-briefing-title {
        font-size: 1.4em;
    }

    .morning-briefing-welcome {
        font-size: 0.95em;
        margin-bottom: 15px;
    }

    .morning-briefing-stats-container {
        flex-direction: row;
        gap: 10px;
        padding: 15px;
    }

    .morning-briefing-stats-container > div {
        flex: 1;
        background: rgba(0, 0, 0, 0.2);
        padding: 12px 5px;
        border-radius: 12px;
        border: 1px solid rgba(255,255,255,0.02);
    }

    .morning-briefing-stat-label {
        font-size: 0.8em;
        margin-bottom: 5px;
    }
    
    .morning-briefing-stat-value, .morning-briefing-stat-value-expense {
        font-size: 1.4em;
    }
    
    .morning-briefing-insight {
        font-size: 0.95em;
        padding: 12px;
        line-height: 1.6;
    }

    .api-modal, .settings-modal, .auth-modal, .sos-modal-checklist, .risk-calc-modal {
        padding: 20px;
        max-width: 95%;
    }

    .auth-actions, .api-modal-actions, .settings-actions, .risk-calc-actions {
        flex-direction: column;
        gap: 10px;
    }

    .auth-login-btn, .auth-register-btn, .api-save-btn, .api-cancel-btn, .settings-save-btn, .risk-calc-btn, .risk-close-btn {
        flex: none;
        width: 100%;
        padding: 14px;
    }

    .sos-checklist-item {
        font-size: 0.95em;
        display: flex;
        align-items: flex-start;
        margin-bottom: 15px;
    }

    .sos-checklist-item input[type="checkbox"] {
        transform: scale(1.2);
        margin: 4px 10px 0 10px;
    }
}

@media (max-width: 480px) {
    .ui-modal {
        padding: 15px;
        width: 95%;
    }

    .morning-briefing-title {
        font-size: 1.2em;
    }

    .morning-briefing-stats-container {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }

    .morning-briefing-stat-value, .morning-briefing-stat-value-expense {
        font-size: 1.5em;
    }
}

/* Daily Quiz */
.quiz-title {
    color: var(--gold);
    margin: 10px 0;
}
.quiz-question {
    font-size: 1.1em;
    margin-bottom: 15px;
}
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Highlighted Tool Card */
.tool-mini-card.highlight-pro {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.05);
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}
.tool-icon.animated-breathe {
    animation: breatheAnim 3s infinite;
}
.tool-title.highlight-text {
    color: #38bdf8;
}