/* Components: dashboard tiles, roster table, week calendar, chat, modals, AI cards, runner cards. */

/* lists of clickable rows */
.list{display:flex;flex-direction:column}
.item{display:flex;gap:12px;align-items:flex-start;justify-content:space-between;padding:10px 0;border-top:1px solid var(--line);cursor:pointer;background:none;border-inline:0;border-bottom:0;text-align:start;width:100%}
.item:first-child{border-top:0}
.item:hover .who{color:var(--accent)}
.item .who{font-weight:600}
.item .what{color:var(--muted);font-size:.88rem;overflow-wrap:anywhere}
.item > div{min-width:0}

/* dashboard stat tiles */
.tiles{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
@media (max-width:760px){.tiles{grid-template-columns:repeat(2,minmax(0,1fr))}}
.tile{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:14px 16px;cursor:pointer;text-align:start;display:flex;flex-direction:column;gap:2px}
.tile:hover{border-color:var(--muted)}
.tile .v{font-family:var(--font-data);font-size:1.9rem;line-height:1.1;direction:ltr;text-align:end;unicode-bidi:isolate}
.tile .l{font-size:.85rem;color:var(--muted)}
.tile.crit .v{color:var(--crit)}.tile.warn .v{color:var(--warn)}.tile.good .v{color:var(--good)}

/* AI strip on the dashboard */
.ai-strip{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;border:1px solid var(--accent);background:var(--accent-soft);border-radius:var(--r);padding:14px 18px}
.ai-strip p{max-width:62ch}
.ai-mark{font-family:var(--font-data);font-size:.72rem;letter-spacing:.06em;border:1px solid currentColor;border-radius:4px;padding:0 5px;color:var(--accent)}

/* roster table */
.tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:var(--r);background:var(--surface)}
table{border-collapse:collapse;width:100%;min-width:760px}
th,td{text-align:start;padding:10px 14px;border-bottom:1px solid var(--line);vertical-align:middle}
th{font-size:.75rem;letter-spacing:.06em;color:var(--muted);font-weight:600;background:var(--surface-2)}
tr:last-child td{border-bottom:0}
tbody tr{cursor:pointer}
tbody tr:hover td{background:var(--surface-2)}
.bar{height:6px;background:var(--surface-2);border-radius:99px;overflow:hidden;min-width:90px}
.bar > i{display:block;height:100%;background:var(--good);border-radius:99px}
.search{border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:8px 12px;min-width:0;width:240px;max-width:100%}

/* athlete header */
.ahead{display:flex;flex-wrap:wrap;gap:18px;justify-content:space-between;align-items:flex-start}
.ahead .facts{display:flex;flex-wrap:wrap;gap:6px 20px;margin-top:8px;font-size:.9rem;color:var(--muted)}
.ahead .facts b{color:var(--ink);font-weight:600}
.paces{display:flex;gap:6px;flex-wrap:wrap}
.pace{border:1px solid var(--line);border-radius:8px;padding:4px 10px;display:flex;flex-direction:column;align-items:center;min-width:72px;background:var(--surface)}
.pace small{font-size:.72rem;color:var(--muted)}

/* week calendar */
.weeknav{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px}
.week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:8px}
@media (max-width:1000px){.week{grid-template-columns:minmax(0,1fr)}}
.day{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:10px;display:flex;flex-direction:column;gap:8px;min-height:150px;min-width:0}
.day.is-today{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.day.drop-on{border-color:var(--accent);background:var(--accent-soft)} /* a workout is being dragged over this day */
.wo[draggable="true"]{cursor:grab}
.day-h{display:flex;justify-content:space-between;align-items:baseline;font-size:.82rem;color:var(--muted);font-weight:600}
.is-today .day-h{color:var(--accent)}
@media (max-width:1000px){.day{min-height:0}}
.wo{border:1px solid var(--line);border-radius:8px;padding:8px;background:var(--bg);cursor:pointer;text-align:start;display:flex;flex-direction:column;gap:3px;width:100%}
.wo:hover{border-color:var(--muted)}
.wo .t{font-weight:600;font-size:.9rem;overflow-wrap:anywhere}
.wo .m{font-size:.8rem;color:var(--muted)}
.wo.st-missed{border-color:var(--crit);background:var(--crit-soft)}
.wo.st-done{background:var(--surface)}
.add-wo{border:1px dashed var(--line);background:none;border-radius:8px;padding:5px;color:var(--muted);cursor:pointer;font-size:.82rem;margin-top:auto}
.add-wo:hover{color:var(--accent);border-color:var(--accent)}
/* building a week: the empty-week card, and the assistant's draft (dashed until the coach takes each workout) */
.build-card{display:flex;flex-direction:column;gap:12px;padding:18px;border:1px solid var(--line);border-radius:var(--r);background:var(--surface)}
.build-card .f{max-width:520px}
.draft-bar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;border:1.5px dashed var(--accent);border-radius:var(--r);background:var(--accent-soft)}
.draft-why{flex-basis:100%;font-size:.88rem}
.draft-why summary{cursor:pointer;color:var(--accent);font-weight:600}
.draft-why p{margin-top:6px}
.wo.draft{border:1.5px dashed var(--accent);background:var(--accent-soft);cursor:default}
.wo.draft:hover{border-color:var(--accent)}
.wo.draft .desc{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.draft-acts{gap:6px;margin-top:4px}
.draft-acts .btn{flex:1;justify-content:center;min-height:36px}

/* chat (coach-runner and ask-the-assistant) */
.chat{display:flex;flex-direction:column;height:min(560px,70vh);border:1px solid var(--line);border-radius:var(--r);background:var(--surface);overflow:hidden}
.chat-log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:8px}
.msg{max-width:78%;padding:8px 12px;border-radius:12px;background:var(--surface-2);overflow-wrap:anywhere;white-space:pre-wrap}
.msg.mine{align-self:flex-end;background:var(--accent);color:var(--accent-ink)}
.msg time{display:block;font-size:.72rem;opacity:.7;margin-top:2px}
.msg.ai{background:var(--accent-soft);color:var(--ink);white-space:normal}
.chat-form{display:flex;gap:8px;padding:10px;border-top:1px solid var(--line)}
.chat-form textarea{flex:1;resize:none;border:1px solid var(--line);border-radius:8px;padding:8px 10px;background:var(--bg);min-width:0;height:44px}
.suggest-q{display:flex;flex-wrap:wrap;gap:6px}

/* report form: RPE scale */
.rpe{display:grid;grid-template-columns:repeat(10,minmax(0,1fr));gap:4px;direction:ltr}
.rpe button{border:1px solid var(--line);background:var(--surface);border-radius:6px;padding:6px 0;cursor:pointer;font-family:var(--font-data)}
.rpe button[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}

/* modal */
.scrim{position:fixed;inset:0;background:rgb(10 16 14 / .45);display:flex;align-items:flex-start;justify-content:center;padding:max(24px,env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) 24px max(16px,env(safe-area-inset-left,0px));overflow-y:auto;z-index:20}
.modal{background:var(--surface);border-radius:14px;border:1px solid var(--line);width:min(640px,100%);padding:22px;display:flex;flex-direction:column;gap:16px;margin-block:auto}
.modal-foot{display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between}
.kv{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 14px;font-size:.92rem}
.kv dt{color:var(--muted)}
.kv dd{margin:0;overflow-wrap:anywhere}

/* AI output and suggestions */
.ai-out{font-size:.94rem;line-height:1.65;overflow-wrap:anywhere}
.ai-out ul{margin:4px 0 8px;padding-inline-start:20px}
.ai-out p{margin:0 0 6px}
.ai-out h4{margin:8px 0 2px;font-size:.95rem}
.thinking{color:var(--muted);font-style:italic}
.sugg{border:1px solid var(--line);border-radius:var(--r);background:var(--surface);padding:16px;display:flex;flex-direction:column;gap:12px}
.change{display:grid;grid-template-columns:auto minmax(0,1fr);gap:10px;align-items:start;padding:10px 0;border-top:1px solid var(--line)}
.change input{margin-top:4px;width:16px;height:16px}
.change .why{font-size:.85rem;color:var(--muted)}
.op{font-size:.72rem;font-weight:700;border-radius:4px;padding:0 6px}
.op.add{background:var(--good-soft);color:var(--good)}.op.update{background:var(--warn-soft);color:var(--warn)}.op.remove{background:var(--crit-soft);color:var(--crit)}
.arrow{color:var(--muted);padding:0 4px}

/* runner's today card and metrics */
.today-card{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:20px;display:flex;flex-direction:column;gap:12px}
.today-card .big{font-family:var(--font-display);font-size:1.6rem;line-height:1.2}
.metrics{display:flex;flex-wrap:wrap;gap:8px 24px}
.metric{display:flex;flex-direction:column}
.metric small{color:var(--muted);font-size:.78rem}
.metric b{font-family:var(--font-data);font-size:1.25rem;font-weight:500}
.chart{width:100%;height:auto;display:block}

/* toast */
.toast{position:fixed;bottom:calc(20px + env(safe-area-inset-bottom,0px));left:50%;transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:8px;z-index:30;max-width:calc(100% - 32px);font-size:.9rem}
.toast.crit{background:var(--crit);color:#fff}

@media (prefers-reduced-motion:no-preference){.thinking{animation:pulse 1.4s ease-in-out infinite}@keyframes pulse{50%{opacity:.45}}}
/* training zones table */
.zones td,.zones th{white-space:nowrap}
.zchip{display:inline-block;min-width:2.2em;text-align:center;border-radius:6px;padding:1px 6px;font-family:var(--font-data);font-size:.82rem;color:var(--ink);background:var(--surface-2);border-inline-start:4px solid var(--line)}
.zchip.z1{border-color:var(--t-rest)}.zchip.z2{border-color:var(--t-easy)}.zchip.z3{border-color:var(--t-strength)}.zchip.z4{border-color:var(--t-tempo)}.zchip.z5{border-color:var(--t-interval)}
.zones-edit summary{cursor:pointer;color:var(--accent);font-weight:600;font-size:.9rem}
.zones-edit .form{margin-top:10px}
/* fitness / fatigue chart */
.loadchart{display:flex;flex-direction:column;gap:8px;margin-top:12px}
.lc-legend{display:flex;gap:16px;font-size:.85rem;color:var(--muted)}
.lc-legend i{display:inline-block;width:14px;height:3px;border-radius:2px;vertical-align:middle;margin-inline-end:6px}
.lc-wrap{position:relative}
.lc-plot{width:100%;height:auto;display:block;touch-action:pan-y}
.lc-grid{stroke:var(--line);stroke-width:1}
.lc-ax{fill:var(--muted);font-size:11px;font-family:var(--font-data)}
.lc-line{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.lc-end{fill:var(--muted);font-size:11px;font-family:var(--font-body)}
.lc-cross{stroke:var(--muted);stroke-width:1;stroke-dasharray:3 3}
.lc-tip{position:absolute;top:-6px;background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:4px 10px;font-size:.82rem;color:var(--ink);white-space:nowrap;pointer-events:none;box-shadow:0 2px 8px rgb(0 0 0 / .08)}
/* workout builder: blocks, each step one row; a repeated set is a framed group */
.sb{display:flex;flex-direction:column;gap:8px;padding:12px;border:1px solid var(--line);border-radius:var(--r);background:var(--surface-2)}
.sb-head{display:flex;flex-direction:column;gap:2px}
.sb-step{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:8px;border-radius:8px;background:var(--surface);border-inline-start:4px solid var(--t-easy)}
.sb-step.k-warmup,.sb-step.k-cooldown{border-color:var(--t-rest)}.sb-step.k-recovery{border-color:var(--line)}
.sb-step.k-tempo{border-color:var(--t-tempo)}.sb-step.k-interval{border-color:var(--t-interval)}.sb-step.k-long{border-color:var(--t-long)}
.sb-step select,.sb-step input{width:auto;min-width:0}
.sb-amt{width:5.5em!important}.sb-n{width:3.5em!important}
.sb-res{color:var(--muted);flex-basis:100%;order:10}
.sb-btns{display:inline-flex;gap:2px;margin-inline-start:auto}
.sb-rep{display:flex;flex-direction:column;gap:6px;padding:8px;border:1.5px dashed var(--t-interval);border-radius:var(--r)}
.sb-rep-h{display:flex;align-items:center;gap:8px}
