:root {
  --bg: #0F1115;
  --surface: #1A1D24;
  --surface-2: #23262F;
  --surface-dim: #141720;
  --line: #2A2E38;
  --line-dim: #1F232C;
  --text: #F3F4F6;
  --text-2: #D1D5DB;
  --muted: #9CA3AF;
  --muted-2: #6B7280;
  --accent: #C8F04A;
  --accent-2: #F0A64A;
  --ok: #4ADE80;
  --warn: #F0A64A;
  --danger: #F87171;
  --yt: #FF4D4D;
  --radius: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.4;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; }
.display { font-family: 'Barlow Condensed', Inter, sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; line-height: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .danger { color: var(--danger); }

#app { min-height: 100vh; min-height: 100dvh; }
.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding-top: var(--sat); }
.screen.center { justify-content: center; padding: 28px; }
.screen.has-nav { padding-bottom: calc(84px + var(--sab)); }
.content { padding: 0 20px 24px; display: flex; flex-direction: column; gap: 12px; flex-grow: 1; }

.spinner { width: 32px; height: 32px; margin: 0 auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* header */
.header { padding: 20px 20px 14px; display: flex; align-items: center; gap: 12px; }
.header .title-block { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.header h1 { font-size: 28px; }
.header .sub { color: var(--muted); font-size: 12px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--text); flex-shrink: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.avatar { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 20px; color: var(--bg); flex-shrink: 0; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 18px; border-radius: 14px; font-weight: 600; font-size: 15px; width: 100%; }
.btn.primary { background: var(--accent); color: var(--bg); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px dashed #3B4150; font-weight: 500; font-size: 14px; }
.btn.ghost.accent { color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #3B2A2A; }
.btn.sm { height: 42px; font-size: 14px; }
.btn.square { width: 52px; padding: 0; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; }
.btn svg { width: 18px; height: 18px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex-grow: 1; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.hero { background: var(--accent); color: var(--bg); border: 0; border-radius: 20px; padding: 20px; gap: 14px; cursor: pointer; }
.card.hero .label { color: var(--bg); opacity: 0.85; }
.card.hero h2 { font-size: 30px; }
.card.hero .play { width: 44px; height: 44px; border-radius: 14px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.card.hero .play svg { width: 18px; height: 18px; fill: var(--accent); }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); width: 100%; text-align: left; color: var(--text); }
.list-item .li-main { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 15px; }
.list-item .li-sub { color: var(--muted); font-size: 12px; }
.list-item .li-sub.ok { color: var(--ok); }
.list-item .badge { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 14px; color: var(--accent); flex-shrink: 0; }
.list-item .chev { color: var(--muted); flex-shrink: 0; }
.list-item .chev svg { width: 20px; height: 20px; }
.list-item.profile { padding: 18px; }
.list-item.profile .avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 26px; }
.list-item.profile .li-title { font-size: 18px; }
.split { display: flex; gap: 0; }
.split .list-item { border-radius: var(--radius) 0 0 var(--radius); border-right: 0; }
.split .icon-btn { height: auto; width: 52px; border-radius: 0 var(--radius) var(--radius) 0; border: 1px solid var(--line); border-left: 1px solid var(--line-dim); background: var(--surface); color: var(--muted); }

/* week strip */
.week { padding: 0 20px 8px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; border-radius: 12px; background: var(--surface); color: var(--text); }
.week a .d { font-size: 11px; color: var(--muted); }
.week a .n { font-weight: 600; font-size: 15px; }
.week a .dot { width: 6px; height: 6px; border-radius: 3px; background: #3B4150; }
.week a .dot.has { background: var(--accent); }
.week a .dot.done { background: var(--ok); }
.week a.today { background: var(--accent); color: var(--bg); }
.week a.today .d { color: var(--bg); font-weight: 600; }
.week a.today .dot { background: var(--bg); }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 12px calc(14px + var(--sab)); border-top: 1px solid var(--line-dim); background: var(--bg); z-index: 20; max-width: 560px; margin: 0 auto; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.nav a.active { color: var(--accent); }
.nav a svg { width: 22px; height: 22px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 8px; }
.input { width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted-2); }
.input.center { text-align: center; font-weight: 600; font-size: 18px; padding: 0 8px; }
.input.sm { height: 42px; font-size: 14px; }
textarea.input { height: auto; padding: 12px 14px; resize: vertical; min-height: 80px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 13px; }
.chip.on { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.days button { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; }
.days button.on { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.err { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; }
.swatches { display: flex; gap: 10px; }
.swatches button { width: 40px; height: 40px; border-radius: 12px; border: 3px solid transparent; }
.swatches button.on { border-color: #fff; }

/* workout day */
.progress { margin: 0 20px 14px; height: 6px; border-radius: 3px; background: var(--line-dim); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s; }
.timer-chip { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text); flex-shrink: 0; }
.timer-chip svg { width: 16px; height: 16px; color: var(--muted); }
.timer-chip.on { border-color: var(--accent); color: var(--accent); }
.timer-chip.on svg { color: var(--accent); }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); width: 100%; text-align: left; color: var(--text); }
.item.done { background: var(--surface-dim); border-color: var(--line-dim); opacity: 0.65; }
.item.done .item-name { text-decoration: line-through; }
.item .check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid #3B4150; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.item.done .check, .item.open.is-done .check { background: var(--ok); border-color: var(--ok); }
.item .check svg { width: 14px; height: 14px; stroke: var(--bg); }
.item-main { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; }
.item-sub { color: var(--muted); font-size: 12px; }
.item .yt { color: var(--muted); flex-shrink: 0; }
.item .yt svg { width: 18px; height: 18px; }
.item.open { flex-direction: column; align-items: stretch; gap: 14px; border-color: var(--accent); padding: 16px; }
.item.open .item-head { display: flex; align-items: flex-start; gap: 12px; width: 100%; }
.item.open .item-name { font-size: 17px; }
.video-btn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-align: left; width: 100%; }
.video-btn .thumb { width: 72px; height: 44px; border-radius: 8px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.video-btn .thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-btn .thumb svg { width: 18px; height: 18px; fill: var(--yt); }
.video-btn b { display: block; font-size: 13px; }
.video-btn span { font-size: 11px; color: var(--muted); }
.load-row { display: flex; align-items: center; gap: 8px; }
.load-row .stepper { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 22px; flex-shrink: 0; }
.load-box { flex-grow: 1; display: flex; align-items: center; justify-content: center; gap: 4px; height: 48px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); padding: 0 12px; }
.load-box input { width: 90px; background: transparent; border: 0; color: var(--accent); font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 32px; text-align: right; outline: none; }
.load-box span { color: var(--muted); font-size: 14px; }
.delta { display: flex; align-items: center; gap: 6px; font-size: 12px; min-height: 16px; }
.delta svg { width: 14px; height: 14px; }
.note-row { display: flex; flex-direction: column; gap: 6px; }
.item .meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.footer { position: sticky; bottom: 0; padding: 12px 20px calc(18px + var(--sab)); background: var(--bg); border-top: 1px solid var(--line-dim); display: flex; gap: 10px; }

/* editor */
.ed-item { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.ed-item .ed-top { display: flex; align-items: center; gap: 8px; }
.ed-item .ed-name { font-weight: 600; font-size: 15px; flex-grow: 1; min-width: 0; }
.ed-item .mini { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ed-item .mini svg { width: 16px; height: 16px; }
.ed-item .mini.del { color: var(--danger); }
.ed-item .mini:disabled { opacity: 0.3; }
.ed-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ed-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--muted); letter-spacing: 0.5px; text-transform: uppercase; }
.ed-fields input { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-align: center; font-weight: 600; font-size: 15px; outline: none; width: 100%; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0; }
.modal { background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + var(--sab)); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-size: 24px; }
.modal-bg.video { align-items: center; padding: 16px; }
.modal.video-box { padding: 0; border-radius: 16px; background: #000; overflow: hidden; max-height: none; }
.video-frame { position: relative; width: 100%; padding-top: 56.25%; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.picker-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.picker-list .list-item { padding: 12px 14px; }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.hist { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-dim); }
.hist:last-child { border-bottom: 0; }
.hist b { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 22px; color: var(--accent); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.stat b { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 26px; color: var(--accent); }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* misc */
.empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 14px; line-height: 1.6; }
.logo { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.logo svg { width: 40px; height: 40px; stroke: var(--bg); }
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--sab)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: 0.25s; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details summary::-webkit-details-marker { display: none; }
details p { margin: 10px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
