/* Core Structural and iOS System Resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    --bg-absolute: #000000;
    --bg-card: #1c1c1e;
    --bg-card-elevated: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #aeaeae;
    --ios-blue: #0a84ff;
    --ios-orange: #ff9f0a;
    --ios-gray-border: #38383a;
    --ios-nav-bg: rgba(20, 20, 20, 0.94);
}

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-absolute);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden; /* Lock viewport elasticity */
    position: fixed;  /* Stop elastic drag behavior on iOS Safari browser wrappers */
}

/* Base App Layout Shell */
#app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Header UI Elements */
.ios-header {
    background-color: var(--bg-absolute);
    padding: 55px 16px 10px 16px; /* Top padding respects Safe Area layout rules */
    border-bottom: 0.5px solid var(--ios-gray-border);
    flex-shrink: 0;
}

.ios-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Main Workspace Frame Container */
.ios-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 100px; /* Accounts for bottom system sticky navbar layout clearances */
    -webkit-overflow-scrolling: touch;
}

/* Application Component Presentation Logic States */
.app-view {
    display: none;
}

.app-view.active {
    display: block;
}

/* iOS Cards Design Language Layout System */
.ios-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.ios-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.section-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.4;
}

/* Form Input Element Architecture Mapping */
.input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 0.5px solid var(--ios-gray-border);
}

.input-group:last-of-type {
    border-bottom: none;
    margin-bottom: 10px;
}

.input-group label {
    font-size: 16px;
    color: var(--text-primary);
}

.input-group input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    text-align: right;
    width: 50%;
    outline: none;
}

/* Standardized Form Interactive Elements Control Rules */
.ios-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.1s ease;
}

.btn-orange {
    background-color: var(--ios-orange);
    color: #000000;
}

.btn-orange:active {
    background-color: #e08b05;
}

.btn-secondary {
    background-color: var(--bg-card-elevated);
    color: var(--ios-orange);
    border: 0.5px solid var(--ios-gray-border);
}

/* Dashboard Performance Summary Modules */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.metric-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--ios-orange);
}

.metric-unit {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 2px;
}

/* Standard Native Native CSS Progress Bars */
.progress-bar-container {
    margin-top: 8px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.progress-labels strong {
    color: var(--text-primary);
}

.progress-track {
    width: 100%;
    height: 12px;
    background-color: var(--bg-card-elevated);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--ios-orange), #ffbe59);
    border-radius: 6px;
    transition: width 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
}

/* Presets Configuration Mechanics System */
.preset-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.preset-item-btn {
    background-color: var(--bg-card-elevated);
    border: 0.5px solid var(--ios-gray-border);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.preset-item-btn:active {
    background-color: #3a3a3c;
}

.item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.item-stats {
    font-size: 13px;
    color: var(--ios-orange);
    margin-top: 2px;
}

/* High-fidelity Native Mimicking Switch Checkboxes */
.ios-list {
    list-style: none;
    margin-bottom: 16px;
}

.ios-list li {
    border-bottom: 0.5px solid var(--ios-gray-border);
    padding: 12px 0;
}

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

.checkbox-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    cursor: pointer;
    font-size: 16px;
}

.checkbox-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

.checkmark {
    position: relative;
    width: 51px;
    height: 31px;
    background-color: #3a3a3c;
    border-radius: 16px;
    transition: background-color 0.2s;
}

.checkmark:after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.checkbox-container input:checked + .checkmark {
    background-color: #34c759; /* Apple System Green Option */
}

.checkbox-container input:checked + .checkmark:after {
    transform: translateX(20px);
}

/* Hypertrophy Execution Worksheets Formatting */
.tip-box {
    background-color: rgba(255, 159, 10, 0.15);
    border-left: 4px solid var(--ios-orange);
    padding: 12px;
    border-radius: 4px 8px 8px 4px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.4;
}

.exercise-category {
    font-size: 11px;
    color: var(--ios-orange);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.set-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card-elevated);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
}

.set-count {
    color: var(--text-secondary);
}

.small-check .checkmark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--ios-gray-border);
    background: transparent;
}

.small-check .checkmark:after {
    display: none;
}

.small-check input:checked + .checkmark {
    background-color: var(--ios-orange);
    border-color: var(--ios-orange);
}

.small-check input:checked + .checkmark:after {
    display: block;
    content: "✓";
    color: #000000;
    font-size: 16px;
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.workout-inputs {
    display: flex;
    gap: 10px;
    margin: 12px 0;
}

.workout-inputs input {
    flex: 1;
    background-color: var(--bg-card-elevated);
    border: 0.5px solid var(--ios-gray-border);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    text-align: center;
}

.set-tracker-group {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.set-pill {
    flex: 1;
    cursor: pointer;
    text-align: center;
}

.set-pill input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.set-pill span {
    display: block;
    padding: 10px;
    background-color: var(--bg-card-elevated);
    border: 0.5px solid var(--ios-gray-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.set-pill input:checked + span {
    background-color: var(--ios-blue);
    color: #ffffff;
    border-color: var(--ios-blue);
}

/* Chat Engine Layout System Structure */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 190px);
}

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
}

.bubble-received {
    background-color: var(--bg-card);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.bubble-sent {
    background-color: var(--ios-blue);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    background-color: var(--bg-absolute);
    border-top: 0.5px solid var(--ios-gray-border);
}

.chat-input-bar input {
    flex: 1;
    background-color: var(--bg-card);
    border: 0.5px solid var(--ios-gray-border);
    border-radius: 18px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.chat-send-btn {
    background-color: var(--ios-blue);
    border: none;
    color: #ffffff;
    padding: 0 16px;
    border-radius: 18px;
    font-size: 14px;
    font-weight: 600;
}

/* System Fixed Dock Native Navigation Bar Design */
.ios-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 84px; /* Native height accommodating lower home indicator area clearances */
    background-color: var(--ios-nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--ios-gray-border);
    display: flex;
    justify-content: space-around;
    padding-top: 6px;
    padding-bottom: 20px;
    z-index: 999;
}

.nav-item {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    width: 20%;
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--ios-orange);
}