:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #2c3338;
  --muted: #6b7680;
  --line: #e4e0d6;
  --brand: #3f7d52;
  --brand-soft: #e3efe6;
  --accent: #c97b3c;
  --outdoor: #3f7d52;
  --indoor: #5a7da0;
  --screen: #9b6bae;
  --personal: #b0905a;
  --danger: #b3493f;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 8px;
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-mark { font-size: 1.4rem; }
.brand-name { color: var(--brand); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  overflow-x: auto;
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .95rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--bg); }
.tab.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* Content */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 18px 64px;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.view-head h1 { font-size: 1.5rem; margin: 0; }
.view-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .92rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e6c4c0; }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 1.1rem; color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* Cards / grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card .meta { color: var(--muted); font-size: .85rem; }
.card-actions { display: flex; gap: 6px; margin-top: 12px; }

.tag {
  display: inline-block;
  font-size: .74rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  margin: 2px 3px 0 0;
}
.tag.skill { background: var(--brand-soft); border-color: #cfe2d4; color: #2f5e3d; }
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; }
.set-outdoor { background: var(--outdoor); }
.set-indoor { background: var(--indoor); }
.set-screen { background: var(--screen); }
.set-personal { background: var(--personal); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

/* Forms */
.field { margin-bottom: 14px; }
.field label { display:block; font-weight:600; font-size:.88rem; margin-bottom:5px; }
.field input[type=text], .field input[type=number], .field input[type=date],
.field input[type=time], .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: .95rem; font-family: inherit; background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.checks { display:flex; flex-wrap:wrap; gap:6px; }
.check-pill {
  display:inline-flex; align-items:center; gap:6px;
  padding: 6px 10px; border:1px solid var(--line); border-radius:999px;
  font-size:.85rem; cursor:pointer; user-select:none;
}
.check-pill input { margin:0; }
.check-pill.on { background: var(--brand-soft); border-color:#cfe2d4; color:#2f5e3d; }
.hint { color: var(--muted); font-size:.82rem; margin-top:4px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,24,28,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { display:flex; align-items:center; justify-content:space-between; padding: 16px 18px; border-bottom:1px solid var(--line); }
.modal-head h2 { margin:0; font-size:1.15rem; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display:flex; justify-content:flex-end; gap:8px; padding: 14px 18px; border-top:1px solid var(--line); }

/* Today view */
.meter {
  background: var(--surface); border:1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.meter h3 { margin:0 0 10px; font-size:1rem; }
.meter-bar { display:flex; height:22px; border-radius:999px; overflow:hidden; background:var(--bg); }
.meter-seg { height:100%; }
.meter-legend { display:flex; gap:16px; margin-top:10px; flex-wrap:wrap; font-size:.82rem; color:var(--muted); }

.timeline { display:flex; flex-direction:column; gap:10px; }
.slot-row {
  display:flex; gap:14px; align-items:stretch;
  background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.slot-row.done { opacity:.6; }
.slot-time { font-weight:700; min-width:74px; color:var(--ink); }
.slot-time small { display:block; font-weight:400; color:var(--muted); }
.slot-main { flex:1; }
.slot-main h4 { margin:0 0 3px; }
.slot-side { display:flex; flex-direction:column; gap:6px; align-items:flex-end; }

/* Planner grid */
.planner-controls { display:flex; gap:8px; align-items:center; margin-bottom:14px; flex-wrap:wrap; }
.week-scroll { overflow-x:auto; border:1px solid var(--line); border-radius: var(--radius); background:var(--surface); }
.week-grid { display:grid; grid-template-columns: 68px repeat(7, minmax(120px,1fr)); min-width:780px; }
.wg-cell { border-right:1px solid var(--line); border-bottom:1px solid var(--line); min-height:34px; padding:3px; }
.wg-cell.half { border-bottom-color:#eee; }
.wg-hour.half { color:#aab2b8; }
.wg-head { position:sticky; top:0; background:var(--surface); font-weight:600; text-align:center; padding:8px 4px; border-bottom:2px solid var(--line); font-size:.85rem; }
.wg-head.today { color:var(--brand); }
.wg-hour { font-size:.75rem; color:var(--muted); text-align:right; padding:4px 6px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); }
.wg-cell:hover { background: var(--brand-soft); cursor:pointer; }
.block {
  border-radius:6px; padding:3px 6px; font-size:.74rem; color:#fff; margin-bottom:2px;
  cursor:pointer; line-height:1.2;
}
.block.set-outdoor { background: var(--outdoor); }
.block.set-indoor { background: var(--indoor); }
.block.set-screen { background: var(--screen); }
.block.set-personal { background: var(--personal); }

/* Monthly focus */
.focus-banner {
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  margin-bottom:16px; border-left:4px solid var(--accent); flex-wrap:wrap;
}
.focus-banner h3 { margin:2px 0; font-size:1.15rem; }
.focus-eyebrow {
  font-size:.74rem; font-weight:700; letter-spacing:.04em;
  color:var(--accent); text-transform:uppercase;
}
.focus-acts { margin-top:8px; }
.focus-actions { display:flex; gap:6px; flex-shrink:0; }
.focus-chip {
  display:inline-block; background:var(--brand-soft); border:1px solid #cfe2d4;
  color:#2f5e3d; border-radius:999px; padding:8px 16px; font-size:.9rem; margin-bottom:16px;
}
.theme-chip { background:#e8eef6; border-color:#cdd9e8; color:#33506e; margin-right:8px; }
.theme-banner { border-left-color: var(--indoor); }
.theme-banner .focus-eyebrow { color: var(--indoor); }

/* Month */
.month-grid { display:grid; grid-template-columns: repeat(7,1fr); gap:6px; }
.month-dow { text-align:center; font-size:.78rem; color:var(--muted); font-weight:600; padding:4px; }
.month-day {
  background:var(--surface); border:1px solid var(--line); border-radius:8px;
  min-height:74px; padding:6px; cursor:pointer;
}
.month-day:hover { border-color: var(--brand); }
.month-day.other { opacity:.4; }
.month-day.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.month-day .dnum { font-size:.82rem; font-weight:600; }
.month-dots { display:flex; flex-wrap:wrap; gap:3px; margin-top:5px; }
.month-dots .dot { width:7px; height:7px; margin:0; }

/* Progress */
.prog-student { margin-bottom: 26px; }
.prog-bar-row { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
.prog-label { min-width:170px; font-size:.9rem; }
.prog-track { flex:1; background:var(--bg); border-radius:999px; height:14px; overflow:hidden; border:1px solid var(--line); }
.prog-fill { height:100%; background:var(--brand); }
.prog-count { min-width:90px; font-size:.82rem; color:var(--muted); text-align:right; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color:#fff; padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; box-shadow: var(--shadow); z-index: 80;
}
.toast.hidden { display:none; }

.maps-row { margin-top: 8px; }
.maps-row a { color: var(--brand); text-decoration: none; font-weight: 600; }
.maps-row a:hover { text-decoration: underline; }

.hidden { display: none; }

/* Auth / cloud sync */
.sync { font-size:.78rem; color:var(--muted); margin-left:10px; white-space:nowrap; }
#signout { margin-left:auto; }
.login-wrap { display:flex; justify-content:center; padding:40px 16px; }
.login-card { width:100%; max-width:380px; }

/* Settings — module toggles */
.mod-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 0; border-bottom:1px solid var(--line); font-weight:600; }
.mod-row:last-child { border-bottom:none; }
.mod-row input { width:18px; height:18px; cursor:pointer; }
.done-card { opacity:.62; }

/* Daily quote + Help */
.quote-card { background:var(--surface); border:1px solid var(--line); border-left:4px solid var(--accent); border-radius:var(--radius); padding:12px 16px; margin-bottom:16px; font-style:italic; color:var(--ink); box-shadow:var(--shadow); }
.help-sec { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); margin-bottom:10px; box-shadow:var(--shadow); overflow:hidden; }
.help-sec summary { padding:14px 16px; cursor:pointer; font-weight:700; font-size:1.02rem; list-style:none; }
.help-sec summary::-webkit-details-marker { display:none; }
.help-sec summary::after { content:"▸"; float:right; color:var(--muted); }
.help-sec[open] summary::after { content:"▾"; }
.help-body { padding:0 16px 14px; color:var(--ink); }
.help-body ul { margin:6px 0; padding-left:20px; }
.help-body li { margin:5px 0; }
.help-body p { margin:6px 0; }

/* Nutrition */
.nut-head { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.nut-head h3 { margin:0; }
.protein-badge { background:var(--brand-soft); color:#2f5e3d; border:1px solid #cfe2d4; border-radius:999px; padding:2px 10px; font-size:.8rem; font-weight:700; white-space:nowrap; }
.plain-list { list-style:none; padding:0; margin:8px 0 0; }
.plain-list li { padding:4px 0; border-bottom:1px solid var(--line); font-size:.9rem; }
.plain-list li:last-child { border-bottom:none; }
.food-pick-cat { font-weight:700; font-size:.8rem; color:var(--muted); margin:10px 0 4px; }

/* Daily Reset (core, on Today) */
.reset-card { margin-bottom: 18px; }
.reset-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.reset-head h3 { margin:0; font-size:1.05rem; }
.reset-right { display:flex; align-items:center; gap:8px; }
.streak { background:#fff3e0; color:#b5651d; border:1px solid #f0d8b8; border-radius:999px; padding:3px 10px; font-size:.82rem; font-weight:700; white-space:nowrap; }
.reset-list { display:flex; flex-direction:column; }
.reset-row { display:flex; align-items:flex-start; gap:10px; padding:8px 0; border-bottom:1px solid var(--line); cursor:pointer; }
.reset-row:last-child { border-bottom:none; }
.reset-row input { width:20px; height:20px; margin-top:1px; cursor:pointer; flex:0 0 auto; }
.reset-row span { display:flex; flex-direction:column; }
.reset-row small { color:var(--muted); font-size:.82rem; }
.reset-row.on b { text-decoration:line-through; color:var(--muted); font-weight:600; }
.reset-done { margin-top:10px; text-align:center; color:var(--brand); font-weight:600; }
.pin-card { margin-bottom:18px; border-left:4px solid var(--accent); }
#set-quotes { width:100%; box-sizing:border-box; min-height:160px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; font-family:inherit; font-size:.95rem; line-height:1.5; resize:vertical; }
.reset-erow { display:flex; gap:6px; align-items:center; margin-bottom:6px; flex-wrap:wrap; }
.reset-erow input { flex:1; min-width:120px; padding:6px 8px; border:1px solid var(--line); border-radius:8px; font-family:inherit; }
.re-move { display:flex; gap:2px; flex-shrink:0; }

/* Personal Trainer — weekly schedule + today banner */
.today-train { margin-bottom: 18px; border-left: 4px solid var(--brand); }
.sched-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:9px 0; border-bottom:1px solid var(--line); }
.sched-row:last-child { border-bottom:none; }
.sched-row span { font-weight:600; }
.sched-row.is-today span { color:var(--brand); }
.sched-row select { flex:0 0 auto; min-width:170px; max-width:60%; padding:7px 9px; border:1px solid var(--line); border-radius:8px; font-family:inherit; background:#fff; }

/* Personal Trainer — stats & history */
.t-stats { display:flex; gap:16px; align-items:center; flex-wrap:wrap; margin-bottom:14px; }
.t-stat { display:flex; flex-direction:column; align-items:center; min-width:60px; }
.t-stat-n { font-size:1.35rem; font-weight:800; color:var(--brand); line-height:1.1; }
.t-stat-l { font-size:.72rem; color:var(--muted); text-align:center; }
.t-stats #t-weigh { margin-left:auto; }
.wt-chart { width:100%; height:auto; display:block; margin-top:8px; }

/* Personal Trainer — plan editor */
.pe-row { padding:12px 14px; }
.pe-head { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.pe-move { display:flex; gap:2px; flex-shrink:0; }
.pe-fields { display:flex; flex-wrap:wrap; gap:10px; margin-top:8px; }
.pe-fields label { font-size:.78rem; color:var(--muted); display:flex; flex-direction:column; gap:3px; }
.pe-fields input { width:90px; padding:6px 8px; border:1px solid var(--line); border-radius:8px; font-family:inherit; }

/* Personal Trainer — guided player */
.video-wrap { position:relative; padding-bottom:56.25%; height:0; border-radius:var(--radius); overflow:hidden; margin:10px 0; background:#000; }
.video-wrap iframe { position:absolute; inset:0; width:100%; height:100%; border:0; }
.cues-list { margin:4px 0; padding-left:20px; }
.cues-list li { margin:4px 0; }
.set-label { font-size:1.1rem; font-weight:700; text-align:center; margin:4px 0 12px; }
.big-btn { display:block; width:100%; padding:16px; font-size:1.1rem; font-weight:700; border:none; border-radius:12px; background:var(--brand); color:#fff; cursor:pointer; }
.big-btn:hover { filter:brightness(1.05); }
.timer { font-size:2.6rem; font-weight:800; text-align:center; color:var(--brand); margin:8px 0; font-variant-numeric:tabular-nums; }
.quick-row { display:flex; gap:10px; }
.quick-row .btn { flex:1; }
.form label { display:block; margin-bottom:10px; font-size:.85rem; color:var(--muted); }
.form input { width:100%; padding:9px 10px; border:1px solid var(--line); border-radius:8px; font-family:inherit; margin-top:3px; }
.row2 { display:flex; gap:10px; }
.row2 label { flex:1; }

.match-box { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.match-row { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:.82rem; color:var(--muted); margin-bottom:5px; }

/* Lists */
.list-card { cursor: pointer; }
.tpl-row { display:grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap:10px; }
.tpl-card {
  display:flex; flex-direction:column; gap:3px; text-align:left;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px; cursor:pointer; box-shadow:var(--shadow); font:inherit; color:inherit;
}
.tpl-card:hover { border-color:var(--brand); }
.tpl-icon { font-size:1.6rem; }
.tpl-name { font-weight:700; }
.tpl-desc { font-size:.8rem; color:var(--muted); }

.list-section { margin-bottom:14px; }
.sec-head { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.sec-name {
  flex:1; font-weight:700; font-size:1rem; border:none; background:transparent;
  padding:4px 2px; border-bottom:1px solid transparent; color:var(--ink); font-family:inherit;
}
.sec-name:hover { border-bottom-color:var(--line); }
.sec-name:focus { outline:none; border-bottom-color:var(--brand); }
.items { display:flex; flex-direction:column; }
.item-row { display:flex; align-items:center; gap:10px; padding:5px 0; border-bottom:1px solid var(--line); }
.item-row:last-child { border-bottom:none; }
.item-box { width:18px; height:18px; flex:0 0 auto; cursor:pointer; }
.item-text {
  flex:1; min-width:0; border:none; background:transparent; padding:5px 4px;
  font-size:.95rem; font-family:inherit; color:var(--ink); border-radius:4px;
}
.item-text:focus { outline:none; background:var(--bg); }
.item-qty { width:64px; flex:0 0 auto; border:1px solid var(--line); border-radius:6px; padding:4px 6px; font-size:.85rem; font-family:inherit; }
.item-row.done .item-text { text-decoration:line-through; color:var(--muted); }
.item-add { display:flex; gap:8px; margin-top:10px; }
.add-text { flex:1; padding:8px 10px; border:1px solid var(--line); border-radius:8px; font-size:.92rem; font-family:inherit; background:#fff; }
.list-foot { display:flex; gap:8px; flex-wrap:wrap; margin-top:6px; }

@media (max-width: 600px) {
  .brand { padding: 10px 14px 6px; }
  .content { padding: 16px 12px 64px; }
  .prog-label { min-width: 110px; }
}

@media print {
  .app-header, .planner-controls, .view-head .btn, .view-head > div:last-child,
  .modal-overlay, .toast { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .week-scroll { overflow: visible; border: none; box-shadow: none; }
  .week-grid { min-width: 0; }
  .wg-cell:hover { background: none; }
  .card, .slot-row { box-shadow: none; break-inside: avoid; }
  .item-add, .list-foot, .sec-head .icon-btn, .item-row .icon-btn { display: none !important; }
  .item-qty { border: none; }
}
