:root {
    --primary: #e63946;
    --primary-dark: #c1121f;
    --success: #2d6a4f;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e0e0e0;
    --text-muted: #888888;
    --border: #2a2a2a;
    --radius: 6px;
    --accent: #e63946;
}

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

body {
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Nav */
.navbar {
    background: #0a0a0a;
    color: white;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--accent);
}
.navbar a { color: #ccc; text-decoration: none; transition: color 0.2s; }
.navbar a:hover { color: white; }
.navbar .brand {
    font-weight: 900;
    font-size: 1.3rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
}
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.nav-links a:hover, .nav-links a.active { background: rgba(230,57,70,0.15); color: var(--accent); }

/* Nav dropdowns */
.nav-dropdown { position: relative; }
.nav-dropdown > .nav-dd-toggle {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
    display: inline-block;
}
.nav-dropdown.active > .nav-dd-toggle,
.nav-dropdown > .nav-dd-toggle:hover { background: rgba(230,57,70,0.15); color: var(--accent); }
.nav-dd-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 140px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 200;
    padding: 0.25rem 0;
    margin-top: 0.2rem;
}
.nav-dropdown.open > .nav-dd-menu { display: block; }
.nav-dd-menu a {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
}
.nav-dd-menu a:hover, .nav-dd-menu a.active { background: rgba(230,57,70,0.1); color: var(--accent); }

/* Motivation cards */
.motivation-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
    align-items: flex-start;
}
.motivation-card:hover { background: #252525; border-color: var(--accent); }
.motivation-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card h2 { margin-bottom: 1rem; font-size: 1.25rem; color: #f0f0f0; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}
.form-group { display: flex; flex-direction: column; }
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input, .form-group select, .form-group textarea {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: #161616;
    color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(230,57,70,0.15);
}
.form-full { grid-column: 1 / -1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s, transform 0.1s;
    color: white;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: #3a3a3a; color: #e0e0e0; }
.btn-primary:hover { background: #555; color: #fff; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1b4332; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 700; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* Flash messages */
.flash { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-error { background: #2d1215; color: #f87171; border: 1px solid #7f1d1d; }
.flash-success { background: #132a1c; color: #6ee7b7; border: 1px solid #1b4332; }

/* Auth pages */
.auth-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 1.5rem;
}
.auth-container .card {
    text-align: center;
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
}
.auth-container input {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.6rem;
    background: #161616;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.auth-container input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(230,57,70,0.15);
}
.auth-container .btn { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* Stats bar */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    border-top: 2px solid var(--accent);
}
.stat-card .value { font-size: 1.5rem; font-weight: 900; color: var(--accent); }
.stat-card .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Chart container */
.chart-container { position: relative; height: 300px; margin: 1rem 0; }

/* Date nav */
.date-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.date-nav input[type="date"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: #161616;
    color: var(--text);
}

/* Chat layout */
.chat-layout {
    display: flex;
    height: calc(100vh - 56px - 3rem);
    gap: 0;
    overflow: hidden;
}
.chat-sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 0.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    margin-bottom: 2px;
    transition: background 0.15s;
}
.conv-item:hover { background: #252525; }
.conv-item.active { background: rgba(230,57,70,0.15); font-weight: 600; color: var(--accent); }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-delete {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1rem; padding: 0 0.2rem; opacity: 0; transition: opacity 0.15s;
}
.conv-item:hover .conv-delete { opacity: 1; }
.chat-sidebar-toggle {
    display: none;
    background: var(--border);
    color: var(--text);
    padding: 0.5rem;
    font-size: 1rem;
    line-height: 1;
}
.chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius) 0 0;
}
.chat-message {
    margin-bottom: 0.4rem;
    max-width: 85%;
}
.chat-message.user {
    margin-left: auto;
    text-align: right;
}
.chat-message .bubble {
    display: inline-block;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    text-align: left;
    line-height: 1.35;
    font-size: 0.88rem;
}
.chat-message.user .bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-message.assistant .bubble {
    background: #252525;
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.chat-message .bubble p { margin-bottom: 0.2rem; }
.chat-message .bubble p:last-child { margin-bottom: 0; }
.chat-message .bubble ul, .chat-message .bubble ol { margin: 0.15rem 0 0.15rem 1.1rem; }
.chat-message .bubble li { margin-bottom: 0.05rem; }
.chat-message .bubble strong { font-weight: 600; }
.chat-message .bubble h3 { margin: 0.4rem 0 0.15rem; font-size: 0.95rem; }
.chat-message .bubble h4 { margin: 0.3rem 0 0.1rem; font-size: 0.9rem; }
.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: none;
    border-left: none;
    border-radius: 0 0 var(--radius) 0;
}
.chat-input-area textarea {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    min-height: 38px;
    max-height: 120px;
    background: #161616;
    color: var(--text);
}
.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.no-key-warning {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Training Plan */
.plan-week {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}
.plan-day {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.plan-day-today {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(230,57,70,0.2);
}
.plan-day-header {
    background: #252525;
    padding: 0.5rem 0.75rem;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.plan-day-today .plan-day-header {
    background: var(--accent);
    color: white;
}
.plan-day-body { padding: 0.5rem; }
.plan-exercise {
    padding: 0.4rem 0.25rem;
    border-bottom: 1px solid var(--border);
}
.plan-exercise:last-child { border-bottom: none; }
.plan-exercise-name { font-weight: 600; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; }
.what-is-this {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--accent);
    text-decoration: none;
    opacity: 0.7;
    white-space: nowrap;
}
.what-is-this:hover { opacity: 1; text-decoration: underline; }
.plan-exercise-detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.plan-exercise-notes { font-size: 0.75rem; color: var(--text-muted); font-style: italic; margin-top: 0.15rem; }

/* Tappable plan exercises */
.plan-exercise-tappable {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: 4px;
    padding: 0.5rem;
    margin: 0 -0.25rem;
    transition: background 0.15s, opacity 0.3s;
}
.plan-exercise-tappable:hover { background: rgba(255,255,255,0.04); }
.plan-exercise-tappable:active { background: rgba(45,106,79,0.15); }
.plan-exercise-tappable .plan-exercise-content { flex: 1; min-width: 0; }
.plan-exercise-check {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: transparent;
    flex-shrink: 0;
    margin-top: 1px;
    transition: all 0.2s;
}

/* Logging in progress */
.plan-exercise-tappable.logging .plan-exercise-check {
    border-color: var(--success);
    animation: pulse-check 0.6s ease infinite;
}
@keyframes pulse-check {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Done state */
.plan-exercise-tappable.done {
    cursor: pointer;
}
.plan-exercise-tappable.done .plan-exercise-check {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.plan-exercise-tappable.done .plan-exercise-name {
    text-decoration: line-through;
    opacity: 0.5;
}
.plan-exercise-tappable.done .plan-exercise-detail,
.plan-exercise-tappable.done .plan-exercise-notes {
    opacity: 0.4;
}
.plan-exercise-tappable.done:hover { background: transparent; }

/* Inline editable cells */
td.editable { cursor: pointer; transition: background 0.15s; }
td.editable:hover { background: rgba(255,255,255,0.05); }
.inline-edit {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #2a2a2a;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}
.inline-edit::-webkit-inner-spin-button,
.inline-edit::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.inline-edit[type="number"] { -moz-appearance: textbox; }
.inline-edit:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(230,57,70,0.15);
}
.plan-tag {
    display: inline-block;
    background: rgba(230,57,70,0.15);
    color: var(--accent);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 0.25rem;
}

/* Progress Photos */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}
.photo-card { position: relative; }
.photo-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.2s;
}
.photo-card img:hover { opacity: 0.85; }
.photo-info {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}
.photo-date { color: var(--text-muted); font-weight: 600; }
.photo-caption { color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

/* Copy date picker */
.copy-date-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
}
.copy-date-option:hover { background: #252525; }
.copy-date-option input[type="radio"] { accent-color: var(--accent); }
.copy-date-option span:first-of-type { flex: 1; font-weight: 500; }

/* Music results */
.music-results { display: flex; flex-direction: column; gap: 0.5rem; }
.music-result-card {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    align-items: center;
}
.music-result-card:hover { background: #252525; }
.music-result-card.active { border-color: var(--accent); background: rgba(230,57,70,0.1); }
.music-result-card img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.music-result-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.music-result-title { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-result-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.music-result-actions { display: flex; gap: 0.25rem; flex-shrink: 0; align-self: center; }
.music-nokey-icon {
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.music-result-card.active .music-nokey-icon { background: var(--primary-dark); }
.tracklist-playable:hover { background: rgba(255,255,255,0.05); border-radius: 4px; }
.tracklist-active { background: rgba(230,57,70,0.15); border-radius: 4px; }
.tracklist-active span:first-child { color: var(--accent) !important; }

/* Single Item Modal */
.single-item-modal {
    max-width: 500px;
    width: 95%;
}
.single-item-modal .form-group input,
.single-item-modal .form-group select {
    font-size: 1rem;
    padding: 0.6rem;
}
.single-item-macros {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.single-item-macros .form-group input {
    width: 100%;
}

@media (max-width: 768px) {
    .single-item-modal {
        max-width: none;
        width: 100%;
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
    }
    .single-item-modal form {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    .single-item-modal .form-group input,
    .single-item-modal .form-group select {
        font-size: 16px; /* prevents iOS zoom */
        padding: 0.7rem;
    }
    .single-item-macros {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }
    .single-item-macros .form-group label {
        font-size: 0.7rem;
    }
}

@media (max-width: 380px) {
    .single-item-macros {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Food Add Dropdown Menu */
.food-add-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 50;
    min-width: 200px;
    overflow: hidden;
}
.food-add-menu button {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text);
}
.food-add-menu button:hover { background: #252525; }
.food-add-menu button:not(:last-child) { border-bottom: 1px solid var(--border); }

/* Entry Action Dropdown */
.entry-actions { position: relative; display: inline-block; }
.entry-action-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 50;
    min-width: 120px;
    overflow: hidden;
}
.entry-action-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text);
}
.entry-action-menu button:hover { background: #252525; }
.entry-action-menu button:not(:last-child) { border-bottom: 1px solid var(--border); }

/* Print styles */
@media print {
    .navbar, .no-print, .date-nav, .chat-input-area { display: none !important; }
    body { background: white; color: #111; }
    .container { max-width: 100%; padding: 0; }
    .card { background: white; border: none; padding: 0.5rem 0; box-shadow: none; page-break-inside: avoid; }
    .plan-week { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.5rem; }
    .plan-day { border: 1px solid #ccc; }
    .plan-day-header { background: #eee !important; color: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .plan-day-today .plan-day-header { background: #ddd !important; font-weight: 900; }
    h1 { font-size: 1.2rem; margin-bottom: 0.5rem; }
}

/* Hamburger toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

/* Scrollable table wrapper */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Responsive */
@media (max-width: 768px) {
    /* Navbar: hamburger menu */
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0; right: 0;
        background: #0a0a0a;
        flex-direction: column;
        padding: 0.5rem;
        z-index: 150;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
        border-bottom: 2px solid var(--accent);
    }
    .nav-dd-menu {
        position: static;
        box-shadow: none;
        margin-top: 0;
        padding-left: 1rem;
        background: transparent;
        border: none;
    }
    .nav-dropdown.open > .nav-dd-menu { display: block; }
    .nav-links.open { display: flex; }
    .nav-links a {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
        border-radius: var(--radius);
    }

    /* Layout */
    .container { padding: 1rem; }
    h1 { font-size: 1.3rem; }

    /* Forms */
    .form-grid { grid-template-columns: 1fr; }
    .form-full, [style*="grid-column: span 2"] { grid-column: 1 / -1; }

    /* Stats */
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-card { padding: 0.75rem 0.5rem; }
    .stat-card .value { font-size: 1.2rem; }

    /* Tables */
    table { font-size: 0.8rem; }
    th, td { padding: 0.35rem 0.4rem; white-space: nowrap; }

    /* Cards */
    .card { padding: 1rem; margin-bottom: 1rem; }
    .card h2 { font-size: 1.1rem; }

    /* Buttons */
    .btn { padding: 0.45rem 0.75rem; font-size: 0.85rem; }
    .btn-sm { padding: 0.2rem 0.4rem; font-size: 0.75rem; }

    /* Training plan */
    .plan-week { grid-template-columns: 1fr; }

    /* Photo grid */
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }

    /* Chat */
    .chat-sidebar {
        position: fixed; left: -240px; top: 56px; bottom: 0; z-index: 150;
        border-radius: 0; transition: left 0.2s;
    }
    .chat-sidebar.open { left: 0; }
    .chat-sidebar-toggle { display: inline-flex; }
    .chat-messages { border-left: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
    .chat-input-area { border-left: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
    .chat-input-area textarea { min-height: 60px; max-height: 150px; font-size: 1rem; }

    /* Music */
    .music-result-card .music-result-actions { width: 100%; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 0.4rem; margin-top: 0.1rem; }
    .music-result-card img { width: 80px; height: 45px; }
    .music-result-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

    /* Settings API key rows */
    .card [style*="display: flex"][style*="gap"] { flex-wrap: wrap; }

    /* Chart */
    .chart-container { height: 220px; }

    /* Date nav */
    .date-nav { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .form-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .stat-card .value { font-size: 1rem; }
    .photo-grid { grid-template-columns: repeat(2, 1fr); }
    .music-result-card img { width: 60px; height: 34px; }
    .music-result-card .music-result-actions .btn { font-size: 0.7rem; padding: 0.2rem 0.4rem; }
}

/* Links */
a { color: var(--accent); }
a:hover { color: var(--primary-dark); }

/* Scrollbar styling for dark theme */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #444; }
