:root {
  --bg: #f4efe6; --card: #fffdf8; --ink: #1d2a26; --muted: #7b7a72; --line: #e6dfd2;
  --green: #1f3d36; --accent: #e8835a; --him: #2f6f8f; --her: #c25a7c; --ok: #3d8b5f; --warn: #c9822b;
  --r: 16px; --num: 'Bricolage Grotesque', ui-rounded, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: #b3423a; min-height: 1em; }
h1, h2, h3 { margin: 0; letter-spacing: .01em; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); }
textarea { resize: vertical; min-height: 70px; }
.btn { white-space: nowrap; border: 0; border-radius: 12px; padding: 10px 16px; background: #ebe4d6; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--green); color: #f4efe6; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; padding: 13px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; }
.login-card h1 { font-family: var(--num); font-size: 34px; }
.logo-mark { width: 74px; height: 74px; margin: 0 auto 6px; border-radius: 22px; background: var(--green); position: relative; }
.logo-mark::before, .logo-mark::after { content: ''; position: absolute; top: 24px; width: 10px; height: 26px; border-radius: 3px; background: var(--bg); }
.logo-mark::before { left: 12px; } .logo-mark::after { right: 12px; }
.logo-mark span { position: absolute; left: 22px; right: 22px; top: 33px; height: 8px; border-radius: 3px; background: var(--accent); }

/* shell */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px; background: rgba(244, 239, 230, .92); backdrop-filter: blur(10px); }
.brand { font-family: var(--num); font-weight: 800; font-size: 20px; color: var(--green); }
.brand small { font-size: 10px; letter-spacing: .25em; color: var(--accent); margin-left: 8px; font-weight: 700; }
.avatar { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; border: 0; color: #fff; font-weight: 700; cursor: pointer; }
main { max-width: 760px; margin: 0 auto; padding: 4px 14px calc(96px + var(--safe-b)); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
.tabs a { flex: 1; text-align: center; color: var(--muted); text-decoration: none; font-size: 11.5px; padding: 2px 0; }
.tabs a i { display: block; font-style: normal; font-size: 19px; line-height: 1.2; }
.tabs a.on { color: var(--green); font-weight: 700; }
.tabs a.on i { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 12px 0; }
.card h3 { font-size: 16px; }
.section-title { font-size: 12px; letter-spacing: .14em; color: var(--muted); font-weight: 700; margin: 18px 4px 6px; text-transform: uppercase; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #ece5d7; }
.pill.him { background: color-mix(in srgb, var(--him) 14%, white); color: var(--him); }
.pill.her { background: color-mix(in srgb, var(--her) 14%, white); color: var(--her); }
.pill.done { background: color-mix(in srgb, var(--ok) 16%, white); color: var(--ok); }
.pill.active { background: color-mix(in srgb, var(--warn) 16%, white); color: var(--warn); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot.him { background: var(--him); } .dot.her { background: var(--her); }

/* date strip */
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
.strip::-webkit-scrollbar { display: none; }
.dchip { flex: 0 0 52px; text-align: center; border-radius: 14px; padding: 6px 0 7px; background: var(--card); border: 1px solid var(--line); cursor: pointer; scroll-snap-align: center; }
.dchip .w { font-size: 11px; color: var(--muted); }
.dchip .d { font-family: var(--num); font-weight: 700; font-size: 19px; line-height: 1.2; }
.dchip .marks { display: flex; gap: 3px; justify-content: center; height: 8px; margin-top: 2px; }
.dchip .marks span { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid; }
.dchip .marks .him { border-color: var(--him); } .dchip .marks .her { border-color: var(--her); }
.dchip .marks .fill.him { background: var(--him); } .dchip .marks .fill.her { background: var(--her); }
.dchip.sel { background: var(--green); color: #fff; border-color: var(--green); }
.dchip.sel .w { color: #cfd9d4; }
.dchip.today:not(.sel) { border-color: var(--accent); }

.hero { padding: 16px; border-radius: var(--r); background: var(--green); color: #f4efe6; margin-top: 6px; }
.hero h2 { font-family: var(--num); font-size: 24px; }
.hero .focus { color: #cfe0d8; margin-top: 2px; }
.hero .notes { font-size: 13.5px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.14); color: #e8efe9; }

.seg { display: flex; background: #e9e2d3; border-radius: 12px; padding: 3px; margin: 12px 0 0; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* equipment */
.equip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.eq { background: #f8f4ec; border-radius: 12px; padding: 9px 10px; cursor: pointer; border: 1px solid transparent; }
.eq:active { border-color: var(--line); }
.eq b { display: block; font-size: 14px; }
.eq .who { font-size: 12px; line-height: 1.55; margin-top: 3px; }
.eq .who span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eq .who .h { color: var(--him); } .eq .who .s { color: var(--her); }

/* exercise logging */
.ex { padding: 0; overflow: hidden; }
.ex-head { padding: 13px 14px 8px; display: flex; gap: 10px; align-items: flex-start; }
.ex-num { flex: 0 0 26px; height: 26px; border-radius: 8px; background: #efe8da; display: grid; place-items: center; font-family: var(--num); font-weight: 700; font-size: 14px; }
.ex.complete .ex-num { background: var(--ok); color: #fff; }
.ex-title { font-weight: 700; font-size: 16.5px; }
.ex-title small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.target { font-family: var(--num); font-weight: 600; color: var(--green); font-size: 14.5px; }
.meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.meta.seat { color: var(--him); }
.info-btn { margin-left: auto; flex: 0 0 auto; border: 1.5px solid var(--line); background: transparent; border-radius: 99px; width: 30px; height: 30px; cursor: pointer; color: var(--muted); font-weight: 700; }
.sets { padding: 0 10px 10px; }
.set { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 11px; font-variant-numeric: tabular-nums; }
.set + .set { border-top: 1px dashed var(--line); border-radius: 0; }
.set .no { width: 38px; font-size: 12px; color: var(--muted); }
.set.logged .val { font-family: var(--num); font-weight: 700; font-size: 17px; }
.set.logged .chk { color: var(--ok); font-weight: 800; }
.set.planned { color: #b8b3a6; }
.set.planned .val { font-family: var(--num); font-size: 15px; }
.set.input { background: #f8f4ec; border: 1.5px solid var(--accent) !important; border-radius: 12px; margin: 4px 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; background: #fff; border: 1.5px solid var(--line); border-radius: 11px; overflow: hidden; }
.step button { border: 0; background: transparent; width: 32px; height: 40px; font-size: 18px; color: var(--green); cursor: pointer; }
.step input { border: 0; width: 56px; text-align: center; padding: 6px 0; font-family: var(--num); font-weight: 700; font-size: 18px; border-radius: 0; }
.step .u { font-size: 11px; color: var(--muted); padding-right: 6px; }
.log-btn { margin-left: auto; background: var(--accent); color: #fff; border: 0; border-radius: 11px; height: 42px; padding: 0 16px; font-weight: 700; cursor: pointer; }
.x { border: 0; background: transparent; color: #c0b9ab; font-size: 16px; cursor: pointer; padding: 4px 6px; margin-left: auto; }
.add-set { margin: 2px 6px 4px; font-size: 13px; color: var(--green); background: none; border: 0; cursor: pointer; font-weight: 600; }

.finish { position: relative; margin-top: 16px; }
.done-banner { text-align: center; padding: 18px; }
.done-banner .big { font-family: var(--num); font-size: 30px; font-weight: 800; color: var(--ok); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat { background: #f8f4ec; border-radius: 12px; padding: 9px; text-align: center; }
.stat b { display: block; font-family: var(--num); font-size: 21px; }
.stat span { font-size: 11.5px; color: var(--muted); }

/* plan */
.pday { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pday:last-child { border-bottom: 0; }
.pday.past { opacity: .55; }
.pday.today { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.pday .date { font-family: var(--num); font-weight: 700; font-size: 17px; line-height: 1.15; }
.pday .date small { display: block; font-family: inherit; font-weight: 500; font-size: 11.5px; color: var(--muted); }
.pday .who { font-size: 13.5px; display: flex; gap: 6px; align-items: baseline; }
.pday .who + .who { margin-top: 2px; }
.pday .who .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; background: #fbf8f2; }
.edit-item .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.edit-item label { font-size: 11px; color: var(--muted); display: block; }
.edit-item input, .edit-item select { padding: 7px 8px; border-radius: 9px; }

/* coach */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 130px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.msg.user { align-self: flex-end; background: var(--green); color: #f4efe6; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; white-space: normal; }
.msg.assistant p { margin: 0 0 6px; } .msg.assistant p:last-child { margin: 0; }
.msg.assistant ul { margin: 4px 0 6px; padding-left: 20px; }
.msg.assistant h4 { margin: 8px 0 3px; font-size: 14.5px; color: var(--green); }
.proposal { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.proposal table { width: 100%; border-collapse: collapse; font-size: 13px; }
.proposal td { padding: 4px 3px; border-bottom: 1px solid #f0eadf; vertical-align: top; }
.proposal td.n { font-family: var(--num); font-weight: 600; white-space: nowrap; text-align: right; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(58px + var(--safe-b)); z-index: 4; padding: 8px 12px; background: linear-gradient(transparent, var(--bg) 22%); }
.composer .inner { max-width: 760px; margin: 0 auto; }
.composer .quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.composer .quick button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; }
.composer textarea { min-height: 44px; max-height: 120px; border-radius: 14px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 4px 8px; }
.typing::after { content: '…'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* progress */
.prog-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.prog-row:last-child { border-bottom: 0; }
.prog-row .best { font-family: var(--num); font-weight: 700; font-size: 14px; text-align: right; line-height: 1.35; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12.5px; margin-top: 6px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.hist th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; padding: 4px; }
table.hist td { padding: 6px 4px; border-top: 1px solid var(--line); }

/* machines */
.mach h3 { display: flex; gap: 8px; align-items: baseline; }
.mach dl { margin: 8px 0 0; font-size: 13.5px; }
.mach dt { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.mach dd { margin: 1px 0 0; }

/* modal / toast / rest */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20, 28, 25, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(22px + var(--safe-b)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet h2 { font-family: var(--num); font-size: 22px; margin-bottom: 8px; }
.sheet label.f { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.scale { display: flex; gap: 5px; }
.scale button { flex: 1; border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 0; font-family: var(--num); font-weight: 700; cursor: pointer; }
.scale button.on { background: var(--green); color: #fff; border-color: var(--green); }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 60px); transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 99px; font-size: 14px; max-width: 90vw; }
.rest { position: fixed; z-index: 7; left: 50%; transform: translateX(-50%); bottom: calc(66px + var(--safe-b)); background: var(--ink); color: #fff; border-radius: 99px; padding: 6px 8px 6px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.rest b { font-family: var(--num); font-size: 22px; min-width: 52px; text-align: center; }
.rest .rest-label { font-size: 12px; color: #b8c4bf; }
.rest button { border: 0; border-radius: 99px; background: #34433e; color: #fff; padding: 6px 11px; font-size: 13px; cursor: pointer; }
.rest.over b { color: var(--accent); }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
@media (min-width: 700px) { .sheet { border-radius: 22px; margin-bottom: 4vh; } .modal { align-items: center; } }

/* media */
.pics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 0; }
.pics figure { margin: 0; }
.pics img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 12px; display: block; background: #e9e2d3; }
.pics figcaption { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 2px; }
.vids { display: grid; gap: 8px; }
.vid { display: flex; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 7px; cursor: pointer; align-items: center; }
.vthumb { position: relative; flex: 0 0 132px; aspect-ratio: 16/9; border-radius: 9px; background: #2a3632 center/cover; }
.vthumb .play { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%; background: rgba(232,131,90,.92); color: #fff; display: grid; place-items: center; font-size: 13px; padding-left: 2px; }
.vthumb .len, .vthumb .bili { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.72); color: #fff; font-size: 10.5px; padding: 0 5px; border-radius: 4px; }
.vthumb .bili { left: 4px; right: auto; background: #fb7299; }
.vmeta { min-width: 0; }
.vt { font-size: 13.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vid.playing { display: block; padding: 0; overflow: hidden; }
.vid.playing iframe { width: 100%; aspect-ratio: 16/9; border: 0; display: block; }
.mach { position: relative; }
.mthumb { float: right; width: 84px; height: 56px; object-fit: cover; border-radius: 9px; margin-left: 10px; }
.vcount { margin-bottom: 4px; background: var(--accent); color: #fff; font-size: 11px; }
.info-btn.tut { width: auto; padding: 0 10px; font-size: 12px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, white); }
.msg .tbl { overflow-x: auto; margin: 6px 0; }
.msg table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.msg th, .msg td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: top; }
.msg th { color: var(--green); white-space: nowrap; }
.msg h4 + .tbl { margin-top: 2px; }
