/* ═══════════════════════════════════════════════════════════════
   VIGALITY — Minimal Strength Log
   Design: Black/White, minimal, sharp cards
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg: #f5f5f5;
    --bg-alt: #ececec;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --border: #eaeaea;
    --border-strong: #d4d4d4;
    --border-dashed: #d4d4d4;

    --ink: #0a0a0a;
    --ink-2: #1a1a1a;
    --text: #0f0f0f;
    --text-sec: #6b6b6b;
    --text-mute: #9b9b9b;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
    --shadow-fab: 0 8px 24px rgba(0,0,0,0.15);

    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 22px;
    --radius-2xl: 28px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', monospace;

    --header-h: 76px;
    --footer-h: 72px;

    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.28); }

.screen { display: none; height: 100vh; width: 100vw; }
.screen.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════ */
.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(0,0,0,0.03), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(0,0,0,0.03), transparent 40%),
        var(--bg);
    padding: 24px;
    overflow-y: auto;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    padding: 36px;
    box-shadow: var(--shadow-md);
    animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.brand-icon-box {
    width: 44px;
    height: 44px;
    background: var(--ink);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.brand-icon-box.sm { width: 38px; height: 38px; border-radius: 10px; }
.brand-icon-box.lg { width: 52px; height: 52px; border-radius: 14px; }

.brand-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.brand-tag {
    font-size: 13px;
    color: var(--text-sec);
    margin-top: 1px;
    letter-spacing: -0.01em;
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 18px;
    animation: fade 0.4s ease;
}
.auth-form.active { display: flex; }

@keyframes fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.badge-pill {
    display: inline-block;
    padding: 5px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
    align-self: flex-start;
}

.badge-pill.sm { padding: 3px 10px; font-size: 11px; }
.badge-pill.center-badge { align-self: center; }

.auth-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.03em;
}

.auth-sub {
    font-size: 14px;
    color: var(--text-sec);
    line-height: 1.55;
    margin-top: -8px;
    margin-bottom: 4px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sec);
    letter-spacing: -0.005em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px; /* Prevents iOS zoom on focus */
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
    letter-spacing: -0.01em;
}

@media (min-width: 601px) {
    .field input,
    .field select,
    .field textarea { font-size: 14px; }
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--text-mute);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.field textarea { resize: vertical; min-height: 60px; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-dark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    background: var(--ink);
    color: #ffffff;
    border: 1px solid var(--ink);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: -0.01em;
    min-height: 44px;
}

.btn-dark:hover {
    background: #222;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.btn-dark:active { transform: translateY(0); }
.btn-dark:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-dark.full { width: 100%; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    min-height: 40px;
}

.btn-outline:hover {
    background: var(--surface-2);
    border-color: var(--ink);
}

.btn-add-square {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--ink);
    color: #ffffff;
    border: 1px solid var(--ink);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-add-square:hover {
    background: #222;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

.btn-add-square.sm { width: 34px; height: 34px; border-radius: 9px; }

.btn-icon-plain {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-sec);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-icon-plain:hover {
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--border-strong);
}

.btn-icon-xs {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.08);
    color: var(--ink);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-xs:hover { background: rgba(0,0,0,0.15); }

.switch-line {
    text-align: center;
    color: var(--text-sec);
    font-size: 13px;
    margin-top: 4px;
}

.switch-line a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid var(--border-strong);
    padding-bottom: 1px;
    transition: var(--transition);
}
.switch-line a:hover { border-color: var(--ink); }

/* ─── Code Input ────────────────────────────────────────────── */
.code-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 6px 0;
}

.code-input {
    width: 46px;
    height: 54px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    font-family: var(--mono);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink);
    outline: none;
    transition: var(--transition);
}

.code-input:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

/* ─── Toast ─────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 40px);
    text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: var(--ink); }
.app-toast { z-index: 10001; }

/* ═══════════════════════════════════════════════════════════════
   APP HEADER
   ═══════════════════════════════════════════════════════════════ */
.app-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 50;
}

.app-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-brand .brand-name { font-size: 17px; }
.header-brand .brand-tag { font-size: 12.5px; }

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-btn {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-sec);
    font-size: 13.5px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: -0.01em;
    min-height: 40px;
}

.nav-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.nav-btn.active {
    background: var(--ink);
    color: #fff;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
    position: relative;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-sec);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu-btn:hover { background: var(--surface-2); color: var(--ink); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    min-width: 220px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: var(--transition);
    z-index: 100;
}

.user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-email {
    padding: 8px 12px 12px;
    font-size: 12px;
    color: var(--text-mute);
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    word-break: break-all;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    min-height: 40px;
}

.dropdown-item:hover { background: var(--surface-2); color: var(--ink); }

/* ═══════════════════════════════════════════════════════════════
   MAIN
   ═══════════════════════════════════════════════════════════════ */
#main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
    -webkit-overflow-scrolling: touch;
}

.view {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 32px 60px;
    animation: viewIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.view.active { display: block; }

@keyframes viewIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-bottom: 40px;
}

.hero-title {
    font-size: 44px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.035em;
    line-height: 1.1;
}

.hero-sub {
    font-size: 15px;
    color: var(--text-sec);
    max-width: 620px;
    line-height: 1.55;
}

/* ─── Panel Card ────────────────────────────────────────────── */
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-xs);
    margin-bottom: 20px;
    transition: var(--transition);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.panel-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
}

/* ─── Stats Row ─────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--ink);
    transition: var(--transition);
    min-width: 0;
}

.stat-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat-icon-box {
    width: 42px;
    height: 42px;
    background: var(--ink);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
}

.stat-label {
    font-size: 12px;
    color: var(--text-sec);
    font-weight: 500;
    letter-spacing: -0.005em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value em {
    font-style: normal;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sec);
    margin-left: 2px;
}

/* ─── Quick Row (Search + Add) ──────────────────────────────── */
.quick-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.search-input-wrapper,
.add-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 14px;
    transition: var(--transition);
}

.search-input-wrapper:focus-within {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

.search-input-wrapper svg { color: var(--text-mute); flex-shrink: 0; }

.search-input-wrapper input {
    flex: 1;
    padding: 12px 0;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font);
    font-size: 16px;
    color: var(--text);
    letter-spacing: -0.01em;
    min-width: 0;
}

@media (min-width: 601px) {
    .search-input-wrapper input { font-size: 14px; }
}

.search-input-wrapper input::placeholder { color: var(--text-mute); }

.add-input-wrapper input {
    flex: 1;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 16px;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    letter-spacing: -0.01em;
    min-width: 0;
}

@media (min-width: 601px) {
    .add-input-wrapper input { font-size: 14px; }
}

.add-input-wrapper input:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

.add-input-wrapper input::placeholder { color: var(--text-mute); }

/* ─── Dashboard Exercises ───────────────────────────────────── */
.dashboard-exercises {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    min-height: 200px;
}

.exercise-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: var(--transition);
    animation: cardIn 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exercise-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.exercise-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.exercise-card-head h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.3;
    word-break: break-word;
    min-width: 0;
    flex: 1;
}

.exercise-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.exercise-actions button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    color: var(--text-mute);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.exercise-actions button:hover { background: var(--bg-alt); color: var(--ink); }
.exercise-actions .delete-btn:hover { background: rgba(220,38,38,0.08); color: #dc2626; }

.muscle-tag {
    display: inline-block;
    align-self: flex-start;
    padding: 3px 10px;
    background: var(--bg-alt);
    color: var(--ink);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.005em;
}

/* ─── Empty Box (Dashed) ────────────────────────────────────── */
.empty-box {
    grid-column: 1 / -1;
    border: 1.5px dashed var(--border-dashed);
    border-radius: var(--radius-lg);
    padding: 44px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    background: transparent;
}

.empty-plus {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sec);
    margin-bottom: 4px;
    box-shadow: var(--shadow-xs);
}

.empty-box h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.empty-box p {
    font-size: 13px;
    color: var(--text-mute);
    max-width: 380px;
    line-height: 1.5;
}

/* ─── Form Grid ─────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 14px;
    margin-bottom: 16px;
}

/* ─── Sets Block ────────────────────────────────────────────── */
.sets-block {
    margin-top: 20px;
    margin-bottom: 20px;
}

.sets-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sets-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sec);
}

#sets-container,
#edit-sets-container,
#ll-sets {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.set-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
    animation: cardIn 0.2s ease;
}

.set-num {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--ink);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--mono);
    flex-shrink: 0;
}

.set-row input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 16px;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    letter-spacing: -0.01em;
}

@media (min-width: 601px) {
    .set-row input { font-size: 13px; }
}

.set-row input:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}

.set-row input[type="number"] { max-width: 110px; }
.set-row input.notes-inp { flex: 2; max-width: none; }

.set-row-remove {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border: none;
    border-radius: 7px;
    background: rgba(220,38,38,0.08);
    color: #dc2626;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
}

.set-row-remove:hover { background: rgba(220,38,38,0.15); }

/* ─── History ───────────────────────────────────────────────── */
.history-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.history-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    animation: cardIn 0.3s ease;
}

.history-day-head {
    padding: 12px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-day-head h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.history-day-head .day-count {
    font-size: 11px;
    color: var(--text-mute);
    font-weight: 500;
}

.history-entry {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.history-entry:last-child { border-bottom: none; }
.history-entry:hover { background: var(--surface-2); }

.entry-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
    flex-wrap: wrap;
}

.entry-head h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
    flex-wrap: wrap;
}

.entry-actions { display: flex; gap: 4px; }

.entry-actions button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    color: var(--text-mute);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.entry-actions button:hover { background: var(--bg-alt); color: var(--ink); }

.sets-table {
    width: 100%;
    font-size: 13px;
    color: var(--text-sec);
    border-collapse: collapse;
}

.sets-table td { padding: 3px 0; }
.sets-table td:first-child { width: 80px; font-family: var(--mono); font-weight: 600; color: var(--ink); font-size: 12px; }

.entry-notes {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-mute);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── Charts ────────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}

.chart-wrap {
    position: relative;
    height: 260px;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */
.app-footer {
    height: var(--footer-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    gap: 16px;
    position: relative;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.footer-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.footer-tag {
    font-size: 11px;
    color: var(--text-sec);
    line-height: 1.3;
}

.footer-email {
    font-size: 11px;
    color: var(--text-mute);
    line-height: 1.3;
    word-break: break-all;
}

.footer-right { display: flex; align-items: center; gap: 20px; }

.footer-link {
    color: var(--text-sec);
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.footer-link:hover { color: var(--ink); }

.footer-right .footer-link + .footer-link {
    position: relative;
    padding-left: 20px;
}

.footer-right .footer-link + .footer-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 3px;
    background: var(--border-strong);
    border-radius: 50%;
}

/* ─── Connection Toast (in footer center) ───────────────────── */
.conn-toast {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 20px;
    background: var(--ink);
    color: #fff;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    opacity: 1;
    transition: var(--transition);
    max-width: calc(100vw - 40px);
    z-index: 10;
}

.conn-toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, calc(-50% + 8px));
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239,68,68,0.6);
    animation: pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.conn-dot.green {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════════════════════
   FLOATING CHAT
   ═══════════════════════════════════════════════════════════════ */
.chat-fab {
    position: fixed;
    bottom: calc(var(--footer-h) + 20px);
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-fab);
    transition: var(--transition);
    z-index: 90;
}

.chat-fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}

.chat-modal {
    position: fixed;
    bottom: calc(var(--footer-h) + 20px);
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 620px;
    max-height: calc(100vh - var(--footer-h) - var(--header-h) - 40px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.96);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-modal-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-modal-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-modal-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.chat-status {
    font-size: 11px;
    color: #16a34a;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.chat-modal-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-modal-actions select {
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 12px;
    color: var(--text);
    outline: none;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.chat-welcome {
    text-align: center;
    padding: 30px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.chat-welcome h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    margin-top: 8px;
    letter-spacing: -0.01em;
}

.chat-welcome p {
    font-size: 13px;
    color: var(--text-mute);
    max-width: 300px;
    line-height: 1.5;
}

.bubble {
    max-width: 82%;
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    border-radius: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: bubbleIn 0.25s ease;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.bubble.user {
    align-self: flex-end;
    background: var(--ink);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bubble.ai {
    align-self: flex-start;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.bubble.ai pre {
    background: var(--ink);
    color: #e5e5e5;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: var(--mono);
    font-size: 12px;
}

.bubble.ai code {
    font-family: var(--mono);
    font-size: 12px;
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
}

.bubble.ai pre code { background: none; padding: 0; }

.bubble.ai table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-mute);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.image-preview-bar { padding: 8px 16px; }
.image-preview-bar.hidden { display: none; }

.image-preview-content {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.image-preview-content img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.btn-icon-plain.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.btn-icon-plain.recording { background: rgba(220,38,38,0.1); color: #dc2626; border-color: rgba(220,38,38,0.3); animation: recPulse 1.5s ease-in-out infinite; }

@keyframes recPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

#chat-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font);
    font-size: 16px;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    letter-spacing: -0.01em;
}

@media (min-width: 601px) {
    #chat-input { font-size: 13.5px; }
}

#chat-input:focus { border-color: var(--ink); background: var(--surface); }

.btn-send-dark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send-dark:hover { background: #222; transform: scale(1.05); }

/* ═══════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    animation: fade 0.2s ease;
    padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-overflow-scrolling: touch;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 5;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.modal-body { padding: 20px 22px 22px; }
.modal-body .field { margin-bottom: 14px; }
.modal-body .btn-dark { width: 100%; margin-top: 6px; }

.multi-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
    animation: cardIn 0.2s ease;
}

.multi-row input {
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

.multi-row input:focus { border-color: var(--ink); }

.add-row-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1.5px dashed var(--border-dashed);
    border-radius: var(--radius-sm);
    color: var(--text-sec);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin: 6px 0 12px;
    font-family: var(--font);
}

.add-row-btn:hover {
    border-color: var(--ink);
    color: var(--ink);
    background: var(--surface-2);
}

/* ─── Spinner ───────────────────────────────────────────────── */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════ EXERCISE CARD BUTTONS ═══════════ */
.exercise-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.exercise-btns .btn-dark.sm,
.exercise-btns .btn-outline.sm {
    padding: 9px 14px;
    font-size: 12px;
    border-radius: 8px;
    min-height: 38px;
    width: 100%;
    flex: none;
}

/* ═══════════ BRAND LOGO IMAGE ═══════════ */
.brand-logo-img {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.brand-logo-img.sm { width: 38px; height: 38px; border-radius: 10px; }
.brand-logo-img.xs { width: 34px; height: 34px; border-radius: 9px; }

/* ═══════════ USER AVATAR IMG ═══════════ */
.user-avatar-img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

/* ═══════════ FOOTER SOCIALS ═══════════ */
.footer-socials {
    display: flex;
    align-items: center;
    gap: 8px;
}

.social-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-sec);
    text-decoration: none;
    transition: var(--transition);
    background: var(--surface);
}

.social-btn:hover {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.social-btn svg {
    display: block;
    pointer-events: none;
}

/* ═══════════ DROPDOWN DIVIDER ═══════════ */
.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.dropdown-item.danger { color: #dc2626; }
.dropdown-item.danger:hover { background: rgba(220,38,38,0.06); }

/* ═══════════ HIDDEN UTIL ═══════════ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (< 900px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    :root { --header-h: 64px; --footer-h: 64px; }

    .app-header-inner { padding: 0 16px; gap: 10px; }
    .header-brand .brand-tag { display: none; }
    .header-brand .brand-name { font-size: 15px; }
    .brand-logo-img.sm { width: 34px; height: 34px; }
    .header-nav { gap: 2px; }
    .nav-btn { padding: 8px 10px; font-size: 12.5px; }
    .header-user { margin-left: 6px; padding-left: 10px; }

    .view { padding: 20px 14px 30px; }
    .view-hero { margin-bottom: 24px; gap: 10px; }
    .hero-title { font-size: 28px; }
    .hero-sub { font-size: 13px; }

    .panel-card { padding: 18px 16px; border-radius: 18px; }
    .panel-header { margin-bottom: 14px; }
    .panel-title { font-size: 15px; }

    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-item { padding: 12px; gap: 10px; }
    .stat-icon-box { width: 36px; height: 36px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 11px; }

    .form-grid { grid-template-columns: 1fr; }
    .quick-row { grid-template-columns: 1fr; gap: 10px; }
    .charts-grid { grid-template-columns: 1fr; }

    .dashboard-exercises { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

    .app-footer { padding: 0 14px; gap: 10px; }
    .footer-tag, .footer-email { display: none; }
    .footer-name { font-size: 13px; }
    .footer-right { gap: 12px; }
    .footer-right .footer-link + .footer-link { padding-left: 12px; }
    .footer-link { font-size: 12px; }
    .footer-socials { gap: 6px; }
    .social-btn { width: 32px; height: 32px; }
    .conn-toast { font-size: 11px; padding: 8px 14px; }

    .chat-modal {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: calc(var(--footer-h) + 10px);
        max-height: calc(100vh - var(--footer-h) - var(--header-h) - 20px);
        border-radius: 16px;
    }
    .chat-fab { right: 14px; bottom: calc(var(--footer-h) + 14px); }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (< 600px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .app-header-inner { padding: 0 12px; gap: 8px; }
    .header-brand { gap: 8px; }
    .header-brand .brand-name { font-size: 14px; }
    .brand-logo-img.sm { width: 32px; height: 32px; border-radius: 8px; }
    .header-nav .nav-btn { padding: 6px 8px; font-size: 12px; }
    .nav-btn { display: none; }
    .nav-btn.active { display: inline-flex; align-items: center; }
    .header-user { margin-left: 4px; padding-left: 8px; }
    .user-avatar-img { width: 30px; height: 30px; }

    .user-dropdown { min-width: 200px; right: -8px; }
    .user-dropdown-email { font-size: 11px; }

    .view { padding: 16px 10px 24px; }
    .view-hero { margin-bottom: 20px; gap: 8px; }
    .hero-title { font-size: 24px; line-height: 1.15; }
    .hero-sub { font-size: 12.5px; padding: 0 4px; }
    .badge-pill { font-size: 11px; padding: 4px 12px; }

    .panel-card { padding: 14px 12px; border-radius: 14px; margin-bottom: 14px; }
    .panel-header { margin-bottom: 12px; }
    .panel-title { font-size: 14px; }

    /* Stats: 2x2 grid statt 4 nebeneinander */
    .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
    .stat-item { padding: 10px; gap: 8px; border-radius: 12px; }
    .stat-icon-box { width: 32px; height: 32px; border-radius: 8px; }
    .stat-icon-box svg { width: 14px; height: 14px; }
    .stat-label { font-size: 10.5px; }
    .stat-value { font-size: 16px; }
    .stat-value em { font-size: 10px; }

    /* Search + Add nebeneinander gestapelt */
    .quick-row { gap: 8px; }
    .search-input-wrapper, .add-input-wrapper { padding: 0 10px; }
    .search-input-wrapper input, .add-input-wrapper input { padding: 11px 0; }
    .add-input-wrapper input { padding: 11px 12px; }
    .btn-add-square { width: 40px; height: 40px; border-radius: 10px; }

    /* Exercise Cards: 1 pro Zeile */
    .dashboard-exercises { grid-template-columns: 1fr; gap: 10px; }
    .exercise-card { padding: 14px; }
    .exercise-card-head h4 { font-size: 14px; }
    .exercise-btns { gap: 6px; flex-direction: column; }
    .exercise-btns .btn-dark.sm, .exercise-btns .btn-outline.sm {
        padding: 10px 12px; font-size: 12px; width: 100%;
    }

    .empty-box { padding: 32px 16px; }
    .empty-box h3 { font-size: 14px; }
    .empty-box p { font-size: 12px; }
    .empty-plus { width: 40px; height: 40px; }

    /* Set Row: kompakter */
    .set-row { padding: 8px 10px; gap: 6px; }
    .set-num { width: 24px; height: 24px; min-width: 24px; font-size: 10px; }
    .set-row input { padding: 7px 8px; }
    .set-row input[type="number"] { max-width: 80px; }
    .set-row-remove { width: 28px; height: 28px; min-width: 28px; }

    /* Modal: Fullscreen-ähnlich */
    .modal-overlay { padding: 0; }
    .modal {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
    .modal-header { padding: 14px 16px; }
    .modal-header h3 { font-size: 15px; }
    .modal-body { padding: 16px 16px 24px; }

    /* Chat: Fullscreen auf Mobile */
    .chat-modal {
        width: 100vw;
        max-width: 100vw;
        right: 0;
        left: 0;
        bottom: 0;
        top: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    .chat-modal-header { padding: 14px 16px; }
    .chat-modal-header h3 { font-size: 14px; }
    .chat-modal-actions select { font-size: 11px; padding: 5px 8px; }
    .chat-messages { padding: 12px; gap: 10px; }
    .bubble { max-width: 88%; font-size: 13px; padding: 9px 12px; }
    .chat-input-row { padding: 10px 12px; gap: 5px; }
    .btn-icon-plain { width: 38px; height: 38px; }
    .btn-send-dark { width: 42px; height: 42px; }

    .chat-fab {
        width: 52px; height: 52px;
        right: 12px;
        bottom: calc(var(--footer-h) + 12px);
    }

    /* Footer: kompakter */
    .app-footer { padding: 0 10px; gap: 8px; }
    .footer-brand .brand-logo-img { width: 28px; height: 28px; border-radius: 7px; }
    .footer-name { font-size: 12px; }
    .footer-socials { gap: 4px; }
    .social-btn { width: 30px; height: 30px; }
    .social-btn svg { width: 12px !important; height: 12px !important; }
    .footer-link { font-size: 11px; }
    .footer-right { gap: 8px; }
    .footer-right .footer-link + .footer-link { padding-left: 10px; }

    /* Code Input */
    .code-input { width: 40px; height: 48px; font-size: 20px; }
    .code-inputs { gap: 6px; }

    /* Auth Card */
    .auth-wrapper { padding: 12px; }
    .auth-card { padding: 24px 20px; border-radius: 20px; }
    .auth-title { font-size: 22px; }
    .auth-sub { font-size: 13px; }

    /* Toast */
    .toast { font-size: 12.5px; padding: 10px 18px; bottom: 20px; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (< 380px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    .hero-title { font-size: 20px; }
    .stats-row { grid-template-columns: 1fr; }
    .stat-value { font-size: 18px; }
    .header-brand .brand-name { display: none; }
    .footer-right { gap: 6px; }
    .footer-right .footer-link + .footer-link { padding-left: 8px; }
    .footer-link { font-size: 10.5px; }
}

/* ═══════════════════════════════════════════════════════════════
   LANDSCAPE MOBILE (kurze Höhe)
   ═══════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .auth-wrapper { padding: 10px; }
    .auth-card { padding: 20px; }
    .auth-brand { margin-bottom: 16px; padding-bottom: 16px; }
    .code-input { height: 42px; font-size: 18px; }

    .chat-modal { top: 0; height: 100vh; max-height: 100vh; }
}

/* ═══════════════════════════════════════════════════════════════
   TOUCH DEVICES: Hover-Effekte deaktivieren
   ═══════════════════════════════════════════════════════════════ */
@media (hover: none) {
    .btn-dark:hover,
    .btn-outline:hover,
    .btn-add-square:hover,
    .exercise-card:hover,
    .stat-item:hover,
    .chat-fab:hover,
    .social-btn:hover {
        transform: none;
        box-shadow: inherit;
    }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT (nice-to-have)
   ═══════════════════════════════════════════════════════════════ */
@media print {
    .app-header, .app-footer, .chat-fab, .chat-modal { display: none !important; }
    body { background: white; }
    .panel-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* ═══════════════════════════════════════════════════════════════
   OFFLINE / SYNC UI
   ═══════════════════════════════════════════════════════════════ */

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--ink);
    color: #fff;
    padding: 8px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.offline-banner.hidden {
    display: none;
}

.offline-banner.offline {
    background: linear-gradient(90deg, #dc2626, #b91c1c);
}

.offline-banner.syncing {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.offline-banner-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 600;
    flex-wrap: wrap;
}

.offline-icon {
    display: inline-flex;
    align-items: center;
}

.offline-icon svg {
    display: block;
}

.offline-text {
    letter-spacing: -0.01em;
}

.offline-sync {
    font-size: 11px;
    padding: 2px 10px;
    background: rgba(255,255,255,0.18);
    border-radius: 999px;
    font-weight: 500;
    letter-spacing: -0.005em;
}

.offline-sync:empty {
    display: none;
}

.offline-sync-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
}

.offline-sync-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(180deg);
}

.offline-sync-btn.hidden {
    display: none !important;
}

/* Wenn Banner sichtbar: main-content Padding anpassen */
body:has(.offline-banner:not(.hidden)) .app-header {
    margin-top: 40px;
}

/* Fallback für Browser ohne :has() */
.offline-banner:not(.hidden) ~ #app-screen .app-header,
.offline-banner:not(.hidden) + #app-screen .app-header {
    margin-top: 40px;
}

/* ─── Sync Badge auf Exercise Cards ────────────────────────── */
.sync-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    animation: syncSpin 2s linear infinite;
}

.sync-badge svg {
    display: block;
}

@keyframes syncSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT OFFLINE LOCK
   ═══════════════════════════════════════════════════════════════ */

.chat-offline-lock {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border-radius: inherit;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-lock-inner {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 320px;
}

.chat-lock-icon {
    width: 72px;
    height: 72px;
    background: var(--ink);
    color: #fff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    margin-bottom: 4px;
}

.chat-lock-inner h3 {
    font-size: 17px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.chat-lock-inner p {
    font-size: 13px;
    color: var(--text-sec);
    line-height: 1.55;
    letter-spacing: -0.01em;
}

/* Mobile: Chat Lock */
@media (max-width: 600px) {
    .chat-lock-icon {
        width: 64px;
        height: 64px;
        border-radius: 18px;
    }
    .chat-lock-icon svg {
        width: 36px;
        height: 36px;
    }
    .chat-lock-inner h3 {
        font-size: 16px;
    }
    .chat-lock-inner p {
        font-size: 12.5px;
    }
}

/* Wenn Offline-Banner aktiv, Header nach unten schieben */
.offline-banner:not(.hidden) {
    position: sticky;
    top: 0;
}

body {
    display: flex;
    flex-direction: column;
}

.offline-banner:not(.hidden) ~ .screen {
    height: calc(100vh - 40px);
}

/* Mobile Offline-Banner kompakter */
@media (max-width: 600px) {
    .offline-banner {
        padding: 6px 12px;
    }
    .offline-banner-inner {
        font-size: 12px;
        gap: 8px;
    }
    .offline-sync {
        font-size: 10px;
        padding: 2px 8px;
    }
    .offline-sync-btn {
        width: 24px;
        height: 24px;
    }
}

/* ═══ Chat Offline Lock - Close Button ═══ */
.chat-lock-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.chat-lock-close:hover {
    background: rgba(0, 0, 0, 0.15);
    transform: rotate(90deg);
    border-color: rgba(0, 0, 0, 0.2);
}

.chat-lock-close svg {
    display: block;
}

.chat-lock-back {
    margin-top: 12px;
    padding: 10px 18px;
    font-size: 13px;
}

.chat-lock-back svg {
    flex-shrink: 0;
}

/* Mobile */
@media (max-width: 600px) {
    .chat-lock-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
    }
    .chat-lock-back {
        font-size: 12.5px;
        padding: 9px 14px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   THEME SYSTEM
   ═══════════════════════════════════════════════════════════════ */
body.theme-dark {
    --bg: #1a1a1a;
    --bg-alt: #202020;
    --surface: #262626;
    --surface-2: #2d2d2d;
    --border: #3a3a3a;
    --border-strong: #4a4a4a;
    --border-dashed: #4a4a4a;
    --ink: #f5f5f5;
    --ink-2: #e5e5e5;
    --text: #f0f0f0;
    --text-sec: #a3a3a3;
    --text-mute: #7c7c7c;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.18);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.22), 0 1px 2px rgba(0,0,0,0.16);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-lg: 0 18px 42px rgba(0,0,0,0.34);
    --shadow-fab: 0 12px 30px rgba(0,0,0,0.36);
}

body.theme-dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
body.theme-dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ═══════════════════════════════════════════════════════════════
   UPGRADE BUTTON
   ═══════════════════════════════════════════════════════════════ */
.nav-upgrade {
    background: linear-gradient(135deg, #0a0a0a 0%, #3a3a3a 45%, #9f9f9f 100%);
    color: #fff;
    border: 1px solid rgba(10,10,10,0.16);
    box-shadow: 0 10px 22px rgba(0,0,0,0.12);
    position: relative;
    overflow: hidden;
}
.nav-upgrade::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
    transform: translateX(-130%);
    transition: transform 0.6s ease;
}
.nav-upgrade:hover::before { transform: translateX(130%); }
.nav-upgrade:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.16);
}
.nav-upgrade.is-pro {
    background: linear-gradient(135deg, #111 0%, #1f5139 55%, #22c55e 100%);
}

@media (max-width: 600px) {
    .nav-upgrade {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 11.5px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT USAGE BADGE
   ═══════════════════════════════════════════════════════════════ */
.chat-head-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.chat-usage-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-sec);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.chat-usage-badge.pro {
    background: rgba(34,197,94,0.12);
    border-color: rgba(34,197,94,0.2);
    color: #15803d;
}
.chat-usage-badge.hidden { display: none; }

/* ═══════════════════════════════════════════════════════════════
   UPGRADE MODAL
   ═══════════════════════════════════════════════════════════════ */
.upgrade-lock {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.upgrade-lock-visual {
    width: 82px;
    height: 82px;
    border-radius: 24px;
    background: linear-gradient(145deg, #0a0a0a 0%, #404040 55%, #9a9a9a 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 16px 34px rgba(0,0,0,0.18);
}
.upgrade-lock h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.03em;
}
.upgrade-lock p {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-sec);
    max-width: 420px;
}
.upgrade-lock .hint {
    font-size: 12px;
    color: var(--text-mute);
}
.upgrade-lock .actions {
    width: 100%;
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.upgrade-lock .actions .btn-dark,
.upgrade-lock .actions .btn-outline {
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════════
   AMBIENT BACKGROUND
   ═══════════════════════════════════════════════════════════════ */
.auth-wrapper,
#view-dashboard {
    position: relative;
    overflow: hidden;
}

.auth-wrapper > .ambient-scene,
#view-dashboard > .ambient-scene {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.auth-card,
#view-dashboard > *:not(.ambient-scene) {
    position: relative;
    z-index: 1;
}

.ambient-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(10,10,10,0.12) 1px, transparent 1.6px);
    background-size: 30px 30px;
    opacity: 0.18;
}

body.theme-dark .ambient-dots {
    background-image: radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1.6px);
    opacity: 0.16;
}

/* Logo-Watermark komplett entfernt — nur die schwebende Hantel bleibt */
.ambient-watermark { display: none !important; }

.ambient-dumbbell {
    position: absolute;
    right: 7%;
    top: 14%;
    width: 260px;
    height: 120px;
    opacity: 0.88;
    animation: dumbbellFloat 4s ease-in-out infinite;
    transform-style: preserve-3d;
    filter: drop-shadow(0 16px 20px rgba(0,0,0,0.12));
}
.dashboard-float { top: 12%; right: 4%; }

.ambient-dumbbell .handle {
    position: absolute;
    left: 58px;
    right: 58px;
    top: 49px;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(180deg, #dedede 0%, #a8a8a8 48%, #7c7c7c 100%);
    transform: skewX(-18deg);
    box-shadow: inset 0 2px 2px rgba(255,255,255,0.45), inset 0 -2px 4px rgba(0,0,0,0.16);
}
body.theme-dark .ambient-dumbbell .handle {
    background: linear-gradient(180deg, #bdbdbd 0%, #8b8b8b 50%, #5f5f5f 100%);
}

.ambient-dumbbell .plate {
    position: absolute;
    top: 28px;
    border-radius: 12px;
    background: linear-gradient(145deg, #121212 0%, #404040 50%, #6c6c6c 100%);
    box-shadow: inset 0 2px 3px rgba(255,255,255,0.08), inset 0 -6px 10px rgba(0,0,0,0.28);
}
body.theme-dark .ambient-dumbbell .plate {
    background: linear-gradient(145deg, #f0f0f0 0%, #bdbdbd 48%, #707070 100%);
    box-shadow: inset 0 2px 3px rgba(255,255,255,0.25), inset 0 -6px 10px rgba(0,0,0,0.18);
}

.plate-a { left: 14px; width: 18px; height: 48px; top: 34px; }
.plate-b { left: 32px; width: 24px; height: 56px; top: 30px; }
.plate-c { left: 56px; width: 18px; height: 64px; top: 26px; }

.plate-d { right: 56px; width: 18px; height: 64px; top: 26px; }
.plate-e { right: 32px; width: 24px; height: 56px; top: 30px; }
.plate-f { right: 14px; width: 18px; height: 48px; top: 34px; }

.ambient-dumbbell .shadow {
    position: absolute;
    left: 42px;
    right: 42px;
    bottom: -4px;
    height: 20px;
    border-radius: 999px;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.06) 55%, transparent 100%);
    filter: blur(2px);
}

@keyframes dumbbellFloat {
    0%, 100% { transform: translateY(0px) rotate(-8deg); }
    50% { transform: translateY(14px) rotate(-6deg); }
}

@media (max-width: 900px) {
    .ambient-dumbbell {
        width: 190px;
        height: 92px;
        right: -10px;
        top: 12%;
        opacity: 0.65;
    }
}

@media (max-width: 600px) {
    .ambient-dumbbell {
        width: 150px;
        height: 72px;
        top: 10%;
        right: -16px;
        opacity: 0.5;
    }
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE DETAIL FIXES
   ═══════════════════════════════════════════════════════════════ */
body.theme-dark .bubble.user { color: #111; background: #f5f5f5; }
body.theme-dark .chat-status { color: #86efac; }
body.theme-dark .conn-dot.green {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74,222,128,0.45);
}
body.theme-dark .social-btn:hover {
    background: #f5f5f5;
    color: #111;
    border-color: #f5f5f5;
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE — CONTRAST FIXES FÜR SCHWARZE FLÄCHEN
   ═══════════════════════════════════════════════════════════════ */

/* Icon-Boxen die im Light Mode schwarz sind → im Dark Mode helles Grau */
body.theme-dark .brand-icon-box,
body.theme-dark .stat-icon-box,
body.theme-dark .set-num,
body.theme-dark .user-avatar {
    background: #f5f5f5;
    color: #0a0a0a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Buttons die schwarzen Hintergrund haben */
body.theme-dark .btn-dark,
body.theme-dark .btn-add-square,
body.theme-dark .btn-send-dark,
body.theme-dark .chat-fab {
    background: #f5f5f5;
    color: #0a0a0a;
    border-color: #f5f5f5;
}

body.theme-dark .btn-dark:hover,
body.theme-dark .btn-add-square:hover,
body.theme-dark .btn-send-dark:hover,
body.theme-dark .chat-fab:hover {
    background: #e5e5e5;
    color: #0a0a0a;
}

/* Nav-Button aktiv */
body.theme-dark .nav-btn.active {
    background: #f5f5f5;
    color: #0a0a0a;
}

/* Upgrade-Button behält Gradient, aber wird angepasst */
body.theme-dark .nav-upgrade {
    background: linear-gradient(135deg, #f5f5f5 0%, #b8b8b8 45%, #6a6a6a 100%);
    color: #0a0a0a;
    border: 1px solid rgba(255,255,255,0.16);
}
body.theme-dark .nav-upgrade:hover {
    color: #0a0a0a;
}
body.theme-dark .nav-upgrade.is-pro {
    background: linear-gradient(135deg, #f5f5f5 0%, #4ade80 55%, #22c55e 100%);
    color: #0a0a0a;
}

/* Muscle-Tag lesbar machen */
body.theme-dark .muscle-tag {
    background: #3a3a3a;
    color: #f5f5f5;
}

/* Badge-Pills lesbar */
body.theme-dark .badge-pill {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border);
}

/* Chat User-Bubble */
body.theme-dark .bubble.user {
    background: #f5f5f5;
    color: #0a0a0a;
}

/* Chat AI-Bubble */
body.theme-dark .bubble.ai {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

/* Chat pre/code im Dark Mode */
body.theme-dark .bubble.ai pre {
    background: #0f0f0f;
    color: #e5e5e5;
    border: 1px solid #3a3a3a;
}

/* Set-Row-Remove Button lesbar */
body.theme-dark .set-row-remove {
    background: rgba(220,38,38,0.18);
    color: #f87171;
}
body.theme-dark .set-row-remove:hover {
    background: rgba(220,38,38,0.3);
}

/* Toast im Dark Mode */
body.theme-dark .toast {
    background: #f5f5f5;
    color: #0a0a0a;
}
body.theme-dark .toast.success { background: #22c55e; color: #052e0f; }
body.theme-dark .toast.error { background: #ef4444; color: #2c0505; }

/* Empty-Box Plus-Icon */
body.theme-dark .empty-plus {
    background: var(--surface-2);
    color: var(--text-sec);
    border-color: var(--border);
}

/* Modal-Header sticky Background */
body.theme-dark .modal-header,
body.theme-dark .chat-modal-header,
body.theme-dark .chat-input-row {
    background: var(--surface);
}

/* Chat Input Field */
body.theme-dark #chat-input {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
body.theme-dark #chat-input:focus {
    border-color: #f5f5f5;
    background: var(--surface);
}

/* Chat Model-Select */
body.theme-dark .chat-modal-actions select {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

/* Icon-Plain Buttons */
body.theme-dark .btn-icon-plain {
    background: transparent;
    border-color: var(--border);
    color: var(--text-sec);
}
body.theme-dark .btn-icon-plain:hover {
    background: var(--surface-2);
    color: var(--ink);
    border-color: var(--border-strong);
}

/* Btn-Outline */
body.theme-dark .btn-outline {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border-strong);
}
body.theme-dark .btn-outline:hover {
    background: var(--surface-2);
    border-color: #f5f5f5;
}

/* Search + Add Input Wrappers */
body.theme-dark .search-input-wrapper,
body.theme-dark .add-input-wrapper input,
body.theme-dark .set-row input,
body.theme-dark .field input,
body.theme-dark .field select,
body.theme-dark .field textarea,
body.theme-dark .code-input {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

body.theme-dark .search-input-wrapper:focus-within,
body.theme-dark .add-input-wrapper input:focus,
body.theme-dark .set-row input:focus,
body.theme-dark .field input:focus,
body.theme-dark .field select:focus,
body.theme-dark .field textarea:focus,
body.theme-dark .code-input:focus {
    border-color: #f5f5f5;
}

/* Set-Row Background */
body.theme-dark .set-row {
    background: var(--surface-2);
    border-color: var(--border);
}

/* History-Day Head */
body.theme-dark .history-day-head {
    background: var(--surface-2);
}

/* Sets-Table td:first-child */
body.theme-dark .sets-table td:first-child {
    color: var(--ink);
}

/* Connection Toast */
body.theme-dark .conn-toast {
    background: #f5f5f5;
    color: #0a0a0a;
}

/* Ambient Dumbbell im Dark Mode heller */
body.theme-dark .ambient-dumbbell {
    opacity: 0.55;
}

/* Dark-Mode Toggle Button — Text schön lesbar */
body.theme-dark .dropdown-item {
    color: var(--text);
}
body.theme-dark .dropdown-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}

/* Chat Lock Overlay im Dark Mode */
body.theme-dark .chat-offline-lock {
    background: rgba(26,26,26,0.85);
}
body.theme-dark .chat-lock-icon {
    background: #f5f5f5;
    color: #0a0a0a;
}
body.theme-dark .chat-lock-close {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.15);
    color: #f5f5f5;
}
body.theme-dark .chat-lock-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Upgrade Lock Visual */
body.theme-dark .upgrade-lock-visual {
    background: linear-gradient(145deg, #f5f5f5 0%, #b0b0b0 55%, #6a6a6a 100%);
    color: #0a0a0a;
}

/* Sync-Badge im Dark Mode */
body.theme-dark .sync-badge {
    background: rgba(245,158,11,0.2);
    color: #fbbf24;
}

/* ═══════════════════════════════════════════════════════════════
   ADMIN PANEL — Tabellen & Selects Dark Mode Fix
   ═══════════════════════════════════════════════════════════════ */

/* Admin Panel Tabelle */
body.theme-dark #modal-body table,
body.theme-dark .modal-body table {
    color: var(--text);
    width: 100%;
}
body.theme-dark #modal-body th,
body.theme-dark .modal-body th {
    color: var(--ink);
    border-bottom-color: var(--border) !important;
}
body.theme-dark #modal-body td,
body.theme-dark .modal-body td {
    color: var(--text);
    border-color: var(--border) !important;
}

/* Alle Select-Dropdowns im Dark Mode lesbar */
body.theme-dark select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-family: var(--font);
}

body.theme-dark select option {
    background: var(--surface-2);
    color: var(--text);
}

/* Admin-Buttons "AI Reset" / "PW Reset" — neutrale Style */
body.theme-dark .modal-body button:not(.btn-dark):not(.btn-icon-plain):not(.btn-icon-xs):not(.danger):not(.btn-danger) {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

body.theme-dark .modal-body button:not(.btn-dark):not(.btn-icon-plain):not(.btn-icon-xs):not(.danger):not(.btn-danger):hover {
    background: var(--surface);
    color: var(--ink);
    border-color: #f5f5f5;
}

/* Danger-Buttons (Löschen) */
body.theme-dark .modal-body button.danger,
body.theme-dark .modal-body .btn-danger {
    background: rgba(220,38,38,0.15);
    color: #f87171;
    border: 1px solid rgba(220,38,38,0.35);
}
body.theme-dark .modal-body button.danger:hover,
body.theme-dark .modal-body .btn-danger:hover {
    background: rgba(220,38,38,0.25);
    color: #fca5a5;
}

/* Role/Sub-Badges (owner, pro etc.) */
body.theme-dark .modal-body .badge,
body.theme-dark .modal-body .role-badge,
body.theme-dark .modal-body .sub-badge,
body.theme-dark .modal-body .pill {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

/* Alle Texte im Modal-Body im Dark Mode */
body.theme-dark .modal-body,
body.theme-dark .modal-body div,
body.theme-dark .modal-body span,
body.theme-dark .modal-body p,
body.theme-dark .modal-body td,
body.theme-dark .modal-body th,
body.theme-dark .modal-body label {
    color: var(--text);
}

body.theme-dark .modal-body h1,
body.theme-dark .modal-body h2,
body.theme-dark .modal-body h3,
body.theme-dark .modal-body h4,
body.theme-dark .modal-body strong,
body.theme-dark .modal-body b {
    color: var(--ink);
}

/* ═══════════════════════════════════════════════════════════════
   THEME PERFORMANCE FIX — Kein Lag beim Umschalten
   ═══════════════════════════════════════════════════════════════ */

/* Transitions komplett deaktivieren während Theme-Switch */
body.theme-switching,
body.theme-switching *,
body.theme-switching *::before,
body.theme-switching *::after {
    transition: none !important;
    animation-duration: 0s !important;
}

/* ═══════════════════════════════════════════════════════════════
   SVG ICON COLORS — Bulletproof mit CSS Variables
   ═══════════════════════════════════════════════════════════════ */

/* Definition: Farbe für "dark buttons" (Hintergrund dunkel → Icon hell) */
:root {
    --icon-on-dark: #ffffff;   /* SVG-Farbe wenn Button dunkel ist */
    --icon-on-light: #0a0a0a;  /* SVG-Farbe wenn Button hell ist */
}

body.theme-dark {
    /* Im Dark Mode: "dark buttons" sind eigentlich hell → Icon dunkel */
    --icon-on-dark: #0a0a0a;
    --icon-on-light: #ffffff;
}

/* Alle Icon-Container die im Light Mode dunkel sind */
.btn-dark,
.btn-add-square,
.btn-send-dark,
.chat-fab,
.nav-btn.active,
.stat-icon-box,
.brand-icon-box,
.set-num,
.user-avatar {
    color: var(--icon-on-dark);
}

.btn-dark svg,
.btn-add-square svg,
.btn-send-dark svg,
.chat-fab svg,
.nav-btn.active svg,
.stat-icon-box svg,
.brand-icon-box svg {
    color: var(--icon-on-dark) !important;
    stroke: var(--icon-on-dark) !important;
}

.btn-dark svg[fill]:not([fill="none"]),
.btn-add-square svg[fill]:not([fill="none"]),
.btn-send-dark svg[fill]:not([fill="none"]),
.chat-fab svg[fill]:not([fill="none"]),
.stat-icon-box svg[fill]:not([fill="none"]),
.brand-icon-box svg[fill]:not([fill="none"]) {
    fill: var(--icon-on-dark) !important;
}

/* Toast Icons */
.toast {
    color: var(--icon-on-dark);
}
.toast svg {
    color: var(--icon-on-dark) !important;
    stroke: var(--icon-on-dark) !important;
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE — ALLE BUTTONS mit hellem Hintergrund
   ═══════════════════════════════════════════════════════════════ */

body.theme-dark .btn-dark,
body.theme-dark .btn-add-square,
body.theme-dark .btn-send-dark,
body.theme-dark .chat-fab {
    background: #f5f5f5;
    color: #0a0a0a;
    border-color: #f5f5f5;
}

body.theme-dark .btn-dark:hover,
body.theme-dark .btn-add-square:hover,
body.theme-dark .btn-send-dark:hover,
body.theme-dark .chat-fab:hover {
    background: #e5e5e5;
    color: #0a0a0a;
}

body.theme-dark .nav-btn.active {
    background: #f5f5f5;
    color: #0a0a0a;
}

body.theme-dark .stat-icon-box,
body.theme-dark .brand-icon-box,
body.theme-dark .set-num,
body.theme-dark .user-avatar {
    background: #f5f5f5;
    color: #0a0a0a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

