:root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-text: #f8fafc;
    --color-text-muted: #94a3b8;
    --color-primary: #3b82f6;

    /* Mood Colors */
    --color-mood-minus-1: #ef4444;
    --color-mood-0: #94a3b8;
    --color-mood-1: #3b82f6;
    --color-mood-2: #10b981;
    --color-mood-3: #f59e0b;
    --color-mood-4: #d946ef;

    --font-family: 'Inter', sans-serif;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --color-success: #10b981;
    --color-bad: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.lang-switcher {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 5px;
}

.lang-switcher button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: all 0.2s;
}

.lang-switcher button.active,
.lang-switcher button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.app-header h1 {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 20px;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: var(--radius-lg);
    position: sticky;
    top: 10px;
    z-index: 110;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

nav button {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

nav button.active {
    background-color: var(--color-bg);
    color: var(--color-text);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Main Content Area */
#main-content {
    flex: 1;
}

#main-content>div {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Today View */
.today-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.date-display {
    text-align: center;
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

/* Mood Buttons & Selector */
.mood-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mood-btn {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    overflow: hidden;
}

.mood-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.03), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.mood-btn:hover {
    transform: translateY(-2px);
    background: #2d3b4e;
}

.mood-btn:hover::before {
    transform: translateX(100%);
}

.mood-btn:active {
    transform: scale(0.98);
}

.mood-btn.selected {
    border-color: var(--selected-color);
    background: rgba(255, 255, 255, 0.05);
}

.mood-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--btn-color);
}

.mood-label {
    font-weight: 600;
    font-size: 1.1rem;
}

.mood-desc {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-left: auto;
}

/* Calendar View */
.calendar-year-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.month-block h3 {
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.day-cell {
    aspect-ratio: 1;
    background: var(--color-surface);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 44px;
}

.day-cell:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.day-cell.is-today {
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 10px var(--color-primary);
    font-weight: bold;
    color: white;
}

.btn-text {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 10px;
    padding: 5px 0;
}

.btn-text:hover {
    text-decoration: underline;
}

/* Stats View */
.stats-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.stats-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 10px 0;
}

.recommendation {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    box-shadow: var(--shadow-lg);
}

/* Utilities & Animations */
.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-surface);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Year Navigation */
.year-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: var(--radius-md);
    position: sticky;
    top: 70px;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.year-nav button {
    background: var(--color-bg);
    border: none;
    color: var(--color-text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.year-nav button:hover {
    background: var(--color-primary);
}

.year-label {
    font-size: 1.2rem;
    font-weight: 700;
}

/* Stats Counts */
.stats-counts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mood-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.stat-count {
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.9rem;
}

/* Help Links */
.help-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.help-links a {
    color: var(--color-primary);
    text-decoration: none;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    transition: background 0.2s;
    display: block;
    text-align: center;
}

.help-links a:hover {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: underline;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.footer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 5px;
}

.btn-footer-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
}

.btn-footer-action:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    border-color: var(--color-text-muted);
}

.app-footer a {
    color: var(--color-text-muted);
    text-decoration: underline;
}

.app-footer a:hover {
    color: var(--color-text);
}


/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    padding: 20px;
}

.modal-content {
    background: var(--color-surface);
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--color-text);
}


/* --- NEW SETTINGS STYLES (Card Grid) --- */

.settings-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding-bottom: 40px;
}

.settings-section-title {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.mood-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.mood-edit-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    transition: all 0.2s;
    animation: fadeIn 0.3s ease;
}

.mood-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.mood-edit-card {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    transition: all 0.2s;
    animation: fadeIn 0.3s ease;
    height: auto;
    /* Allow growth */
}

.mood-edit-card textarea.inp-desc {
    resize: vertical;
    min-height: 60px;
    white-space: pre-wrap;
    line-height: 1.4;
}

.mood-edit-card:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-header {
    display: none;
    /* Hide old header */
}

.mood-preview {
    display: none;
    /* Hide old preview */
}

/* Compact Top Row */
.compact-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.settings-input-color {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.settings-input-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.settings-input-color::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.settings-input.inp-val {
    width: 50px;
    padding: 2px 5px;
    text-align: center;
    font-weight: bold;
    height: 24px;
    font-size: 0.9rem;
}

.btn-icon-delete {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
    font-size: 1.1rem;
}

.btn-icon-delete:hover {
    color: #ef4444;
}

/* Text Inputs */
.settings-input.inp-label {
    font-weight: 600;
    font-size: 0.85rem;
    padding: 5px;
    margin-bottom: 2px;
}

.settings-input.inp-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: 5px;
    background: rgba(0, 0, 0, 0.15);
}

.input-group {
    display: none;
}

/* Ensure old groups are hidden if they exist */

.btn-add-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    cursor: pointer;
    gap: 5px;
    color: var(--color-text-muted);
}

.btn-add-card:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.edit-actions-bar {
    position: sticky;
    bottom: 15px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: var(--radius-lg);
    display: flex;
    gap: 10px;
    z-index: 90;
    margin-top: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.data-management-card {
    background: rgba(30, 41, 59, 0.4);
    border-radius: var(--radius-md);
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-save,
.btn-reset {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.btn-save {
    background: var(--color-primary);
    color: white;
}

.btn-reset {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--color-text-muted);
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 20px);
    background-color: var(--color-success);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    font-weight: 600;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-icon {
    font-size: 1.2rem;
}

/* --- Entry Notes --- */
.entry-note-wrapper {
    margin-top: 10px;
}

.entry-note-area {
    width: 100%;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 15px;
    color: var(--color-text);
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.entry-note-area:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(30, 41, 59, 0.8);
}

/* --- Calendar Note Indicator --- */
.day-cell.has-note::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* --- Stats Notes List --- */
.stats-notes-container {
    margin-top: 20px;
}

.stats-notes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.stats-note-item {
    background: rgba(30, 41, 59, 0.6);
    padding: 15px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid var(--color-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left-width: 4px;
}

.stats-note-item:hover {
    transform: translateY(-2px);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.stats-note-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.stats-note-text {
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* --- Missed Days Banner --- */
.missed-days-banner {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--color-text);
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.missed-days-banner strong {
    color: #f59e0b;
    font-size: 1.05rem;
    display: inline-block;
    margin-bottom: 5px;
}