:root {
    --primary: #007AFF;
    --primary-light: rgba(0, 122, 255, 0.12);
    --danger: #FF3B30;
    --success: #34C759;
    --orange: #FF9500;
    --bg: #F2F2F7;
    --card: #FFFFFF;
    --card2: #F9F9F9;
    --text: #000000;
    --text-secondary: #6E6E73;
    --separator: rgba(0,0,0,0.08);
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --header-height: 60px;
    --tab-height: 84px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F0F13;
        --card: #1C1C1E;
        --card2: #2C2C2E;
        --text: #FFFFFF;
        --text-secondary: #8E8E93;
        --separator: rgba(255,255,255,0.08);
        --shadow: 0 2px 12px rgba(0,0,0,0.4);
        --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* html ebenfalls einfärben: iOS zeigt sonst beim Overscroll/Statusbar-Bereich
   die schwarze WebView-Fläche durch (oberer Teil "schwarz" beim Scrollen). */
html {
    background: var(--bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overscroll-behavior: none;
    -webkit-user-select: text;
    user-select: text;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* ── Header ─────────────────────────────────────────── */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 8px;
    padding-top: env(safe-area-inset-top, 0px);
    background: rgba(var(--card), 0.72);
    background: color-mix(in srgb, var(--card) 80%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 0;
    z-index: 100;
    /* Eigenen Compositing-Layer erzwingen — verhindert das iOS-Schwarzflackern
       des backdrop-filter beim Momentum-Scrollen. */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

#page-title {
    font-size: 17px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    letter-spacing: -0.2px;
}

.header-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 20px;
    font-weight: 500;
    padding: 8px;
    cursor: pointer;
    min-width: 48px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s;
}

.header-btn:active {
    background: var(--primary-light);
}

.header-btn.hidden {
    visibility: hidden;
}

.header-btn.danger {
    color: var(--danger);
}

#back-btn {
    font-size: 28px;
    font-weight: 400;
}

/* ── Main content ────────────────────────────────────── */
#content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: 16px;
    padding-bottom: 200px;
}

/* ── FAB ─────────────────────────────────────────────── */
#fab {
    position: fixed;
    bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
    right: 20px;
    width: auto;
    height: 52px;
    padding: 0 28px;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 32px;
    font-weight: 400;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.15s, box-shadow 0.15s;
}

#fab:active {
    transform: scale(0.93);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.35);
}

#fab.hidden {
    display: none;
}

/* ── Tab bar ─────────────────────────────────────────── */
#tab-bar {
    display: flex;
    background: color-mix(in srgb, var(--card) 85%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 0.5px solid var(--separator);
    padding-bottom: var(--safe-bottom);
    min-height: var(--tab-height);
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.tab svg {
    fill: var(--text-secondary);
    transition: fill 0.2s, transform 0.15s;
}

.tab.active {
    color: var(--primary);
}

.tab.active svg {
    fill: var(--primary);
    transform: scale(1.1);
}

/* ── Section header ──────────────────────────────────── */
.section-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 20px 20px 8px;
}

/* ── List ────────────────────────────────────────────── */
.list {
    margin: 0 16px 8px;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-section {
    margin-bottom: 16px;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
    gap: 12px;
    min-height: 52px;
    transition: background 0.15s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:first-child {
    border-top: none;
}

.list-item:active {
    background: var(--card2);
}

.list-item .arrow {
    color: var(--text-secondary);
    font-size: 18px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.5;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.1px;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Reorder ─────────────────────────────────────────── */
.reorder-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.reorder-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 10px;
    padding: 4px 6px;
    cursor: pointer;
    line-height: 1;
}

.reorder-btn:disabled {
    color: var(--separator);
}

/* ── Badge ───────────────────────────────────────────── */
.badge {
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 20px;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: 0.1px;
}

.badge.cardio {
    background: rgba(255, 149, 0, 0.15);
    color: var(--orange);
}

.badge.kraft {
    background: var(--primary-light);
    color: var(--primary);
}

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px 40px;
    text-align: center;
    color: var(--text-secondary);
    gap: 10px;
}

.empty-state svg {
    width: 52px;
    height: 52px;
    fill: var(--text-secondary);
    opacity: 0.35;
    margin-bottom: 12px;
}

.empty-state .title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.empty-state .subtitle {
    font-size: 15px;
    line-height: 1.4;
}

/* ── Form ────────────────────────────────────────────── */
.form {
    margin: 0 16px 16px;
}

.form-group {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 0.5px solid var(--separator);
    gap: 12px;
}

.form-row:last-child {
    border-bottom: none;
}

.form-row label {
    font-size: 15px;
    font-weight: 500;
    min-width: 80px;
    flex-shrink: 0;
}

.form-row input,
.form-row select {
    flex: 1;
    font-size: 15px;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
    text-align: right;
    font-family: inherit;
}

.form-row input::placeholder {
    color: var(--text-secondary);
}

/* ── Segmented control ───────────────────────────────── */
.segmented {
    display: flex;
    background: var(--card2);
    border-radius: 10px;
    padding: 2px;
    margin: 12px 16px;
}

.segmented button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.segmented button.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 15px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    transition: opacity 0.15s, transform 0.1s;
    letter-spacing: -0.1px;
}

.btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-text {
    background: none;
    color: var(--primary);
    padding: 12px 16px;
    font-size: 15px;
}

.btn-text.danger {
    color: var(--danger);
}

.btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* ── Workout sets ────────────────────────────────────── */
.exercise-section {
    margin: 0 16px 12px;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.exercise-section-header {
    font-size: 15px;
    font-weight: 700;
    padding: 14px 16px 10px;
    color: var(--text);
    letter-spacing: -0.2px;
    border-bottom: 0.5px solid var(--separator);
}

.set-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
}

.set-row:last-child {
    border-bottom: none;
}

.set-row input {
    width: 72px;
    padding: 9px 10px;
    border: 1.5px solid var(--separator);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s;
}

.set-row input:focus,
.set-row input:not(:placeholder-shown) {
    border-color: var(--primary);
    outline: none;
}

.set-row .unit {
    font-size: 14px;
    color: var(--text-secondary);
    min-width: 32px;
    font-weight: 500;
}

.set-row .spacer {
    flex: 1;
}

.set-row.previous {
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}

.set-row.previous:active {
    background: var(--primary-light);
}

.pr-mark {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.pr-mark.hidden {
    display: none;
}

.set-row .delete-set {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0.8;
}

/* ── Slider ──────────────────────────────────────────── */
.slider-row {
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    margin-bottom: 10px;
    font-weight: 500;
}

.slider-row input[type="range"] {
    width: 100%;
    accent-color: var(--orange);
    height: 4px;
}

.add-set-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 16px;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    transition: background 0.15s;
}

.add-set-btn:active {
    background: var(--primary-light);
}

.warmup-toggle-btn {
    display: block;
    width: 100%;
    padding: 6px 16px 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.warmup-row {
    background: color-mix(in srgb, var(--card) 60%, var(--bg));
    opacity: 0.85;
}

.warmup-field {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.warmup-row input {
    width: 60px;
}

.warmup-row .spacer {
    display: none;
}

.warmup-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--text-secondary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Warmup define modal ─────────────────────────────── */
.wm-row { overflow: hidden; }
.wm-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.wm-field input {
    flex: 1;
    min-width: 0;
    text-align: right;
}
.wm-unit {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.wm-sep {
    color: var(--separator);
    flex-shrink: 0;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 8px 16px 4px;
}

/* ── Workout actions ─────────────────────────────────── */
.workout-actions {
    padding: 20px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Session notes ───────────────────────────────────── */
.notes-section {
    margin: 0 16px 12px;
}

.notes-section .section-header {
    padding-left: 4px;
}

.notes-section textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--card);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    resize: none;
    min-height: 88px;
    outline: none;
}

.session-notes-text {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    margin: 0 16px 12px;
}

/* ── Previous set label ──────────────────────────────── */
.prev-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.prev-pill {
    background: var(--bg);
    border: 1px solid var(--separator);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.prev-pill:active {
    background: var(--separator);
}

/* ── Modal / Sheet ───────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-sheet {
    background: var(--bg);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90dvh;
    overflow-y: auto;
    padding-bottom: var(--safe-bottom);
}

.modal-overlay--center {
    align-items: center;
}

.modal-sheet--center {
    border-radius: var(--radius);
    margin: 16px;
    width: calc(100% - 32px);
    max-height: 80dvh;
}

.ex-list {
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-bottom: 0.5px solid var(--separator);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px;
    border-bottom: 0.5px solid var(--separator);
    background: var(--card);
    border-radius: 24px 24px 0 0;
    position: sticky;
    top: 0;
}

.modal-header h2 {
    font-size: 17px;
    font-weight: 700;
}

.modal-header button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

/* ── Confirm dialog ──────────────────────────────────── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.confirm-dialog {
    background: var(--card);
    border-radius: 18px;
    width: 100%;
    max-width: 300px;
    overflow: hidden;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.confirm-dialog .message {
    padding: 24px 20px 16px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
    line-height: 1.4;
}

.confirm-dialog .actions {
    border-top: 0.5px solid var(--separator);
    display: flex;
}

.confirm-dialog .actions button {
    flex: 1;
    padding: 14px;
    border: none;
    background: none;
    font-size: 17px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.confirm-dialog .actions button:active {
    background: var(--card2);
}

.confirm-dialog .actions button:first-child {
    border-right: 0.5px solid var(--separator);
    color: var(--primary);
}

.confirm-dialog .actions button.danger {
    color: var(--danger);
    font-weight: 600;
}

.confirm-dialog .actions button.primary {
    color: var(--primary);
    font-weight: 600;
}

/* ── Existing exercises in modal ─────────────────────── */
.existing-exercises {
    max-height: 220px;
    overflow-y: auto;
}

.existing-exercises .list-item:active {
    background: var(--primary-light);
}

/* ── Workout Summary ─────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    padding: 8px 0;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.summary-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -1px;
}

.summary-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
}

/* ── Category progress cards ─────────────────────────── */
.category-progress-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}

.category-progress-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow);
}

.category-progress-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-progress-card-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

/* ── Chart ───────────────────────────────────────────── */
.chart-container {
    padding: 16px;
    background: var(--card);
    border-radius: var(--radius);
    margin: 0 16px 16px;
    box-shadow: var(--shadow-sm);
}

.chart-container canvas {
    width: 100% !important;
    max-height: 220px;
}

.chart-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 20px 20px 8px;
}

/* ── History detail ──────────────────────────────────── */
.detail-set-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
    font-size: 15px;
}

.detail-set-row:last-child {
    border-bottom: none;
}

/* ── Swipe to delete ─────────────────────────────────── */
.swipeable {
    position: relative;
    overflow: hidden;
    border-radius: 0;
}

.swipeable .swipe-content {
    position: relative;
    z-index: 1;
    background: var(--card);
}

.swipe-delete-bg {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    background: var(--danger);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    width: 80px;
}

/* ── List section inside detail ──────────────────────── */
.list-section {
    margin: 0 16px 12px;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-section .section-header {
    padding: 14px 16px 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    text-transform: none;
    letter-spacing: -0.2px;
    border-bottom: 0.5px solid var(--separator);
}

/* ── History list (expandable sessions) ─────────────── */
.history-list {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hist-item {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.hist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hist-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hist-date {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.hist-plan {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.hist-chevron {
    font-size: 22px;
    color: var(--text-secondary);
    line-height: 1;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.hist-chevron.expanded {
    transform: rotate(90deg);
}

.ex-collapse-chevron {
    display: inline-block;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.ex-collapse-chevron.expanded {
    transform: rotate(90deg);
}

.exercise-section-body.hidden {
    display: none;
}

.ex-collapse-summary {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin: 0 8px 0 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.hist-body {
    border-top: 0.5px solid var(--separator);
}

.hist-body.hidden {
    display: none;
}

/* ── Exercise search input ───────────────────────────── */
.ex-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--separator);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
}

.ex-search-input:focus {
    border-color: var(--primary);
    outline: none;
}

.hist-body-inner {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Volume overview (active workout) ────────────────── */
.vol-overview {
    margin: 0 0 4px;
}

.vol-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--card);
    border-radius: var(--radius);
    margin: 0 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.vol-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 0.5px solid var(--separator);
}

.vol-row:last-child {
    border-bottom: none;
}

.vol-row-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    min-width: 72px;
    flex-shrink: 0;
}

.vol-bar-wrap {
    flex: 1;
    min-width: 0;
}

.vol-bar-track {
    height: 8px;
    background: var(--separator);
    border-radius: 4px;
    position: relative;
    overflow: visible;
}

.vol-bar-fill {
    height: 100%;
    border-radius: 4px;
    min-width: 3px;
    transition: width 0.4s ease;
}

.vol-bar-last {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
}

.vol-row-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 52px;
    text-align: right;
    flex-shrink: 0;
}

/* ── History detail cards ────────────────────────────── */
.history-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.history-card-header {
    padding: 12px 14px 0;
}

.history-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.history-card-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.history-card-summary {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 3px 14px 8px;
    border-bottom: 0.5px solid var(--separator);
}

.history-card-sets {
    padding: 4px 0;
}

.history-set-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-bottom: 0.5px solid var(--separator);
}

.history-set-row:last-child {
    border-bottom: none;
}

.history-set-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 16px;
}

.history-input {
    width: 56px;
    padding: 5px 8px;
    border: 1.5px solid var(--separator);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
}

.history-input:focus {
    border-color: var(--primary);
    outline: none;
}

.history-unit {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.history-sep {
    font-size: 13px;
    color: var(--text-secondary);
    flex: 1;
    text-align: center;
}

/* ==================== Per-exercise CLI input ==================== */

.ex-cli-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 12px;
}

.ex-cli-input {
    flex: 1;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.ex-cli-input::placeholder {
    color: var(--text-secondary);
}

.ex-cli-input:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

.ex-cli-submit {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.ex-cli-submit:active {
    opacity: 0.8;
}

.ex-cli-hint {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 16px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* CLI live preview tooltip */
.cli-preview {
    position: relative;
    margin: 6px 16px 0;
    background: var(--card2);
    border: 0.5px solid var(--separator);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    pointer-events: none;
}
/* Downward arrow pointing at the input below */
.cli-preview::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 22px;
    width: 10px;
    height: 10px;
    background: var(--card2);
    border-right: 0.5px solid var(--separator);
    border-bottom: 0.5px solid var(--separator);
    transform: rotate(45deg);
}

.clip-w {
    color: var(--primary);
    font-weight: 700;
}
.clip-r {
    color: var(--success);
    font-weight: 700;
}
.clip-ww {
    color: var(--orange);
    font-weight: 700;
}
.clip-wr {
    color: var(--orange);
    font-weight: 600;
    opacity: 0.8;
}
.clip-unit {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.7;
    margin-left: 1px;
}
.clip-sep {
    color: var(--text-secondary);
    font-weight: 400;
}
.clip-badge-w {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--orange);
    border-radius: 4px;
    padding: 1px 4px;
    margin-right: 2px;
}
.clip-mult {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 800;
    color: var(--text);
    background: var(--separator);
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 1px;
}

.ex-cli-hint span b {
    color: var(--text);
    font-weight: 600;
}

/* ==================== Plan CLI input (add exercises to plan) ==================== */

#plan-cli-wrap {
    padding: 8px 12px 4px;
}

#plan-cli-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

#plan-cli-input {
    flex: 1;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    outline: none;
    min-width: 0;
}

#plan-cli-input::placeholder {
    color: var(--text-secondary);
}

#plan-cli-input:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

#plan-cli-submit {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

#plan-cli-submit:active { opacity: 0.8; }

#plan-cli-suggestions {
    background: var(--card);
    border: 0.5px solid var(--separator);
    border-radius: var(--radius-sm);
    margin-top: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#plan-cli-suggestions.hidden { display: none; }

/* ==================== Chat input bar (adding new exercises) ==================== */

#chat-input-wrap {
    padding: 8px 12px 16px;
}

#chat-suggestions {
    background: var(--card);
    border: 0.5px solid var(--separator);
    border-radius: var(--radius-sm);
    margin-top: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#chat-suggestions.hidden {
    display: none;
}

.chat-suggestion {
    padding: 11px 14px;
    font-size: 15px;
    color: var(--text);
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-suggestion:last-child {
    border-bottom: none;
}

.chat-suggestion:active {
    background: var(--bg);
}

.chat-eq-badge {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 4px;
    padding: 1px 5px;
    font-weight: 500;
}

#chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-input {
    flex: 1;
    background: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    outline: none;
    min-width: 0;
}

#chat-input::placeholder {
    color: var(--text-secondary);
}

#chat-submit {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

#chat-submit:active {
    opacity: 0.8;
}

/* ==================== App banner (errors + SW update) ==================== */
#app-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    animation: banner-in 0.2s ease-out;
}
#app-banner.hidden { display: none; }
#app-banner .banner-text { flex: 1; min-width: 0; word-wrap: break-word; }
#app-banner .banner-close,
#app-banner .banner-action {
    background: rgba(255,255,255,0.18);
    color: inherit;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
}
#app-banner .banner-close { padding: 2px 8px; font-size: 18px; line-height: 1; }
#app-banner .banner-action:active,
#app-banner .banner-close:active { opacity: 0.7; }

.banner-error { background: var(--danger, #ff3b30); color: #fff; }
.banner-update { background: var(--primary, #007aff); color: #fff; }

@keyframes banner-in {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* ── KI-Vorschlag: Übung tauschen ───────────────────── */
.ai-swap-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin: -8px -8px -8px 0;
    border: none;
    border-radius: 20px;
    background: transparent;
    color: var(--primary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ai-swap-btn:active { background: var(--separator); }
.ai-swap-list {
    max-height: 55dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
