*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: 16px;
    color: inherit;
}

/* ── App Shell ── */
#app {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    padding: calc(var(--space-1) * 2);
    padding-top: calc(var(--space-1) * 9);
    padding-bottom: calc(var(--space-1) * 4);
}

/* ── Header ── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--muted-border);
}

.header-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.header-icon {
    color: var(--accent);
    display: flex;
}

.header-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 0.5);
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
}

/* ── Typography ── */
.page-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 12px;
}

/* ── Page Layout ── */
.page {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 1.5);
    margin-bottom: calc(var(--space-1) * 3);
}

.section {
    margin-top: calc(var(--space-1) * 3);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: calc(var(--space-1) * 2);
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--muted-border);
    border-radius: var(--radius-md);
    padding: calc(var(--space-1) * 2);
    transition: border-color 0.15s;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: calc(var(--space-1) * 1) calc(var(--space-1) * 2);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s, opacity 0.1s;
    white-space: nowrap;
}

.btn:active {
    opacity: 0.8;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg);
    border: 1px solid var(--text-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-ghost {
    background: var(--surface-2);
    border: 1px solid var(--muted-border);
    color: var(--text-primary);
}

.btn-ghost:hover {
    border-color: var(--muted-border-hover);
    background: var(--surface-hover);
}

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

.btn-danger:hover {
    opacity: 0.9;
}

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

.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.08);
}

.btn-sm {
    padding: calc(var(--space-1) * 0.5) calc(var(--space-1) * 1.25);
    font-size: 12px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s, opacity 0.1s;
}

.btn-icon:active {
    opacity: 0.8;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

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

.btn-danger-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

/* ── Inputs ── */
.input {
    width: 100%;
    padding: calc(var(--space-1) * 1) calc(var(--space-1) * 1.5);
    background: var(--surface);
    border: 1px solid var(--muted-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
    border-color: var(--muted-border-hover);
    box-shadow: 0 0 0 3px var(--focus);
}

.input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* ── Badge ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--muted-border);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: calc(var(--space-1) * 6) 0;
}

.empty-state-icon {
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: calc(var(--space-1) * 2);
}

.empty-state-text {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: var(--space-1);
}

.empty-state-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Toast ── */
#toast-container {
    position: fixed;
    bottom: calc(var(--space-1) * 3);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    pointer-events: none;
}

.toast {
    padding: calc(var(--space-1) * 1) calc(var(--space-1) * 2.5);
    background: var(--surface);
    border: 1px solid var(--muted-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: 0 8px 30px var(--shadow);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
    white-space: nowrap;
}

.toast--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: calc(var(--space-1) * 2);
    opacity: 0;
    transition: opacity 0.15s;
}

.modal-overlay--visible {
    opacity: 1;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--muted-border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 16px 48px var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--space-1) * 2) calc(var(--space-1) * 2.5);
    border-bottom: 1px solid var(--muted-border);
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
}

.modal-body {
    padding: calc(var(--space-1) * 2.5);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-1);
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2.5);
    border-top: 1px solid var(--muted-border);
}

/* ── Settings Page ── */
.settings-section {
    margin-bottom: calc(var(--space-1) * 4);
}

.settings-section .section-title {
    margin-bottom: calc(var(--space-1) * 2);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(var(--space-1) * 2);
    padding: calc(var(--space-1) * 2) 0;
    border-bottom: 1px solid var(--muted-border);
}

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

.settings-info {
    flex: 1;
}

.settings-label {
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
}

.about-info {
    padding: calc(var(--space-1) * 2);
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--muted-border);
}

.about-info p {
    margin-bottom: calc(var(--space-1) * 0.75);
}

.about-info p:last-child {
    margin-bottom: 0;
}

/* ══════════════════════════════════════════
   PUSH IT! — Counter-Specific Styles
   ══════════════════════════════════════════ */

/* ── Counter Page ── */
.counter-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 120px);
}

.exercise-name-section {
    width: 100%;
    margin-bottom: calc(var(--space-1) * 3);
}

.exercise-name-input {
    width: 100%;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2);
    background: var(--surface);
    border: 1px solid var(--muted-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    letter-spacing: -0.01em;
}

.exercise-name-input:focus {
    border-color: var(--muted-border-hover);
    box-shadow: 0 0 0 3px var(--focus);
}

.exercise-name-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
    font-weight: 400;
}

/* Counter Display */
.counter-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: calc(var(--space-1) * 2) 0;
}

.counter-display {
    font-size: 120px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--text-primary);
    user-select: none;
    transition: transform 0.1s ease;
    margin-bottom: calc(var(--space-1) * 1);
}

.counter-display.bump-up {
    animation: bumpUp 0.15s ease;
}

.counter-display.bump-down {
    animation: bumpDown 0.15s ease;
}

@keyframes bumpUp {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes bumpDown {
    0% { transform: scale(1); }
    40% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.counter-label {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: calc(var(--space-1) * 4);
}

/* Counter Buttons */
.counter-controls {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 4);
    margin-bottom: calc(var(--space-1) * 4);
}

.counter-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 300;
    transition: transform 0.1s, background 0.15s, border-color 0.15s, opacity 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.counter-btn:active {
    transform: scale(0.92);
    opacity: 0.85;
}

.counter-btn-minus {
    background: var(--surface);
    border: 1px solid var(--muted-border);
    color: var(--text-primary);
}

.counter-btn-minus:hover {
    border-color: var(--muted-border-hover);
    background: var(--surface-2);
}

.counter-btn-plus {
    background: var(--text-primary);
    border: 1px solid var(--text-primary);
    color: var(--bg);
}

.counter-btn-plus:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Reset link */
.counter-reset {
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
    margin-bottom: calc(var(--space-1) * 3);
    display: flex;
    align-items: center;
    gap: 4px;
}

.counter-reset:hover {
    color: var(--text-primary);
}

/* Save Button */
.save-section {
    width: 100%;
    padding-top: calc(var(--space-1) * 2);
    border-top: 1px solid var(--muted-border);
}

.save-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 2);
    background: var(--text-primary);
    color: var(--bg);
    border: 1px solid var(--text-primary);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s, opacity 0.1s;
    letter-spacing: -0.01em;
}

.save-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.save-btn:active {
    opacity: 0.85;
    transform: scale(0.99);
}

.save-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

/* ── History Page ── */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.history-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: default;
}

.history-entry:hover {
    border-color: var(--muted-border-hover);
}

.history-entry-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.history-entry-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-entry-date {
    font-size: 12px;
    color: var(--text-muted);
}

.history-entry-right {
    display: flex;
    align-items: center;
    gap: calc(var(--space-1) * 1.5);
    flex-shrink: 0;
}

.history-entry-reps {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.history-entry-reps-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.history-entry-delete {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s, opacity 0.1s;
}

.history-entry-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

.history-entry-delete:active {
    opacity: 0.8;
}

/* ── Stats Row ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-1);
    margin-bottom: calc(var(--space-1) * 2);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--muted-border);
    border-radius: var(--radius-md);
    padding: calc(var(--space-1) * 1.5) calc(var(--space-1) * 1);
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* ── Focus States ── */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ── Selection ── */
::selection {
    background: var(--accent);
    color: #fff;
}

/* ── Landscape Overlay ── */
@media (orientation: landscape) and (max-height: 500px) {
    #app {
        display: none !important;
    }

    body::after {
        content: 'Bitte drehe dein Gerät ins Hochformat 📱';
        position: fixed;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg);
        color: var(--text-primary);
        font-size: 16px;
        font-weight: 500;
        text-align: center;
        padding: 24px;
        z-index: 9999;
    }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .counter-display {
        font-size: 96px;
    }

    .counter-btn {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }

    .settings-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}
