/* ── Variables ── */
:root {
    --bg:         #111;
    --surface:    #1a1a1a;
    --border:     #2a2a2a;
    --text:       #e0e0e0;
    --text-dim:   #666;

    /* Effort zone colours — matched to Coggan zones */
    --z1:   #444;     /* recovery */
    --z2:   #4a90d9;  /* endurance */
    --z3:   #5cb85c;  /* tempo */
    --z4lo: #e6c027;  /* sweet spot */
    --z4hi: #e07820;  /* threshold */
    --z5lo: #e04020;  /* VO2 max lower */
    --z5hi: #cc2020;  /* VO2 max upper */
    --z6:   #aa00cc;  /* anaerobic */

    --seg-dim: #252525;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Header ── */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#live-data {
    display: flex;
    gap: 28px;
}

.metric {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.metric .value {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    min-width: 3ch;
    text-align: right;
}

.unit {
    font-size: 0.8rem;
    color: var(--text-dim);
}

#ftp-control {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

#ftp-input {
    width: 60px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: right;
}

#controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) { background: var(--border); }
button:disabled { opacity: 0.35; cursor: default; }

#sample-select {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 7px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 200px;
}

#sample-select option {
    background: #222;
    color: var(--text);
}

#btn-connect.connected {
    border-color: #5cb85c;
    color: #5cb85c;
}

/* ── Main ── */
#main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Segment table ── */
#segment-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    border-right: 1px solid var(--border);
    min-width: 0;
}

/* Thin scrollbar */
#segment-list::-webkit-scrollbar { width: 4px; }
#segment-list::-webkit-scrollbar-track { background: transparent; }
#segment-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#workout-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#workout-table th {
    text-align: left;
    padding: 6px 10px;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
}

#workout-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#workout-table tr.past td { opacity: 0.3; }

#workout-table tr.current {
    background: rgba(255,255,255,0.05);
}

#workout-table tr.current td:nth-child(1) {
    border-left: 3px solid #e0e0e0;
    padding-left: 7px;
}

.effort-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.effort-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Rings panel ── */
#rings {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
}

.ring-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ring-centre {
    position: absolute;
    text-align: center;
    pointer-events: none;
    user-select: none;
}

.ring-label {
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.ring-effort {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.ring-effort.small {
    font-size: 1.5rem;
}

.ring-rpm {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.ring-countdown {
    font-size: 1.6rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.ring-countdown.small {
    font-size: 1rem;
    color: var(--text-dim);
}

#next-label {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    text-transform: uppercase;
    align-self: flex-end;
    padding-right: 10px;
    margin-top: 4px;
}

/* ── Footer / progress bar ── */
#footer {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#progress-bar-container {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: var(--text);
    border-radius: 3px;
    transition: width 0.9s linear;
}

#time-remaining {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    min-width: 52px;
    text-align: right;
}
