:root {
  --bg: #F5F3FB; --surface: #FFFFFF; --ink: #231F3A; --muted: #615C80; --line: #E6E1F3;
  --accent: #5B45C7; --soft: #E4DEF8; --on: #FFFFFF; --danger: #B3261E;
  --mp: #2F6F9A; --mc: #8A5A1F; --mg: #A0457A;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.3; }
body.lock { overflow: hidden; }
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

#app { max-width: 480px; margin: 0 auto; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
#screen { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px;
  padding: calc(env(safe-area-inset-top) + 22px) 20px 24px; }
#screen > * { flex-shrink: 0; }
#tabs { display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px); }
.tab { flex: 1; height: 58px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }

.h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.hrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card { background: var(--surface); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.num { font-weight: 700; letter-spacing: -0.02em; }

.ibtn { width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; background: var(--surface); color: var(--ink);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ibtn.soft { background: var(--soft); color: var(--accent); }
.ibtn:disabled { opacity: .35; cursor: default; }
.nav { display: flex; gap: 8px; }

.week { display: flex; gap: 6px; }
.wd { flex: 1; height: 62px; border: 0; border-radius: 16px; background: var(--surface); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; padding: 0; }
.wd .l { font-size: 12px; font-weight: 500; color: var(--muted); }
.wd .n { font-size: 16px; font-weight: 700; }
.wd .dot { width: 5px; height: 5px; border-radius: 50%; }
.wd .dot.done { background: var(--accent); }
.wd .dot.part { background: var(--muted); }
.wd.today { box-shadow: inset 0 0 0 2px var(--accent); }
.wd[aria-pressed="true"] { background: var(--accent); color: var(--on); box-shadow: none; }
.wd[aria-pressed="true"] .l { color: var(--on); }
.wd[aria-pressed="true"] .dot { background: var(--on); }
.wd:disabled { opacity: .4; cursor: default; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px; border-radius: 20px; background: var(--surface); width: 100%;
  border: 0; text-align: left; }
.ibub { width: 44px; height: 44px; border-radius: 14px; background: var(--hcs); color: var(--hc); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rname { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsub { font-size: 13px; color: var(--muted); }
.chk { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--muted); background: transparent; padding: 0; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chk.on { background: var(--hc); border-color: transparent; }

.bar { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.thin { height: 6px; }
.macros { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mac { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.mac i { width: 8px; height: 8px; border-radius: 50%; display: block; }

.seg { display: flex; gap: 2px; padding: 4px; border-radius: 16px; background: var(--surface); }
.seg button { flex: 1; height: 40px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on); }

.chart { display: flex; gap: 8px; }
.chart.thin { gap: 3px; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.btrack { width: 100%; height: 88px; border-radius: 10px; background: var(--soft); display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.thin .btrack { border-radius: 4px; }
.btrack > i { display: block; background: var(--accent); border-radius: 10px; }
.thin .btrack > i { border-radius: 4px; }
.col .lbl { font-size: 12px; color: var(--muted); white-space: nowrap; height: 14px; }
.col .lbl.now { color: var(--ink); font-weight: 700; }
.tiles { display: flex; gap: 10px; }
.tile { flex: 1; border-radius: 20px; background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.tile .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

.hstat { width: 100%; border: 0; background: transparent; padding: 6px 0; min-height: 44px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.hstat .hrow { width: 100%; }
.hstat .bar { width: 100%; display: block; }
.cal .dh { font-size: 12px; color: var(--muted); text-align: center; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; width: 100%; border: 0; background: transparent;
  padding: 0; text-align: left; font-size: 14px; }
.meal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.link { border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; padding: 8px 0; min-height: 44px; text-align: left; }
.empty { background: var(--surface); border-radius: 22px; padding: 22px 18px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }

.btn { width: 100%; height: 54px; border: 0; border-radius: 18px; background: var(--accent); color: var(--on); font-size: 16px; font-weight: 600; }
.btn.ghost { background: var(--soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); }
.pill { height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: var(--accent); color: var(--on); font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }

#sheet { position: fixed; inset: 0; z-index: 50; }
.backdrop { position: absolute; inset: 0; background: rgba(35, 31, 58, .45); }
.panel { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 28px 28px 0 0; padding: 16px 20px calc(env(safe-area-inset-bottom) + 22px); display: flex; flex-direction: column; gap: 16px;
  animation: up .22s ease-out; }
.panel > * { flex-shrink: 0; }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-h h2 { font-size: 19px; font-weight: 700; text-align: center; flex: 1; }
.sheet-h .sp { width: 44px; }
.lab { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 8px; }
.inp { width: 100%; height: 52px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 16px; outline: none; }
.inp:focus { border-color: var(--accent); }
.igrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.itile { height: 58px; border-radius: 16px; border: 2px solid transparent; background: var(--surface); color: var(--muted); padding: 0; display: flex; align-items: center; justify-content: center; }
.itile[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.cgrid { display: flex; justify-content: space-between; }
.csw { width: 48px; height: 48px; border-radius: 50%; padding: 4px; background: transparent; border: 2px solid transparent; }
.csw[aria-pressed="true"] { border-color: var(--accent); }
.csw i { display: block; width: 100%; height: 100%; border-radius: 50%; }
.dgrid { display: flex; justify-content: space-between; }
.dbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600; }
.dbtn[aria-pressed="true"] { background: var(--accent); color: var(--on); }

.flist { display: flex; flex-direction: column; gap: 8px; }
.fitem { width: 100%; text-align: left; border: 0; border-radius: 16px; background: var(--surface); padding: 10px 14px; min-height: 56px; display: flex; flex-direction: column; gap: 2px; }
.fitem .fn { font-size: 15px; font-weight: 600; }
.fitem .fm { font-size: 12px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--soft); border-radius: 8px; padding: 1px 6px; margin-left: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 0; background: var(--soft); color: var(--accent); font-size: 14px; font-weight: 600; }
.prev { background: var(--surface); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-height: 76px; }
.prev .pk { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.prev .pk small { font-size: 14px; font-weight: 500; color: var(--muted); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dh { font-size: 12px; color: var(--muted); text-align: center; }
.cell { aspect-ratio: 1; border-radius: 12px; border: 0; padding: 0; background: transparent; font-size: 13px; display: flex; align-items: center; justify-content: center; color: var(--ink); }
.cell.done { background: var(--hc); color: #fff; font-weight: 600; }
.cell.miss { background: var(--hcs); }
.cell.off { color: var(--muted); opacity: .55; }
.cell.fut { color: var(--muted); opacity: .4; }
.cell.tod { box-shadow: inset 0 0 0 2px var(--ink); }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); background: var(--ink); color: #fff; z-index: 80;
  border-radius: 14px; padding: 10px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.mtiles { display: flex; gap: 8px; }
.mt { flex: 1; border-radius: 14px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; }
.mt b { font-size: 16px; color: var(--ink); }
