/* DiveStrong — mobile-first, dark deep-sea theme */
:root {
    --bg: #0b1620;
    --bg-card: #12222f;
    --bg-card2: #16293a;
    --border: #1f3648;
    --text: #e8f0f5;
    --text-dim: #8fa8b8;
    --accent: #35c4dc;       /* dive-light cyan */
    --accent-deep: #1789a0;
    --good: #4cd97b;
    --warn: #ffb454;
    --danger: #ff6b6b;
    --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 560px;
    margin: 0 auto;
    padding: calc(12px + env(safe-area-inset-top)) 16px 24px;
}

.loading { text-align: center; color: var(--text-dim); padding: 48px 0; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-bottom: 10px; }

/* ---- Tab bar ---- */
#tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    background: rgba(11, 22, 32, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
}
#tabbar button {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.72rem;
    padding: 8px 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}
#tabbar button.active { color: var(--accent); }
.tab-icon { font-size: 1.35rem; }

/* ---- Cards & buttons ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.btn {
    display: block;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #04222b;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
}
.btn:active { transform: scale(0.985); }
.btn.secondary {
    background: var(--bg-card2);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 600;
}
.btn.danger { background: none; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { width: auto; padding: 9px 16px; font-size: 0.9rem; display: inline-block; }

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.link-dim { color: var(--text-dim); font-size: 0.85rem; text-decoration: none; background:none; border:none; cursor:pointer; }

/* ---- Home ---- */
.hero { text-align: center; padding: 22px 16px; }
.hero .big { font-size: 2rem; font-weight: 800; margin: 6px 0 2px; }
.hero .sub { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 16px; }
.week-dots { display: flex; gap: 7px; justify-content: center; margin: 10px 0 4px; }
.week-dots span {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--bg-card2); border: 1px solid var(--border);
}
.week-dots span.done { background: var(--good); border-color: var(--good); }
.exercise-preview { list-style: none; }
.exercise-preview li {
    display: flex; justify-content: space-between;
    padding: 9px 0; border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.exercise-preview li:last-child { border-bottom: none; }
.exercise-preview .meta { color: var(--text-dim); }

/* ---- Session ---- */
.session-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 12px;
}
.session-head .timer { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.ex-card { margin-bottom: 14px; }
.ex-name { font-size: 1.05rem; font-weight: 700; }
.ex-target { color: var(--text-dim); font-size: 0.85rem; margin: 2px 0 4px; }
.ex-equip { color: var(--accent); font-size: 0.8rem; margin-bottom: 8px; }
.ex-howto {
    font-size: 0.88rem; color: var(--text-dim);
    line-height: 1.45;
    margin: 8px 0;
    display: none;
}
.ex-card.show-howto .ex-howto { display: block; }
.ex-art { display: flex; gap: 8px; margin: 4px 0 10px; }
.ex-art figure {
    flex: 1; margin: 0;
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px 4px 6px;
    text-align: center;
}
.art-svg { width: 100%; height: auto; display: block; }
.ex-art figcaption { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

.set-row {
    display: grid;
    grid-template-columns: 44px 1fr 1fr 56px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.set-row .set-label {
    text-align: center; font-weight: 700; color: var(--text-dim);
    font-size: 0.9rem;
}
.set-row input {
    width: 100%;
    padding: 12px 8px;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    background: var(--bg-card2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    -moz-appearance: textfield;
}
.set-row input::-webkit-outer-spin-button,
.set-row input::-webkit-inner-spin-button { -webkit-appearance: none; }
.set-row input::placeholder { color: #4d6373; font-weight: 400; }
.set-row .tick {
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card2);
    color: var(--text-dim);
    font-size: 1.15rem;
    cursor: pointer;
}
.set-row.logged .tick { background: var(--good); border-color: var(--good); color: #06301a; }
.set-row.logged input { border-color: var(--good); }
.set-cols {
    display: grid;
    grid-template-columns: 44px 1fr 1fr 56px;
    gap: 8px;
    color: var(--text-dim);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    margin-bottom: 6px;
}

/* ---- Rest timer ---- */
#rest-timer {
    position: fixed;
    left: 16px; right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-width: 528px;
    margin: 0 auto;
    background: var(--accent-deep);
    color: #eafcff;
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
    z-index: 60;
}
#rest-timer .count { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
#rest-timer button {
    background: rgba(255,255,255,0.15);
    border: none; color: #eafcff;
    padding: 8px 14px; border-radius: 10px;
    font-weight: 700; cursor: pointer;
}
#rest-timer.done { background: var(--good); color: #06301a; }
#rest-timer.done button { color: #06301a; }

/* ---- History ---- */
.history-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.history-item:last-child { border-bottom: none; }
.history-item .h-title { font-weight: 700; }
.history-item .h-meta { color: var(--text-dim); font-size: 0.83rem; margin-top: 2px; }
.history-item .h-vol { color: var(--accent); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.detail-set { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.92rem; }
.detail-set .d-val { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.detail-ex-name { font-weight: 700; margin: 12px 0 4px; color: var(--accent); }
.session-notes { color: var(--text-dim); font-style: italic; margin-top: 10px; font-size: 0.9rem; }

/* ---- Progress ---- */
.ex-picker {
    width: 100%;
    padding: 13px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    -webkit-appearance: none;
}
.chart-wrap { overflow-x: auto; }
.chart-svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; margin-top: 8px; font-size: 0.8rem; color: var(--text-dim); }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px;
    text-align: center;
}
.stat .s-val { font-size: 1.35rem; font-weight: 800; color: var(--accent); }
.stat .s-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.empty-note { color: var(--text-dim); text-align: center; padding: 26px 0; font-size: 0.92rem; }

textarea.notes-input {
    width: 100%;
    background: var(--bg-card2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    min-height: 60px;
    margin-bottom: 10px;
}

/* ---- Login ---- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100dvh; padding: 20px;
}
.login-card {
    width: 100%; max-width: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px 26px;
    text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); font-size: 0.9rem; margin: 6px 0 18px; }
.login-error { color: var(--danger); font-size: 0.9rem; margin-bottom: 12px; }
.login-card input {
    width: 100%;
    padding: 14px;
    margin-bottom: 10px;
    font-size: 1rem;
    background: var(--bg-card2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.login-card button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #04222b;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 4px;
}
