@import url('https://fonts.googleapis.com/css2?family=Caudex:ital,wght@0,400;0,700;1,400&display=swap');

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

:root {
    --bg:          #f2f6fb;
    --surface:     #ffffff;
    --border:      #d6e2ef;
    --text:        #132035;
    --muted:       #4e6882;
    --faint:       #e8f1fb;
    --azure:       #1a6fc4;
    --azure-dark:  #135499;
    --azure-light: #ddeeff;
    --azure-faint: #f0f6ff;
    --danger:      #c0392b;
    --danger-bg:   #fdf0ef;
    --success:     #1a7a1a;
    --success-bg:  #f0faf0;
    --radius:      14px;
    --radius-sm:   8px;
    --shadow:      0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Caudex', Georgia, serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────── */

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 120px;
}

/* ── App Header ──────────────────────────────────── */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-header-inner {
    max-width: 480px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-name {
    font-family: 'Caudex', serif;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.logout-link {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ── Day Header ──────────────────────────────────── */

.day-header {
    padding: 24px 0 20px;
}

.day-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 9px;
    border-radius: 20px;
    background: var(--faint);
    color: var(--muted);
    border: 1px solid var(--border);
}

.badge-phase {
    background: var(--azure);
    color: #fff;
    border-color: var(--azure);
}

.day-number {
    font-family: 'Caudex', serif;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 4px;
}

.day-number span {
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--muted);
}

.day-focus {
    font-size: 1rem;
    font-weight: 400;
    font-style: italic;
    color: var(--muted);
    margin-bottom: 16px;
}

/* ── Progress Bar ────────────────────────────────── */

.progress-track {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: var(--azure);
    border-radius: 3px;
    transition: width .4s ease;
}

.progress-label {
    font-size: 0.73rem;
    color: var(--muted);
}

/* ── Section Label ───────────────────────────────── */

.section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 20px 0 10px;
}

/* ── Exercise Card ───────────────────────────────── */

.exercise-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s, transform .1s;
    box-shadow: var(--shadow);
}

.exercise-card:active {
    background: var(--azure-faint);
    transform: scale(0.99);
}

.ex-order {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--faint);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Caudex', serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    flex-shrink: 0;
}

.ex-body {
    flex: 1;
    min-width: 0;
}

.ex-name {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.ex-modifier {
    font-size: 0.75rem;
    font-style: italic;
    color: var(--muted);
}

.ex-metric {
    text-align: right;
    flex-shrink: 0;
}

.ex-metric-main {
    font-family: 'Caudex', serif;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--azure);
}

.ex-metric-sub {
    font-size: 0.7rem;
    color: var(--muted);
}

.ex-chevron {
    color: var(--border);
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Rest Day Card ───────────────────────────────── */

.rest-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.rest-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 14px;
}

.rest-title {
    font-family: 'Caudex', serif;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.rest-text {
    font-size: 0.88rem;
    font-style: italic;
    color: var(--muted);
    line-height: 1.6;
}

/* ── Day Notes ───────────────────────────────────── */

.day-notes-card {
    background: var(--azure-faint);
    border: 1px solid var(--azure-light);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--muted);
    margin-bottom: 4px;
    line-height: 1.6;
}

/* ── Action Bar ──────────────────────────────────── */

.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 20;
}

.action-bar-inner {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 15px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Caudex', serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .12s, transform .1s;
}

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

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

.btn-primary:hover {
    background: var(--azure-dark);
}

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

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

.btn-full {
    width: 100%;
    display: block;
    flex: none;
}

/* ── Exercise Detail ─────────────────────────────── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.83rem;
    color: var(--muted);
    text-decoration: none;
    margin: 20px 0 16px;
    -webkit-tap-highlight-color: transparent;
}

.back-link::before {
    content: '←';
    font-size: 1rem;
}

.detail-title {
    font-family: 'Caudex', serif;
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 12px;
}

.muscle-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 22px;
}

.muscle-tag {
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--faint);
    color: var(--muted);
    border: 1px solid var(--border);
}

.muscle-tag-primary {
    background: var(--azure);
    color: #fff;
    border-color: var(--azure);
}

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.detail-card-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 8px;
}

.detail-card-content {
    font-size: 0.9rem;
    line-height: 1.65;
}

.video-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px;
    background: var(--azure-faint);
    border: 1px solid var(--azure-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--azure);
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: var(--shadow);
    margin-top: 4px;
}

/* ── Auth ────────────────────────────────────────── */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}

.auth-logo {
    font-family: 'Caudex', serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 24px;
    display: block;
    color: var(--azure);
}

.auth-title {
    font-family: 'Caudex', serif;
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--muted);
    margin-bottom: 24px;
}

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 7px;
}

.form-field input {
    display: block;
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Caudex', serif;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-field input:focus {
    border-color: var(--azure);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--azure-light);
}

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #f0d0d0;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #c0e0c0;
}

.auth-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 0.85rem;
    color: var(--muted);
}

.auth-footer a {
    color: var(--azure);
    font-weight: 700;
    text-decoration: none;
}
