/*
 * Apple Design System — CSS Component Library
 * Ricalca il piu possibile lo stile Apple/iOS/macOS
 * Usabile con qualsiasi HTML. Nessuna dipendenza JS.
 *
 * Font consigliato: Inter o SF Pro (carica Inter da Google Fonts come fallback)
 * @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
 *
 * Icone: usa l'attributo app-icon="nome" (vedi app-icons.js v2)
 *        Libreria nativa: Lucide (stile SF Symbols) — SVG inline via lucide.min.js
 *        I nomi vengono mappati automaticamente (es. app-icon="heart" → Lucide "heart")
 *        Esempio: <i app-icon="heart" style="width:20px;height:20px"></i>
 *
 * ─── INDICE SEZIONI ───────────────────────────────────────────
 *
 *  FONDAMENTA
 *   1. TOKENS — Design tokens Apple
 *   2. BASE — Reset + Typography
 *
 *  COMPONENTI UI
 *   3. BUTTONS                    23. UTILITIES
 *   4. CARDS                      24. ACCORDION / COLLAPSIBLE
 *   5. LIST / TABLE               25. TABS
 *   6. INPUTS                     26. CHIPS
 *   7. TOGGLE / SWITCH            27. FAB (Floating Action Button)
 *   8. CHECKBOX & RADIO           28. STEPPER (+/-)
 *   9. SEGMENTED CONTROL          29. RATING (Stars)
 *  10. BADGE / TAG / CHIP         30. TIMELINE
 *  11. PROGRESS & SLIDER          31. BANNER / ANNOUNCEMENT
 *  12. ALERTS / BANNERS           32. DROPDOWN MENU
 *  13. TOAST                      33. ACTION SHEET
 *  14. MODAL / SHEET              34. EMPTY STATE
 *  15. AVATAR                     35. BREADCRUMBS
 *  16. SEPARATOR                  36. PAGINATION
 *  17. SPINNER / LOADING          37. TOOLTIP
 *  18. TOOLTIP                    38. POPOVER
 *  19. SKELETON LOADING           39. SIDEBAR / DRAWER
 *  20. NAV BAR / TAB BAR          40. SPINNER / LOADING
 *  21. PAGINATION DOTS            41. CHECKBOX & RADIO
 *  22. SELECT / DROPDOWN          42. SELECT / CUSTOM DROPDOWN
 *                                 43. FILE UPLOAD
 *  FORM & DATA                    44. FORM VALIDATION
 *  45. GRID SYSTEM                46. CAROUSEL
 *  47. KBD (Keyboard Shortcuts)   48. CODE BLOCK
 *
 *  THEMING
 *  49. DARK MODE
 *
 *  APP COMPONENTS (app-palestra)
 *  50. APP CONTAINER & LAYOUT     60. COMPLETED LIST
 *  51. LOGIN PAGE                 61. WORKOUT DETAIL
 *  52. TAB BAR                    62. UNLOCK PAGE
 *  53. SECTION HEADER             63. CHAT
 *  54. STATS HERO                 64. PROFILE
 *  55. PHOTO STRIP                65. SETTINGS
 *  56. CHART SYSTEM               66. HELPERS
 *  57. NUTRITION GRID             67. TOAST CONTAINER
 *  58. WORKOUT TABS               68. TRANSITIONS
 *  59. WORKOUT CARDS
 *
 * ──────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════
   1. TOKENS — Design tokens Apple
   ═══════════════════════════════════════════════════ */

:root {
    /* Palette */
    --app-blue:        #0071e3;
    --app-blue-hover:  #0077ed;
    --app-blue-active: #005ec4;
    --app-blue-bg:     rgba(0, 113, 227, 0.1);
    --app-green:       #34c759;
    --app-green-bg:    rgba(52, 199, 89, 0.12);
    --app-red:         #ff3b30;
    --app-red-bg:      rgba(255, 59, 48, 0.1);
    --app-orange:      #ff9500;
    --app-orange-bg:   rgba(255, 149, 0, 0.1);
    --app-yellow:      #ffcc00;
    --app-yellow-bg:   rgba(255, 204, 0, 0.1);
    --app-purple:      #af52de;
    --app-purple-bg:   rgba(175, 82, 222, 0.1);
    --app-teal:        #5ac8fa;
    --app-pink:        #ff2d55;
    --app-indigo:      #5856d6;

    /* Grays — iOS system grays */
    --app-gray1:       #8e8e93;
    --app-gray2:       #aeaeb2;
    --app-gray3:       #c7c7cc;
    --app-gray4:       #d1d1d6;
    --app-gray5:       #e5e5ea;
    --app-gray6:       #f2f2f7;

    /* Semantic */
    --app-bg:             #f2f2f7;
    --app-bg-elevated:    #ffffff;
    --app-text:           #1d1d1f;
    --app-text-secondary: #86868b;
    --app-text-tertiary:  #aeaeb2;
    --app-separator:      rgba(60, 60, 67, 0.12);
    --app-separator-bold: rgba(60, 60, 67, 0.29);
    --app-fill:           rgba(120, 120, 128, 0.2);
    --app-fill-secondary: rgba(120, 120, 128, 0.16);
    --app-fill-tertiary:  rgba(120, 120, 128, 0.12);

    /* Shapes */
    --app-radius-xs:   8px;
    --app-radius-sm:   12px;
    --app-radius-md:   16px;
    --app-radius-lg:   20px;
    --app-radius-xl:   28px;
    --app-radius-full: 100px;

    /* Shadows */
    --app-shadow-sm:   0 0.5px 1px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
    --app-shadow-md:   0 2px 8px rgba(0,0,0,0.08), 0 0.5px 1px rgba(0,0,0,0.04);
    --app-shadow-lg:   0 4px 20px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.06);
    --app-shadow-xl:   0 8px 40px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.06);

    /* Effects */
    --app-blur:        saturate(180%) blur(20px);
    --app-blur-light:  saturate(120%) blur(10px);

    /* Motion */
    --app-ease:        cubic-bezier(0.25, 0.1, 0.25, 1);
    --app-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
    --app-duration:    0.3s;
    --app-duration-sm: 0.2s;
    --app-duration-lg: 0.45s;
}


/* ═══════════════════════════════════════════════════
   2. BASE — Reset + Typography
   ═══════════════════════════════════════════════════ */

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

body {
    font-family: 'Inter', -app-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--app-bg);
    color: var(--app-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.47;
    letter-spacing: -0.01em;
    font-size: 16px;
}

/* Large Title — stile iOS */
.app-title-large {
    font-size: 2.125rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1.1;
}

.app-title-1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.15;
}

.app-title-2 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.app-title-3 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.app-headline {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.app-body {
    font-size: .9375rem;
    font-weight: 400;
    line-height: 1.47;
}

.app-callout {
    font-size: .875rem;
    font-weight: 400;
    line-height: 1.4;
}

.app-subhead {
    font-size: .8125rem;
    font-weight: 400;
    line-height: 1.35;
    color: var(--app-text-secondary);
}

.app-footnote {
    font-size: .75rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--app-text-secondary);
}

.app-caption {
    font-size: .6875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--app-text-secondary);
}


/* ═══════════════════════════════════════════════════
   3. BUTTONS
   ═══════════════════════════════════════════════════ */

/* Base button */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-weight: 500;
    font-size: .875rem;
    border: none;
    border-radius: var(--app-radius-full);
    padding: 10px 20px;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--app-duration-sm) var(--app-ease);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    white-space: nowrap;
    line-height: 1;
}

.app-btn:active { transform: scale(0.96); }
.app-btn:disabled { opacity: 0.35; pointer-events: none; }

/* Filled — Primary */
.app-btn-filled {
    background: var(--app-blue);
    color: #fff;
    border-radius: var(--app-radius-full);
    padding: 12px 24px;
    font-weight: 500;
    font-size: .9375rem;
}
.app-btn-filled:hover { background: var(--app-blue-hover); }
.app-btn-filled:active { background: var(--app-blue-active); }

/* Tinted — Sfondo leggero */
.app-btn-tinted {
    background: var(--app-blue-bg);
    color: var(--app-blue);
    border-radius: var(--app-radius-full);
    padding: 10px 20px;
    font-weight: 600;
    font-size: .875rem;
}
.app-btn-tinted:hover { background: rgba(0, 113, 227, 0.16); }

/* Gray */
.app-btn-gray {
    background: var(--app-fill-tertiary);
    color: var(--app-text);
}
.app-btn-gray:hover { background: var(--app-fill-secondary); }

/* Plain — solo testo */
.app-btn-plain {
    background: none;
    color: var(--app-blue);
    padding: 8px 4px;
    font-weight: 500;
    font-size: .9375rem;
    border-radius: var(--app-radius-xs);
}
.app-btn-plain:hover { background: var(--app-blue-bg); padding: 8px 12px; }

/* Destructive */
.app-btn-destructive {
    background: var(--app-red);
    color: #fff;
    border-radius: var(--app-radius-full);
    padding: 12px 24px;
    font-weight: 500;
    font-size: .9375rem;
}
.app-btn-destructive:hover { background: #e0342b; }

/* Small */
.app-btn-sm {
    font-size: .8125rem;
    padding: 8px 16px;
}

/* Large */
.app-btn-lg {
    font-size: 1.0625rem;
    padding: 14px 32px;
}

/* Block */
.app-btn-block {
    width: 100%;
}

/* Icon button circle */
.app-btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
    background: var(--app-fill-tertiary);
    color: var(--app-text);
    font-size: 1.1rem;
}
.app-btn-icon:hover { background: var(--app-fill-secondary); }

/* Color variants */
.app-btn-green  { background: var(--app-green); color: #fff; }
.app-btn-red    { background: var(--app-red); color: #fff; }
.app-btn-orange { background: var(--app-orange); color: #fff; }


/* ═══════════════════════════════════════════════════
   4. CARDS
   ═══════════════════════════════════════════════════ */

.app-card {
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-md);
    padding: 16px;
    box-shadow: var(--app-shadow-sm);
    transition: box-shadow var(--app-duration) var(--app-ease),
                transform var(--app-duration) var(--app-ease);
}
.app-card:hover {
    box-shadow: var(--app-shadow-md);
}

/* Card interattiva */
.app-card-interactive {
    cursor: pointer;
}
.app-card-interactive:active {
    transform: scale(0.98);
}

/* Card inset grouped — stile impostazioni iOS */
.app-card-grouped {
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-sm);
    overflow: hidden;
    box-shadow: none;
}

/* Card frosted glass */
.app-card-glass {
    background: rgba(255, 255, 255, 0.65);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
    border: 0.5px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--app-radius-md);
    padding: 16px;
    box-shadow: var(--app-shadow-md);
}


/* ═══════════════════════════════════════════════════
   5. LIST / TABLE — Stile Impostazioni iOS
   ═══════════════════════════════════════════════════ */

.app-list {
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-sm);
    overflow: hidden;
    list-style: none;
}

.app-list-header {
    font-size: .75rem;
    font-weight: 400;
    color: var(--app-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 28px 16px 8px;
}

.app-list-footer {
    font-size: .75rem;
    font-weight: 400;
    color: var(--app-text-secondary);
    padding: 8px 16px 16px;
    line-height: 1.4;
}

.app-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    min-height: 44px;
    background: var(--app-bg-elevated);
    transition: background var(--app-duration-sm);
    position: relative;
}

/* Separator — indentato come iOS */
.app-list-item + .app-list-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    height: 0.5px;
    background: var(--app-separator);
}

/* Con icona a sinistra — separator parte dopo l'icona */
.app-list-item.has-icon + .app-list-item.has-icon::before {
    left: 60px;
}

.app-list-item:active {
    background: rgba(0, 0, 0, 0.04);
}

.app-list-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: #fff;
    flex-shrink: 0;
}

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

.app-list-item-title {
    font-size: .9375rem;
    font-weight: 400;
    color: var(--app-text);
}

.app-list-item-subtitle {
    font-size: .75rem;
    color: var(--app-text-secondary);
    margin-top: 1px;
}

.app-list-item-value {
    font-size: .9375rem;
    color: var(--app-text-secondary);
    flex-shrink: 0;
}

/* Chevron — freccia destra */
.app-list-item-chevron::after {
    content: '';
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--app-gray3);
    border-bottom: 2px solid var(--app-gray3);
    transform: rotate(-45deg);
    flex-shrink: 0;
    margin-left: 4px;
}


/* ═══════════════════════════════════════════════════
   6. INPUTS
   ═══════════════════════════════════════════════════ */

.app-input {
    width: 100%;
    font-family: inherit;
    font-size: .9375rem;
    color: var(--app-text);
    background: var(--app-bg-elevated);
    border: 1px solid #DDD;
    border-radius: var(--app-radius-sm);
    padding: 12px 16px;
    outline: none;
    transition: box-shadow var(--app-duration-sm) var(--app-ease);
}
.app-input::placeholder { color: var(--app-text-tertiary); }
.app-input:focus {
    box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.3);
}

/* Search bar — stile iOS */
.app-search {
    width: 100%;
    font-family: inherit;
    font-size: .9375rem;
    color: var(--app-text);
    background: rgba(120, 120, 128, 0.12);
    border: none;
    border-radius: var(--app-radius-sm);
    padding: 10px 12px 10px 36px;
    outline: none;
    transition: all var(--app-duration-sm) var(--app-ease);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2386868b' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}
.app-search::placeholder { color: var(--app-text-tertiary); }
.app-search:focus {
    background-color: var(--app-bg-elevated);
    box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.2);
}

/* Textarea */
.app-textarea {
    width: 100%;
    font-family: inherit;
    font-size: .9375rem;
    color: var(--app-text);
    background: var(--app-bg-elevated);
    border: none;
    border-radius: var(--app-radius-sm);
    padding: 12px 16px;
    outline: none;
    resize: vertical;
    min-height: 80px;
    line-height: 1.47;
    transition: box-shadow var(--app-duration-sm) var(--app-ease);
}
.app-textarea:focus {
    box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.3);
}


/* ═══════════════════════════════════════════════════
   7. TOGGLE / SWITCH — Stile iOS
   ═══════════════════════════════════════════════════ */

.app-switch {
    position: relative;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

.app-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.app-switch-track {
    position: absolute;
    inset: 0;
    background: var(--app-fill);
    border-radius: 100px;
    transition: background var(--app-duration) var(--app-ease);
    cursor: pointer;
}

.app-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 0 1px rgba(0,0,0,0.06);
    transition: transform var(--app-duration) var(--app-spring);
}

.app-switch input:checked + .app-switch-track {
    background: var(--app-green);
}

.app-switch input:checked + .app-switch-track::after {
    transform: translateX(20px);
}

.app-switch input:focus-visible + .app-switch-track {
    box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.3);
}

/* Switch small */
.app-switch-sm {
    width: 40px;
    height: 24px;
}
.app-switch-sm .app-switch-track::after {
    width: 20px;
    height: 20px;
}
.app-switch-sm input:checked + .app-switch-track::after {
    transform: translateX(16px);
}


/* ═══════════════════════════════════════════════════
   8. CHECKBOX & RADIO
   ═══════════════════════════════════════════════════ */

.app-checkbox,
.app-radio {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: .9375rem;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.app-checkbox input,
.app-radio input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.app-checkbox-box {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--app-gray3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--app-duration-sm) var(--app-ease);
    flex-shrink: 0;
}

.app-checkbox input:checked ~ .app-checkbox-box {
    background: var(--app-blue);
    border-color: var(--app-blue);
}
.app-checkbox input:checked ~ .app-checkbox-box::after {
    content: '';
    width: 6px;
    height: 10px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-0.5px, -0.5px);
}

.app-radio-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--app-gray3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--app-duration-sm) var(--app-ease);
    flex-shrink: 0;
}

.app-radio input:checked ~ .app-radio-dot {
    border-color: var(--app-blue);
}
.app-radio input:checked ~ .app-radio-dot::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--app-blue);
}


/* ═══════════════════════════════════════════════════
   9. SEGMENTED CONTROL — Tab bar iOS
   ═══════════════════════════════════════════════════ */

.app-segmented {
    display: flex;
    background: rgba(120, 120, 128, 0.12);
    border-radius: var(--app-radius-xs);
    padding: 2px;
    gap: 2px;
}

.app-segmented-item {
    flex: 1;
    text-align: center;
    padding: 7px 12px;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--app-text);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--app-duration-sm) var(--app-ease);
    -webkit-tap-highlight-color: transparent;
}

.app-segmented-item.active,
.app-segmented-item[aria-selected="true"] {
    background: var(--app-bg-elevated);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0.5px 1px rgba(0,0,0,0.04);
}

.app-segmented-item:active:not(.active) {
    background: rgba(0,0,0,0.04);
}


/* ═══════════════════════════════════════════════════
   10. BADGE / TAG / CHIP
   ═══════════════════════════════════════════════════ */

.app-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 100px;
    background: var(--app-red);
    color: #fff;
    font-size: .6875rem;
    font-weight: 700;
    line-height: 1;
}

.app-badge-blue   { background: var(--app-blue); }
.app-badge-green  { background: var(--app-green); }
.app-badge-orange { background: var(--app-orange); }
.app-badge-gray   { background: var(--app-gray1); }

.app-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--app-radius-full);
    font-size: .75rem;
    font-weight: 500;
    background: var(--app-fill-tertiary);
    color: var(--app-text-secondary);
}

.app-tag-blue   { background: var(--app-blue-bg);   color: var(--app-blue); }
.app-tag-green  { background: var(--app-green-bg);  color: #1a7a36; }
.app-tag-red    { background: var(--app-red-bg);    color: var(--app-red); }
.app-tag-orange { background: var(--app-orange-bg); color: #b36b00; }
.app-tag-purple { background: var(--app-purple-bg); color: var(--app-purple); }


/* ═══════════════════════════════════════════════════
   11. PROGRESS & SLIDER
   ═══════════════════════════════════════════════════ */

.app-progress {
    width: 100%;
    height: 4px;
    background: var(--app-fill-tertiary);
    border-radius: 100px;
    overflow: hidden;
}

.app-progress-bar {
    height: 100%;
    background: var(--app-blue);
    border-radius: 100px;
    transition: width var(--app-duration) var(--app-ease);
}

/* Range slider */
.app-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--app-fill-tertiary);
    border-radius: 100px;
    outline: none;
}

.app-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15), 0 0 1px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform var(--app-duration-sm) var(--app-spring);
}

.app-slider::-webkit-slider-thumb:active {
    transform: scale(1.15);
}


/* ═══════════════════════════════════════════════════
   12. ALERTS / BANNERS
   ═══════════════════════════════════════════════════ */

.app-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--app-radius-sm);
    font-size: .875rem;
    line-height: 1.4;
}

.app-alert-info {
    background: var(--app-blue-bg);
    color: #004a94;
}

.app-alert-success {
    background: var(--app-green-bg);
    color: #1a7a36;
    border: 0.5px solid rgba(52, 199, 89, 0.2);
}

.app-alert-warning {
    background: var(--app-orange-bg);
    color: #8a5600;
    border: 0.5px solid rgba(255, 149, 0, 0.2);
}

.app-alert-error {
    background: var(--app-red-bg);
    color: #c5221f;
    border: 0.5px solid rgba(255, 59, 48, 0.2);
}


/* ═══════════════════════════════════════════════════
   13. TOAST — Notifica flottante
   ═══════════════════════════════════════════════════ */

/* iOS-style: frosted glass pill, top center */
.app-toast {
    background: rgba(50, 50, 50, 0.72);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
    color: #fff;
    padding: 12px 22px;
    max-width: 100%;
    border-radius: var(--app-radius-full);
    font-size: .875rem;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    animation: app-toast-in .4s var(--app-spring);
}
.app-toast-success {
    background: rgba(30, 120, 50, 0.78);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
}
.app-toast-error {
    background: rgba(200, 38, 32, 0.78);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
}

@keyframes app-toast-in {
    from { opacity: 0; transform: translateY(-14px) scale(0.92); }
    to   { opacity: 1; transform: none; }
}


/* ═══════════════════════════════════════════════════
   14. MODAL / SHEET — Bottom sheet iOS
   ═══════════════════════════════════════════════════ */

.app-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.app-sheet {
    background: var(--app-bg-elevated);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    border-radius: var(--app-radius-md) var(--app-radius-md) 0 0;
    padding: 0 20px 34px;
    overflow-y: auto;
    animation: app-sheet-up var(--app-duration-lg) var(--app-ease);
}

.app-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 -20px 12px;
    padding: 12px 0 8px;
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-md) var(--app-radius-md) 0 0;
}
.app-sheet-handle::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    background: rgba(60, 60, 67, 0.12);
    border-radius: 100px;
    margin: 0 auto;
}

@keyframes app-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: none; }
}

/* Alert dialog — centrato */
.app-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.app-dialog {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
    width: 270px;
    border-radius: 14px;
    text-align: center;
    overflow: hidden;
    box-shadow: var(--app-shadow-xl);
    animation: app-dialog-in var(--app-duration) var(--app-spring);
}

.app-dialog-body {
    padding: 20px 16px 16px;
}

.app-dialog-title {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.app-dialog-message {
    font-size: .8125rem;
    color: var(--app-text-secondary);
    line-height: 1.4;
}

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

.app-dialog-actions button {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 1.0625rem;
    cursor: pointer;
    color: var(--app-blue);
    font-weight: 400;
    transition: background var(--app-duration-sm);
}

.app-dialog-actions button:active {
    background: rgba(0,0,0,0.04);
}

.app-dialog-actions button + button {
    border-left: 0.5px solid var(--app-separator);
}

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

@keyframes app-dialog-in {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: none; }
}


/* ═══════════════════════════════════════════════════
   15. AVATAR
   ═══════════════════════════════════════════════════ */

.app-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--app-fill-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .875rem;
    color: var(--app-text-secondary);
    overflow: hidden;
    flex-shrink: 0;
}
.app-avatar img { width: 100%; height: 100%; object-fit: cover; }
.app-avatar-sm { width: 28px; height: 28px; font-size: .6875rem; }
.app-avatar-lg { width: 56px; height: 56px; font-size: 1.25rem; }
.app-avatar-xl { width: 80px; height: 80px; font-size: 1.75rem; }


/* ═══════════════════════════════════════════════════
   16. SEPARATOR
   ═══════════════════════════════════════════════════ */

.app-separator {
    border: none;
    height: 0.5px;
    background: var(--app-separator);
    margin: 0;
}

.app-separator-inset {
    margin-left: 16px;
}


/* ═══════════════════════════════════════════════════
   17. SPINNER / LOADING
   ═══════════════════════════════════════════════════ */

.app-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--app-fill-secondary);
    border-top-color: var(--app-blue);
    border-radius: 50%;
    animation: app-spin .7s linear infinite;
}

.app-spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.app-spinner-lg { width: 36px; height: 36px; border-width: 3px; }

@keyframes app-spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════════
   18. TOOLTIP
   ═══════════════════════════════════════════════════ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: rgba(30, 30, 30, 0.92);
    -webkit-backdrop-filter: var(--app-blur-light);
    backdrop-filter: var(--app-blur-light);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: .75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all var(--app-duration-sm) var(--app-ease);
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}


/* ═══════════════════════════════════════════════════
   19. SKELETON LOADING
   ═══════════════════════════════════════════════════ */

.app-skeleton {
    background: linear-gradient(90deg, var(--app-fill-tertiary) 25%, rgba(120,120,128,0.06) 50%, var(--app-fill-tertiary) 75%);
    background-size: 200% 100%;
    animation: app-shimmer 1.5s ease infinite;
    border-radius: var(--app-radius-xs);
}

.app-skeleton-text { height: 14px; margin-bottom: 8px; }
.app-skeleton-title { height: 20px; width: 60%; margin-bottom: 10px; }
.app-skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.app-skeleton-card { height: 120px; border-radius: var(--app-radius-md); }

@keyframes app-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ═══════════════════════════════════════════════════
   20. NAV BAR / TAB BAR
   ═══════════════════════════════════════════════════ */

/* iOS-style navigation bar */
.app-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(249, 249, 249, 0.78);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
    border-bottom: 0.5px solid var(--app-separator);
    min-height: 44px;
}

.app-navbar-title {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Tab bar — bottom navigation iOS */
.app-tabbar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 16px max(22px, env(safe-area-inset-bottom));
    background: rgba(249, 249, 249, 0.82);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
    border-top: 0.5px solid var(--app-separator);
}

.app-tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: .625rem;
    font-weight: 500;
    color: var(--app-text-tertiary);
    text-decoration: none;
    padding: 4px 12px;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--app-duration-sm);
}

.app-tabbar-item.active {
    color: var(--app-blue);
}

.app-tabbar-item svg,
.app-tabbar-item .tabbar-icon {
    width: 24px;
    height: 24px;
}


/* ═══════════════════════════════════════════════════
   21. PAGINATION DOTS
   ═══════════════════════════════════════════════════ */

.app-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.app-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--app-fill);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all var(--app-duration-sm) var(--app-ease);
}

.app-dot.active {
    background: var(--app-text);
    width: 24px;
    border-radius: 4px;
}


/* ═══════════════════════════════════════════════════
   22. SELECT / DROPDOWN
   ═══════════════════════════════════════════════════ */

.app-select {
    width: 100%;
    font-family: inherit;
    font-size: .9375rem;
    color: var(--app-text);
    background: var(--app-bg-elevated);
    border: none;
    border-radius: var(--app-radius-sm);
    padding: 12px 36px 12px 16px;
    outline: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2386868b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 14px) center;
    transition: box-shadow var(--app-duration-sm) var(--app-ease);
}

.app-select:focus {
    box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.3);
}


/* ═══════════════════════════════════════════════════
   23. UTILITIES
   ═══════════════════════════════════════════════════ */

/* Spacing */
.app-mt-0  { margin-top: 0; }
.app-mt-1  { margin-top: 4px; }
.app-mt-2  { margin-top: 8px; }
.app-mt-3  { margin-top: 12px; }
.app-mt-4  { margin-top: 16px; }
.app-mt-5  { margin-top: 24px; }
.app-mt-6  { margin-top: 32px; }

.app-mb-0  { margin-bottom: 0; }
.app-mb-1  { margin-bottom: 4px; }
.app-mb-2  { margin-bottom: 8px; }
.app-mb-3  { margin-bottom: 12px; }
.app-mb-4  { margin-bottom: 16px; }
.app-mb-5  { margin-bottom: 24px; }

.app-p-0   { padding: 0; }
.app-p-2   { padding: 8px; }
.app-p-3   { padding: 12px; }
.app-p-4   { padding: 16px; }
.app-p-5   { padding: 24px; }

.app-gap-1 { gap: 4px; }
.app-gap-2 { gap: 8px; }
.app-gap-3 { gap: 12px; }
.app-gap-4 { gap: 16px; }

/* Flex */
.app-flex      { display: flex; }
.app-flex-col  { display: flex; flex-direction: column; }
.app-flex-center { display: flex; align-items: center; justify-content: center; }
.app-flex-between { display: flex; align-items: center; justify-content: space-between; }
.app-flex-1 { flex: 1; }

/* Grid */
.app-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.app-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* Text */
.app-text-center { text-align: center; }
.app-text-right  { text-align: right; }
.app-text-blue   { color: var(--app-blue); }
.app-text-green  { color: var(--app-green); }
.app-text-red    { color: var(--app-red); }
.app-text-muted  { color: var(--app-text-secondary); }
.app-text-faint  { color: var(--app-text-tertiary); }

/* Truncate */
.app-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Rounded */
.app-rounded    { border-radius: var(--app-radius-md); }
.app-rounded-sm { border-radius: var(--app-radius-sm); }
.app-rounded-lg { border-radius: var(--app-radius-lg); }
.app-rounded-full { border-radius: var(--app-radius-full); }

/* Safe area padding (for use inside iPhone frames) */
.app-safe-bottom { padding-bottom: max(34px, env(safe-area-inset-bottom)); }


/* ═══════════════════════════════════════════════════
   24. ACCORDION / COLLAPSIBLE
   ═══════════════════════════════════════════════════ */

.app-accordion {
    border-radius: var(--app-radius-md);
    background: var(--app-bg-elevated);
    overflow: hidden;
}

.app-accordion-item + .app-accordion-item {
    border-top: 0.5px solid var(--app-separator);
}

.app-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: none;
    border: none;
    width: 100%;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 500;
    color: var(--app-text);
    cursor: pointer;
    transition: background var(--app-duration-sm);
    -webkit-tap-highlight-color: transparent;
}

.app-accordion-header:active { background: var(--app-fill-tertiary); }

.app-accordion-header::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--app-text-tertiary);
    border-bottom: 2px solid var(--app-text-tertiary);
    transform: rotate(45deg);
    transition: transform var(--app-duration-sm) var(--app-ease);
    flex-shrink: 0;
}

.app-accordion-item.open .app-accordion-header::after {
    transform: rotate(-135deg);
}

.app-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s var(--app-ease);
}

.app-accordion-item.open .app-accordion-body {
    max-height: 500px;
}

.app-accordion-content {
    padding: 0 16px 14px;
    font-size: .875rem;
    color: var(--app-text-secondary);
    line-height: 1.5;
}


/* ═══════════════════════════════════════════════════
   25. TABS
   ═══════════════════════════════════════════════════ */

.app-tabs {
    display: flex;
    border-bottom: 0.5px solid var(--app-separator);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    color: var(--app-text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--app-duration-sm) var(--app-ease);
    -webkit-tap-highlight-color: transparent;
}

.app-tab:hover { color: var(--app-text); }

.app-tab.active {
    color: var(--app-blue);
    border-bottom-color: var(--app-blue);
}

.app-tab-panel {
    display: none;
    padding: 16px 0;
}
.app-tab-panel.active { display: block; }


/* ═══════════════════════════════════════════════════
   26. CHIPS
   ═══════════════════════════════════════════════════ */

.app-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--app-radius-full);
    background: var(--app-fill-tertiary);
    color: var(--app-text);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--app-duration-sm) var(--app-ease);
    -webkit-tap-highlight-color: transparent;
}

.app-chip:hover { background: var(--app-fill-secondary); }
.app-chip:active { transform: scale(0.95); }

.app-chip.active,
.app-chip.selected {
    background: var(--app-blue);
    color: #fff;
}

.app-chip-close {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .625rem;
    line-height: 1;
    cursor: pointer;
    border: none;
    color: inherit;
}

.app-chip-outline {
    background: transparent;
    border: 1px solid var(--app-gray3);
}
.app-chip-outline.active,
.app-chip-outline.selected {
    border-color: var(--app-blue);
    background: var(--app-blue-bg);
    color: var(--app-blue);
}


/* ═══════════════════════════════════════════════════
   27. FAB (Floating Action Button)
   ═══════════════════════════════════════════════════ */

.app-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--app-radius-lg);
    background: var(--app-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--app-shadow-lg);
    transition: all var(--app-duration-sm) var(--app-ease);
    -webkit-tap-highlight-color: transparent;
}

.app-fab:hover { background: var(--app-blue-hover); box-shadow: var(--app-shadow-xl); }
.app-fab:active { transform: scale(0.92); }

.app-fab-sm {
    width: 40px;
    height: 40px;
    border-radius: var(--app-radius-md);
}

.app-fab-extended {
    width: auto;
    padding: 0 20px;
    gap: 8px;
    font-weight: 600;
    font-size: .875rem;
}


/* ═══════════════════════════════════════════════════
   28. STEPPER (+/-)
   ═══════════════════════════════════════════════════ */

.app-stepper {
    display: inline-flex;
    align-items: center;
    background: var(--app-fill-tertiary);
    border-radius: var(--app-radius-sm);
    overflow: hidden;
}

.app-stepper-btn {
    width: 36px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--app-blue);
    cursor: pointer;
    transition: background var(--app-duration-sm);
    -webkit-tap-highlight-color: transparent;
}

.app-stepper-btn:active { background: var(--app-fill-secondary); }
.app-stepper-btn:disabled { color: var(--app-text-tertiary); cursor: default; }

.app-stepper-divider {
    width: 0.5px;
    height: 18px;
    background: var(--app-separator);
}

.app-stepper-value {
    min-width: 40px;
    text-align: center;
    font-size: .9375rem;
    font-weight: 500;
    color: var(--app-text);
    padding: 0 4px;
}


/* ═══════════════════════════════════════════════════
   29. RATING (Stars)
   ═══════════════════════════════════════════════════ */

.app-rating {
    display: inline-flex;
    gap: 2px;
}

.app-star {
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--app-gray3);
    transition: color var(--app-duration-sm), transform var(--app-duration-sm);
    -webkit-tap-highlight-color: transparent;
}

.app-star:hover { transform: scale(1.15); }

.app-star.filled {
    color: #ff9500;
}

.app-star svg { width: 100%; height: 100%; }


/* ═══════════════════════════════════════════════════
   30. TIMELINE
   ═══════════════════════════════════════════════════ */

.app-timeline {
    position: relative;
    padding-left: 28px;
}

.app-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--app-separator);
    border-radius: 1px;
}

.app-timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.app-timeline-item:last-child { padding-bottom: 0; }

.app-timeline-dot {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--app-bg-elevated);
    border: 2px solid var(--app-blue);
    z-index: 1;
}

.app-timeline-dot.completed {
    background: var(--app-blue);
}

.app-timeline-dot.completed::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.app-timeline-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 2px;
}

.app-timeline-desc {
    font-size: .8125rem;
    color: var(--app-text-secondary);
    line-height: 1.4;
}

.app-timeline-time {
    font-size: .75rem;
    color: var(--app-text-tertiary);
    margin-top: 4px;
}


/* ═══════════════════════════════════════════════════
   31. BANNER / ANNOUNCEMENT
   ═══════════════════════════════════════════════════ */

.app-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--app-radius-md);
    background: var(--app-blue-bg);
    color: var(--app-blue);
    font-size: .875rem;
    font-weight: 500;
}

.app-banner-warning {
    background: var(--app-orange-bg);
    color: var(--app-orange);
}

.app-banner-error {
    background: var(--app-red-bg);
    color: var(--app-red);
}

.app-banner-success {
    background: var(--app-green-bg);
    color: #1a7a36;
}

.app-banner-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    font-size: 1.1rem;
    padding: 4px;
}

.app-banner-close:hover { opacity: 1; }


/* ═══════════════════════════════════════════════════
   32. DROPDOWN MENU
   ═══════════════════════════════════════════════════ */

.app-dropdown {
    position: relative;
    display: inline-block;
}

.app-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-md);
    box-shadow: var(--app-shadow-xl);
    padding: 6px;
    z-index: 100;
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    pointer-events: none;
    transition: all var(--app-duration-sm) var(--app-ease);
}

.app-dropdown.open .app-dropdown-menu {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.app-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--app-radius-sm);
    font-size: .875rem;
    color: var(--app-text);
    cursor: pointer;
    transition: background var(--app-duration-sm);
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
    text-align: left;
}

.app-dropdown-item:hover { background: var(--app-fill-tertiary); }
.app-dropdown-item:active { background: var(--app-blue); color: #fff; }

.app-dropdown-item.destructive { color: var(--app-red); }
.app-dropdown-item:disabled { color: var(--app-text-tertiary); pointer-events: none; }

.app-dropdown-separator {
    height: 0.5px;
    background: var(--app-separator);
    margin: 4px 8px;
}


/* ═══════════════════════════════════════════════════
   33. ACTION SHEET
   ═══════════════════════════════════════════════════ */

.app-action-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    padding: 8px;
    transform: translateY(100%);
    transition: transform 0.35s var(--app-ease);
}

.app-action-sheet.open { transform: translateY(0); }

.app-action-group {
    background: rgba(248, 248, 248, 0.82);
    -webkit-backdrop-filter: var(--app-blur);
    backdrop-filter: var(--app-blur);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 8px;
}

.app-action-item {
    display: block;
    width: 100%;
    padding: 17px 16px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--app-blue);
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.app-action-item:active { background: var(--app-fill-tertiary); }

.app-action-item + .app-action-item {
    border-top: 0.5px solid var(--app-separator);
}

.app-action-item.destructive { color: var(--app-red); }

.app-action-item.action-title {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--app-text-tertiary);
    cursor: default;
    padding: 14px 16px 6px;
}

.app-action-item.action-message {
    font-size: .8125rem;
    font-weight: 400;
    color: var(--app-text-tertiary);
    cursor: default;
    padding: 2px 16px 12px;
}

.app-action-cancel {
    display: block;
    width: 100%;
    padding: 17px 16px;
    background: var(--app-bg-elevated);
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--app-blue);
    text-align: center;
    cursor: pointer;
}


/* ═══════════════════════════════════════════════════
   34. EMPTY STATE
   ═══════════════════════════════════════════════════ */

.app-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.app-empty-icon {
    font-size: 3rem;
    color: var(--app-text-tertiary);
    margin-bottom: 16px;
    opacity: 0.5;
}

.app-empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 6px;
}

.app-empty-desc {
    font-size: .875rem;
    color: var(--app-text-secondary);
    max-width: 280px;
    line-height: 1.4;
}


/* ═══════════════════════════════════════════════════
   35. BREADCRUMBS
   ═══════════════════════════════════════════════════ */

.app-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .8125rem;
    color: var(--app-text-secondary);
    padding: 8px 0;
    flex-wrap: wrap;
}

.app-breadcrumb-item {
    color: var(--app-primary);
    text-decoration: none;
    border-radius: 4px;
    padding: 2px 6px;
    transition: background 0.2s;
}

.app-breadcrumb-item:hover {
    background: var(--app-fill);
}

.app-breadcrumb-item.active {
    color: var(--app-text);
    pointer-events: none;
}

.app-breadcrumb-sep {
    color: var(--app-text-tertiary);
    font-size: .75rem;
    user-select: none;
}


/* ═══════════════════════════════════════════════════
   36. PAGINATION
   ═══════════════════════════════════════════════════ */

.app-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.app-page-btn {
    min-width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--app-primary);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.app-page-btn:hover {
    background: var(--app-fill);
}

.app-page-btn.active {
    background: var(--app-primary);
    color: #fff;
}

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

.app-page-ellipsis {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--app-text-tertiary);
    font-size: .875rem;
}


/* ═══════════════════════════════════════════════════
   37. TOOLTIP
   ═══════════════════════════════════════════════════ */

.app-tooltip-wrap {
    position: relative;
    display: inline-flex;
}

.app-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.92);
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: .75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
    z-index: 999;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.app-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.78);
}

.app-tooltip-wrap:hover .app-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.app-tooltip.bottom {
    bottom: auto;
    top: calc(100% + 8px);
}

.app-tooltip.bottom::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: rgba(0, 0, 0, 0.78);
}


/* ═══════════════════════════════════════════════════
   38. POPOVER
   ═══════════════════════════════════════════════════ */

.app-popover-wrap {
    position: relative;
    display: inline-flex;
}

.app-popover {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.92);
    min-width: 200px;
    padding: 14px;
    border-radius: 14px;
    background: var(--app-bg-elevated);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
    z-index: 998;
}

.app-popover.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.app-popover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-top-color: var(--app-bg-elevated);
}

.app-popover-title {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 6px;
}

.app-popover-body {
    font-size: .8125rem;
    color: var(--app-text-secondary);
    line-height: 1.4;
}


/* ═══════════════════════════════════════════════════
   39. SIDEBAR / DRAWER
   ═══════════════════════════════════════════════════ */

.app-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.app-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.app-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--app-bg-elevated);
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.app-drawer.open {
    transform: translateX(0);
}

.app-drawer.right {
    left: auto;
    right: 0;
    transform: translateX(100%);
}

.app-drawer.right.open {
    transform: translateX(0);
}

.app-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 0.5px solid var(--app-separator);
}

.app-drawer-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--app-text);
}

.app-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.app-drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    font-size: .9375rem;
    color: var(--app-text);
    text-decoration: none;
    transition: background 0.18s;
}

.app-drawer-item:hover {
    background: var(--app-fill);
}

.app-drawer-item.active {
    color: var(--app-primary);
    font-weight: 500;
}


/* ═══════════════════════════════════════════════════
   40. SPINNER / LOADING
   ═══════════════════════════════════════════════════ */

.app-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--app-fill);
    border-top-color: var(--app-primary);
    border-radius: 50%;
    animation: app-spin 0.8s linear infinite;
    display: inline-block;
}

.app-spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.app-spinner.lg { width: 40px; height: 40px; border-width: 4px; }

@keyframes app-spin {
    to { transform: rotate(360deg); }
}

.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--app-text-secondary);
    font-size: .875rem;
}


/* ═══════════════════════════════════════════════════
   41. CHECKBOX & RADIO
   ═══════════════════════════════════════════════════ */

.app-checkbox,
.app-radio {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: .9375rem;
    color: var(--app-text);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.app-checkbox input,
.app-radio input {
    display: none;
}

.app-checkbox-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--app-text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.app-checkbox input:checked + .app-checkbox-mark {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.app-checkbox input:checked + .app-checkbox-mark::after {
    content: '';
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.app-radio-mark {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--app-text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.app-radio input:checked + .app-radio-mark {
    border-color: var(--app-primary);
}

.app-radio input:checked + .app-radio-mark::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--app-primary);
}


/* ═══════════════════════════════════════════════════
   42. SELECT / CUSTOM DROPDOWN
   ═══════════════════════════════════════════════════ */

.app-select-wrap {
    position: relative;
    display: inline-flex;
    min-width: 180px;
}

.app-select-trigger {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border-radius: 10px;
    border: none;
    background: var(--app-fill-secondary);
    color: var(--app-text);
    font-size: .9375rem;
    cursor: pointer;
    appearance: none;
    text-align: left;
    transition: background 0.18s;
}

.app-select-trigger:hover {
    background: var(--app-fill);
}

.app-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--app-text-tertiary);
    font-size: .75rem;
}

.app-select-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--app-bg-elevated);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 200;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.2s, transform 0.2s;
}

.app-select-list.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.app-select-option {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: .875rem;
    color: var(--app-text);
    cursor: pointer;
    transition: background 0.15s;
}

.app-select-option:hover {
    background: var(--app-fill);
}

.app-select-option.selected {
    color: var(--app-primary);
    font-weight: 500;
}


/* ═══════════════════════════════════════════════════
   43. FILE UPLOAD
   ═══════════════════════════════════════════════════ */

.app-file-upload {
    border: 2px dashed var(--app-separator-bold);
    border-radius: 14px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: transparent;
}

.app-file-upload:hover,
.app-file-upload.dragover {
    border-color: var(--app-primary);
    background: rgba(0, 122, 255, 0.04);
}

.app-file-upload-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--app-primary);
}

.app-file-upload-text {
    font-size: .9375rem;
    font-weight: 500;
    color: var(--app-text);
    margin-bottom: 4px;
}

.app-file-upload-hint {
    font-size: .8125rem;
    color: var(--app-text-secondary);
}

.app-file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.app-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--app-fill-secondary);
    border-radius: 10px;
    font-size: .8125rem;
    color: var(--app-text);
}

.app-file-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-file-item-size {
    color: var(--app-text-tertiary);
    font-size: .75rem;
}

.app-file-item-remove {
    background: none;
    border: none;
    color: var(--app-danger, #ff3b30);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
}


/* ═══════════════════════════════════════════════════
   44. FORM VALIDATION
   ═══════════════════════════════════════════════════ */

.app-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.app-field-label {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--app-text-secondary);
    padding-left: 2px;
}

.app-input.success {
    border: 1.5px solid var(--app-success, #34c759);
}

.app-input.error {
    border: 1.5px solid var(--app-danger, #ff3b30);
}

.app-field-msg {
    font-size: .75rem;
    padding-left: 2px;
    color: var(--app-text-secondary);
}

.app-field-msg.success {
    color: var(--app-success, #34c759);
}

.app-field-msg.error {
    color: var(--app-danger, #ff3b30);
}


/* ═══════════════════════════════════════════════════
   45. GRID SYSTEM
   ═══════════════════════════════════════════════════ */

.app-grid {
    display: grid;
    gap: 16px;
}

.app-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.app-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.app-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.app-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

.app-grid.gap-sm { gap: 8px; }
.app-grid.gap-lg { gap: 24px; }

@media (max-width: 768px) {
    .app-grid.cols-3,
    .app-grid.cols-4,
    .app-grid.cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .app-grid.cols-2,
    .app-grid.cols-3,
    .app-grid.cols-4,
    .app-grid.cols-6 {
        grid-template-columns: 1fr;
    }
}


/* ═══════════════════════════════════════════════════
   46. CAROUSEL
   ═══════════════════════════════════════════════════ */

.app-carousel {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
}

.app-carousel-track {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.app-carousel-slide {
    min-width: 100%;
    flex-shrink: 0;
}

.app-carousel-slide img {
    width: 100%;
    display: block;
    object-fit: cover;
}

.app-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    color: #1c1c1e;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.app-carousel-btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

.app-carousel-btn.prev { left: 10px; }
.app-carousel-btn.next { right: 10px; }

.app-carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.app-carousel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}

.app-carousel-dot.active {
    background: #fff;
    transform: scale(1.25);
}


/* ═══════════════════════════════════════════════════
   47. KBD (Keyboard Shortcuts)
   ═══════════════════════════════════════════════════ */

.app-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 26px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--app-bg-elevated);
    border: 1px solid var(--app-separator-bold);
    box-shadow: 0 1px 0 1px var(--app-separator);
    font-size: .75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-weight: 500;
    color: var(--app-text);
    line-height: 1;
    white-space: nowrap;
}

.app-kbd + .app-kbd {
    margin-left: 4px;
}

.app-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.app-shortcut-plus {
    font-size: .75rem;
    color: var(--app-text-tertiary);
}


/* ═══════════════════════════════════════════════════
   48. CODE BLOCK
   ═══════════════════════════════════════════════════ */

.app-code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: .8125rem;
    background: var(--app-fill-secondary);
    padding: 2px 6px;
    border-radius: 5px;
    color: var(--app-text);
}

.app-code-block {
    display: block;
    position: relative;
    background: #1e1e1e;
    border-radius: 12px;
    overflow: hidden;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: .8125rem;
    line-height: 1.6;
}

.app-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #2d2d2d;
    color: #a0a0a0;
    font-size: .75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
}

.app-code-copy {
    background: none;
    border: none;
    color: #a0a0a0;
    cursor: pointer;
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.app-code-copy:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.app-code-body {
    padding: 16px;
    overflow-x: auto;
    color: #d4d4d4;
}

.app-code-body code {
    font-family: inherit;
    font-size: inherit;
}

/* Syntax highlighting tokens */
.app-code-keyword  { color: #c586c0; }
.app-code-string   { color: #ce9178; }
.app-code-number   { color: #b5cea8; }
.app-code-comment  { color: #6a9955; font-style: italic; }
.app-code-function { color: #dcdcaa; }
.app-code-tag      { color: #569cd6; }
.app-code-attr     { color: #9cdcfe; }
.app-code-value    { color: #ce9178; }
.app-code-punct    { color: #808080; }


/* ═══════════════════════════════════════════════════
   49. DARK MODE
   ═══════════════════════════════════════════════════ */

.app-dark,
[data-theme="dark"] {
    --app-bg:             #000000;
    --app-bg-elevated:    #1c1c1e;
    --app-text:           #f5f5f7;
    --app-text-secondary: #98989d;
    --app-text-tertiary:  #636366;
    --app-separator:      rgba(84, 84, 88, 0.36);
    --app-separator-bold: rgba(84, 84, 88, 0.65);
    --app-fill:           rgba(120, 120, 128, 0.36);
    --app-fill-secondary: rgba(120, 120, 128, 0.32);
    --app-fill-tertiary:  rgba(120, 120, 128, 0.24);

    --app-shadow-sm:  0 0.5px 1px rgba(0,0,0,0.2);
    --app-shadow-md:  0 2px 8px rgba(0,0,0,0.3);
    --app-shadow-lg:  0 4px 20px rgba(0,0,0,0.4);
    --app-shadow-xl:  0 8px 40px rgba(0,0,0,0.5);

    /* iOS dark mode colors — leggermente diversi */
    --app-blue:        #0a84ff;
    --app-blue-hover:  #409cff;
    --app-blue-active: #0071e3;
    --app-blue-bg:     rgba(10, 132, 255, 0.18);
    --app-green:       #30d158;
    --app-green-bg:    rgba(48, 209, 88, 0.18);
    --app-red:         #ff453a;
    --app-red-bg:      rgba(255, 69, 58, 0.18);
    --app-orange:      #ff9f0a;
    --app-orange-bg:   rgba(255, 159, 10, 0.18);
    --app-purple:      #bf5af2;
    --app-purple-bg:   rgba(191, 90, 242, 0.18);

    color-scheme: dark;
}

.app-dark .app-card-glass {
    background: rgba(28, 28, 30, 0.6);
    border-color: rgba(255, 255, 255, 0.06);
}

.app-dark .app-switch-track::after {
    background: #fff;
}

.app-dark .app-navbar,
.app-dark .app-tabbar {
    background: rgba(28, 28, 30, 0.82);
    border-color: var(--app-separator);
}

.app-dark .app-dialog {
    background: rgba(44, 44, 46, 0.92);
}

.app-dark .app-alert-info    { color: #6cb4ff; }
.app-dark .app-alert-success { color: #6ee08e; }
.app-dark .app-alert-warning { color: #ffc04d; }
.app-dark .app-alert-error   { color: #ff7b73; }

/* Auto dark mode via prefers-color-scheme */
@media (prefers-color-scheme: dark) {
    .app-auto-dark {
        --app-bg:             #000000;
        --app-bg-elevated:    #1c1c1e;
        --app-text:           #f5f5f7;
        --app-text-secondary: #98989d;
        --app-text-tertiary:  #636366;
        --app-separator:      rgba(84, 84, 88, 0.36);
        --app-fill:           rgba(120, 120, 128, 0.36);
        --app-fill-secondary: rgba(120, 120, 128, 0.32);
        --app-fill-tertiary:  rgba(120, 120, 128, 0.24);
        --app-blue:           #0a84ff;
        --app-green:          #30d158;
        --app-red:            #ff453a;
        color-scheme: dark;
    }
}


/* ═══════════════════════════════════════════════════
   50. APP CONTAINER & LAYOUT
   ═══════════════════════════════════════════════════ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    background: var(--app-bg);
}

.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.app-content.has-tabbar {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
}


/* ═══════════════════════════════════════════════════
   52. TAB BAR
   ═══════════════════════════════════════════════════ */

.app-tabbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(64px + env(safe-area-inset-bottom));
    background: var(--app-bg-elevated);
    border-top: 0.5px solid var(--app-separator);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    color: var(--app-text-secondary);
    transition: color 0.2s;
    background: none;
    border: none;
    font-family: inherit;
    text-decoration: none;
}

.app-tabbar-item.route-active,
.app-tabbar-item.active {
    color: var(--app-blue);
}

.app-tabbar-item svg {
    width: 24px;
    height: 24px;
}

.app-tabbar-item span {
    font-size: .625rem;
    font-weight: 500;
}


/* ═══════════════════════════════════════════════════
   53. SECTION HEADER
   ═══════════════════════════════════════════════════ */

.app-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
}

.app-section-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}


/* ═══════════════════════════════════════════════════
   54. STATS HERO
   ═══════════════════════════════════════════════════ */

.app-stats-hero {
    background: linear-gradient(135deg, #2c2c2e 0%, #1c1c1e 100%);
    color: #fff;
    padding: 28px 24px 24px;
    text-align: center;
}

.app-stats-date {
    font-size: .75rem;
    opacity: 0.6;
    margin-bottom: 16px;
}

.app-stats-row {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.app-stat-item .app-stat-value {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.app-stat-item .app-stat-unit {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.7;
}

.app-stat-item .app-stat-label {
    font-size: .75rem;
    opacity: 0.5;
    margin-top: 4px;
}


/* ═══════════════════════════════════════════════════
   55. PHOTO STRIP
   ═══════════════════════════════════════════════════ */

.app-photo-strip {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
}

.app-photo-card {
    flex: 1;
    min-width: 0;
    height: 180px;
    border-radius: var(--app-radius-sm);
    background: var(--app-fill-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--app-text-secondary);
    font-size: .75rem;
}

.app-photo-card svg {
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════
   56. CHART SYSTEM
   ═══════════════════════════════════════════════════ */

.app-chart-container {
    padding: 12px 20px 20px;
}

.app-chart-label {
    font-size: .75rem;
    color: var(--app-text-secondary);
    margin-bottom: 12px;
}

.app-chart-wrap {
    display: flex;
    gap: 0;
}

.app-chart-yaxis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-bottom: 20px;
    min-width: 36px;
    text-align: right;
    padding-right: 6px;
}

.app-chart-yaxis span {
    font-size: .6rem;
    color: #999;
    line-height: 1;
}

.app-chart-area {
    position: relative;
    flex: 1;
}

.app-chart-inner {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding-bottom: 20px;
    width: 100%;
}

.app-chart-bar-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.app-chart-bar {
    width: 100%;
    max-width: 28px;
    margin: 0 auto;
    background: var(--app-blue);
    border-radius: 3px 3px 0 0;
    transition: height 0.4s cubic-bezier(.34, 1.56, .64, 1);
    opacity: 0.8;
}

.app-chart-bar-val {
    font-size: .6rem;
    color: var(--app-text-secondary);
    white-space: nowrap;
    margin-bottom: 2px;
}

.app-chart-bar-label {
    position: absolute;
    top: 100%;
    margin-top: 3px;
    font-size: .6rem;
    color: var(--app-text-secondary);
    white-space: nowrap;
}

.app-chart-zoom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.app-chart-zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--app-separator);
    background: var(--app-bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--app-text-secondary);
}

.app-chart-zoom-btn:active {
    background: var(--app-fill-tertiary);
}

.app-chart-zoom-info {
    font-size: .75rem;
    color: var(--app-text-secondary);
}

/* Progress line chart */
.app-progress-chart {
    position: relative;
    width: 100%;
    padding-bottom: 22px;
}

.app-progress-chart svg {
    display: block;
}

.app-progress-chart .p-line {
    fill: none;
    stroke: var(--app-blue);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-progress-chart .p-area {
    fill: var(--app-blue);
    opacity: 0.08;
}

.app-progress-chart .p-dot {
    fill: var(--app-blue);
}

.app-progress-chart .p-label {
    position: absolute;
    bottom: 0;
    font-size: .6rem;
    color: var(--app-text-secondary);
    white-space: nowrap;
    transform: translateX(-50%);
}

.app-progress-chart .p-val {
    position: absolute;
    font-size: .6rem;
    color: var(--app-text-secondary);
    white-space: nowrap;
    transform: translateX(-50%);
}


/* ═══════════════════════════════════════════════════
   57. NUTRITION GRID
   ═══════════════════════════════════════════════════ */

.app-metric-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 0 20px;
}

.app-metric-card {
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-sm);
    padding: 14px;
    text-align: center;
}

.app-metric-card .app-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.app-metric-card .app-metric-label {
    font-size: .6875rem;
    color: var(--app-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}


/* ═══════════════════════════════════════════════════
   58. WORKOUT TABS
   ═══════════════════════════════════════════════════ */

.app-tabline {
    display: flex;
    border-bottom: 1px solid var(--app-separator);
    padding: 0 8px;
}

.app-tabline-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--app-text-secondary);
    cursor: pointer;
    border: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    background: none;
    font-family: inherit;
}

.app-tabline-item.active {
    color: var(--app-text);
    border-bottom-color: var(--app-text);
}

.app-tabline-item svg {
    width: 18px;
    height: 18px;
}


/* ═══════════════════════════════════════════════════
   59. WORKOUT CARDS
   ═══════════════════════════════════════════════════ */

.app-pick-card {
    background: var(--app-bg-elevated);
    border-radius: var(--app-radius-md);
    padding: 20px;
    margin: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--app-shadow-sm);
}

.app-pick-card:active {
    transform: scale(0.98);
}

.app-pick-card .app-pick-card-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.app-pick-card .app-pick-card-icon {
    color: var(--app-gray3);
    width: 28px;
    height: 28px;
}


/* ═══════════════════════════════════════════════════
   60. COMPLETED LIST
   ═══════════════════════════════════════════════════ */

.app-datelist-date {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--app-text-secondary);
    padding: 16px 20px 4px;
}

.app-datelist-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 0.5px solid var(--app-separator);
    cursor: pointer;
}

.app-datelist-item:active {
    background: rgba(0, 0, 0, 0.03);
}

.app-datelist-item .app-datelist-name {
    font-size: .9375rem;
    font-weight: 600;
    flex: 1;
}

.app-datelist-item .app-datelist-time {
    font-size: .8125rem;
    color: var(--app-text-secondary);
    margin-right: 8px;
}

.app-datelist-item .app-datelist-chevron {
    color: var(--app-gray3);
    width: 18px;
    height: 18px;
}


/* ═══════════════════════════════════════════════════
   61. WORKOUT DETAIL
   ═══════════════════════════════════════════════════ */

.app-irows {
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--app-separator);
}

.app-irows .app-irows-title {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.app-irows .app-irows-head {
    display: flex;
    gap: 8px;
    font-size: .75rem;
    color: var(--app-text-secondary);
    margin-bottom: 6px;
}

.app-irows .app-irows-head span:first-child {
    flex: 1;
}

.app-irows .app-irows-head span {
    width: 70px;
    text-align: center;
}

.app-irows .app-irows-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.app-irows .app-irows-row .app-irows-label {
    flex: 1;
    font-size: .875rem;
}

.app-irows .app-irows-row input {
    width: 70px;
    text-align: center;
    font-size: .875rem;
    padding: 8px 4px;
    border: 1px solid var(--app-separator);
    border-radius: var(--app-radius-xs);
    background: var(--app-bg-elevated);
    color: var(--app-text);
    font-family: inherit;
}

.app-irows .app-irows-row .app-irows-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--app-radius-xs);
    background: var(--app-fill-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: var(--app-text-secondary);
}

.app-cta-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    background: var(--app-bg-elevated);
    border-top: 1px solid var(--app-separator);
    z-index: 100;
}

.app-cta-btn {
    width: 100%;
    padding: 16px;
    border-radius: var(--app-radius-sm);
    background: var(--app-text);
    color: var(--app-bg-elevated);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

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


/* ═══════════════════════════════════════════════════
   63. CHAT
   ═══════════════════════════════════════════════════ */

.app-chat-wrap {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 64px);
}

.app-chat-messages {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
}

.app-chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 0.5px solid var(--app-separator);
    background: var(--app-bg-elevated);
}

.app-chat-input-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--app-separator);
    border-radius: var(--app-radius-full);
    font-size: .875rem;
    font-family: inherit;
    background: var(--app-bg);
    color: var(--app-text);
}

.app-chat-input-bar button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--app-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    margin-bottom: 6px;
    font-size: .875rem;
    line-height: 1.4;
}

.app-chat-bubble-mine {
    background: var(--app-blue);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.app-chat-bubble-other {
    background: var(--app-bg-elevated);
    box-shadow: var(--app-shadow-sm);
    border-bottom-left-radius: 4px;
}

.app-chat-bubble-time {
    font-size: .625rem;
    opacity: 0.6;
    margin-top: 2px;
}


/* ═══════════════════════════════════════════════════
   65. SETTINGS
   ═══════════════════════════════════════════════════ */

.app-settings-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.app-settings-header .app-back-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--app-text);
}

.app-settings-header h1 {
    font-size: 1.125rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
    margin-right: 36px;
}

.app-settings-list {
    padding: 0 20px;
}

.app-settings-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 0.5px solid var(--app-separator);
    cursor: pointer;
}

.app-settings-item:active {
    opacity: 0.6;
}

.app-settings-item svg {
    width: 22px;
    height: 22px;
    color: var(--app-text-secondary);
}

.app-settings-item .app-si-label {
    flex: 1;
    font-size: .9375rem;
}

.app-settings-item .app-si-chevron {
    width: 18px;
    height: 18px;
    color: var(--app-gray3);
}

.app-settings-section-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--app-text-secondary);
    padding: 24px 0 4px;
}

.app-settings-logout {
    text-align: center;
    padding: 24px 0;
    color: var(--app-text-secondary);
    font-size: .9375rem;
    cursor: pointer;
}

.app-settings-logout:active {
    opacity: 0.5;
}


/* ═══════════════════════════════════════════════════
   66. HELPERS
   ═══════════════════════════════════════════════════ */

.app-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--app-radius-full);
    background: var(--app-fill-tertiary);
    font-size: .8125rem;
    font-weight: 500;
    color: var(--app-text);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.app-refresh-btn:active {
    opacity: 0.7;
}

.app-refresh-btn svg {
    width: 16px;
    height: 16px;
}

.app-filter-select {
    padding: 8px 28px 8px 14px;
    border: 1.5px solid var(--app-separator);
    border-radius: var(--app-radius-full);
    font-size: .8125rem;
    font-weight: 500;
    font-family: inherit;
    background: var(--app-bg-elevated);
    color: var(--app-text);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}


/* ═══════════════════════════════════════════════════
   67. TOAST CONTAINER
   ═══════════════════════════════════════════════════ */

.app-toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 70px);   /* sotto la barra di navigazione in alto */
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: calc(100% - 32px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}


/* ═══════════════════════════════════════════════════
   68. TRANSITIONS (f-transition / f-route-transition)
   ═══════════════════════════════════════════════════ */

.fade-enter        { opacity: 0; }
.fade-enter-active { transition: opacity .25s ease; }
.fade-leave        { opacity: 1; }
.fade-leave-active { transition: opacity .2s ease; opacity: 0; }

.slide-enter        { transform: translateY(-8px); opacity: 0; }
.slide-enter-active { transition: all .25s cubic-bezier(.34,1.56,.64,1); }
.slide-leave        { opacity: 1; }
.slide-leave-active { transition: all .2s ease; transform: translateY(-8px); opacity: 0; }

.slide-up-enter        { transform: translateY(20px); opacity: 0; }
.slide-up-enter-active { transition: all .3s cubic-bezier(.34,1.56,.64,1); }
.slide-up-leave        { opacity: 1; }
.slide-up-leave-active { transition: all .2s ease; transform: translateY(20px); opacity: 0; }

/* Sheet: esce verso il basso quando overlay fa fade-leave */
.fade-leave-active .app-sheet {
    animation: sheetOut .25s ease-in forwards;
}
@keyframes sheetIn  { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheetOut { from { transform: translateY(0); }    to { transform: translateY(100%); } }
/* Dialog centrale: chiusura animata (simmetrica a app-dialog-in) */
.fade-leave-active .app-dialog { animation: app-dialog-out .2s ease-in forwards; }
@keyframes app-dialog-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.9); } }
