:root{
  --bg:#F5F0F6;
  --shell:#FBF8FC;
  --surface:#FFFFFF;
  --surface-2:#F1EAF3;
  --border:#E3D9E6;
  --text:#1C1420;
  --text-dim:#6B6074;
  --text-faint:#9A8FA3;
  --accent:#E8256F;
  --accent-glow:rgba(232,37,111,.28);
  --bg-glow:rgba(232,37,111,.09);
  --accent-ink:#FFFFFF;
  --teal:#0FA39B;
  --danger:#D93636;
  --shadow-sm:0 1px 2px rgba(28,20,32,.07);
  --shadow-lg:0 20px 44px -20px rgba(28,20,32,.34), 0 6px 14px -6px rgba(28,20,32,.14);
  --sheet-bg:#FFFFFF;
  --overlay:rgba(20,14,20,.46);

  --c-crossfit:#E23434;
  --c-crossfit-soft:#FBE0DE;
  --c-swim:#1E6FE0;
  --c-swim-soft:#DCE7FB;
  --c-gym:#7C3AED;
  --c-gym-soft:#EAE0FC;
  --c-run:#1FA355;
  --c-run-soft:#DCF3E3;
  --c-lift:#8B5A2B;
  --c-lift-soft:#EFE3D4;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#120E15;
    --shell:#17121B;
    --surface:#1E1823;
    --surface-2:#26202D;
    --border:#372C3E;
    --text:#F4EFF6;
    --text-dim:#B7AEC2;
    --text-faint:#7E7488;
    --accent:#FF4C90;
    --accent-glow:rgba(255,76,144,.35);
    --bg-glow:rgba(255,76,144,.16);
    --accent-ink:#1A0E14;
    --teal:#37D9C9;
    --danger:#FF6B6B;
    --shadow-sm:0 1px 2px rgba(0,0,0,.5);
    --shadow-lg:0 20px 50px -20px rgba(0,0,0,.75), 0 6px 16px -6px rgba(0,0,0,.55);
    --sheet-bg:#1E1823;
    --overlay:rgba(5,3,7,.62);

    --c-crossfit:#FF5A5A;
    --c-crossfit-soft:#3A2020;
    --c-swim:#4C9CFF;
    --c-swim-soft:#1C2A40;
    --c-gym:#A66BFF;
    --c-gym-soft:#2C2140;
    --c-run:#3ED97A;
    --c-run-soft:#173428;
    --c-lift:#C08552;
    --c-lift-soft:#3A2A1A;
  }
}
:root[data-theme="dark"]{
  --bg:#120E15; --shell:#17121B; --surface:#1E1823; --surface-2:#26202D;
  --border:#372C3E; --text:#F4EFF6; --text-dim:#B7AEC2; --text-faint:#7E7488;
  --accent:#FF4C90; --accent-glow:rgba(255,76,144,.35); --bg-glow:rgba(255,76,144,.16);
  --accent-ink:#1A0E14; --teal:#37D9C9; --danger:#FF6B6B;
  --shadow-sm:0 1px 2px rgba(0,0,0,.5); --shadow-lg:0 20px 50px -20px rgba(0,0,0,.75), 0 6px 16px -6px rgba(0,0,0,.55);
  --sheet-bg:#1E1823; --overlay:rgba(5,3,7,.62);
  --c-crossfit:#FF5A5A; --c-crossfit-soft:#3A2020;
  --c-swim:#4C9CFF; --c-swim-soft:#1C2A40;
  --c-gym:#A66BFF; --c-gym-soft:#2C2140;
  --c-run:#3ED97A; --c-run-soft:#173428;
  --c-lift:#C08552; --c-lift-soft:#3A2A1A;
}

*{box-sizing:border-box;}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:'Pretendard',system-ui,-apple-system,'Segoe UI',Roboto,'Gothic A1',sans-serif;
  -webkit-font-smoothing:antialiased;
  min-height:100vh;
}
.num{font-family:'Oswald','Gothic A1',sans-serif; font-variant-numeric:tabular-nums; letter-spacing:.01em;}
h1,h2,h3{text-wrap:balance; margin:0;}
button{font-family:inherit;}
::selection{background:var(--accent); color:var(--accent-ink);}

.page{
  display:flex; justify-content:center;
  min-height:100vh;
  background:var(--bg);
}
.shell{
  width:100%; max-width:460px;
  background:var(--shell);
  min-height:100vh;
  position:relative;
  box-shadow:var(--shadow-lg);
  display:flex; flex-direction:column;
}
@media (min-width:540px){
  .page{ padding:28px 16px;
    background:
      radial-gradient(900px 620px at 50% -8%, var(--bg-glow), transparent 62%),
      var(--bg);
  }
  .shell{ min-height:calc(100vh - 56px); border-radius:28px; overflow:hidden; }
}

/* header */
.topbar{
  position:sticky; top:0; z-index:20;
  background:var(--shell);
  padding:20px 20px 0;
  overflow:hidden;
}
.topbar::before{
  content:""; position:absolute; top:-70px; left:50%; transform:translateX(-50%);
  width:360px; height:230px; pointer-events:none; z-index:0;
  background:radial-gradient(closest-side, var(--accent-glow), transparent 72%);
}
.brand-row{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; position:relative; z-index:1; }
.brand{ font-family:'Black Han Sans','Gothic A1',sans-serif; font-size:23px; font-weight:400; letter-spacing:.01em; line-height:1.15; }
.brand-accent{ color:var(--accent); }
.brand small{ display:block; font-size:11.5px; font-weight:700; font-family:'Gothic A1',sans-serif; color:var(--text-faint); margin-top:5px; letter-spacing:.01em; }
.topbar-actions{ display:flex; align-items:center; gap:8px; margin-top:2px; }
.today{ font-size:11px; color:var(--text-dim); font-weight:700; background:var(--surface); border:1px solid var(--border); padding:5px 10px; border-radius:100px; white-space:nowrap; }
.logout-btn{ border:1px solid var(--border); background:var(--surface); color:var(--text-dim); font-size:11px; font-weight:700; border-radius:100px; padding:5px 10px; cursor:pointer; }
.logout-btn:hover{ color:var(--accent); border-color:var(--accent); }

.summary{ position:relative; z-index:1; margin-top:16px; }
.hero-stats{
  display:flex; align-items:center; gap:2px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:20px; padding:16px 8px; box-shadow:var(--shadow-sm);
}
.hero-stat{ flex:1; text-align:center; min-width:0; }
.hero-num{ font-size:27px; font-weight:600; line-height:1; color:var(--text); }
.hero-stat--primary .hero-num{ font-size:32px; color:var(--accent); }
.hero-unit{ font-size:11px; font-weight:500; color:var(--text-faint); margin-left:1px; }
.hero-label{ font-size:10px; font-weight:700; color:var(--text-dim); margin-top:6px; text-transform:uppercase; letter-spacing:.035em; }
.hero-div{ width:1px; align-self:stretch; margin:2px 2px; background:var(--border); flex:none; }

.filters{
  display:flex; gap:6px; overflow-x:auto; padding:14px 20px 12px;
  scrollbar-width:none;
}
.filters::-webkit-scrollbar{display:none;}
.chip{
  flex:none; border:1px solid var(--border); background:var(--surface);
  color:var(--text-dim); font-weight:700; font-size:12.5px;
  padding:7px 13px; border-radius:100px; cursor:pointer;
  display:flex; align-items:center; gap:5px; white-space:nowrap;
  transition:background .15s, color .15s, border-color .15s;
}
.chip .dot{width:6px;height:6px;border-radius:50%;background:currentColor;}
.chip[data-active="true"]{ background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }

.view-toggle{
  display:flex; gap:4px; margin:0 20px 10px; padding:4px;
  background:var(--surface-2); border:1px solid var(--border); border-radius:100px;
}
.view-toggle button{
  flex:1; border:none; background:transparent; color:var(--text-dim);
  font-weight:800; font-size:12.5px; padding:8px 0; border-radius:100px; cursor:pointer;
}
.view-toggle button[data-active="true"]{ background:var(--accent); color:var(--accent-ink); }

.search-bar{ padding:0 20px 12px; }
.search-bar input{
  width:100%; border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  border-radius:100px; padding:10px 16px; font-size:13.5px; font-family:inherit;
  -webkit-appearance:none; appearance:none;
}
.search-bar input::placeholder{ color:var(--text-faint); }
.search-bar input:focus{ outline:2px solid var(--accent); outline-offset:1px; }

.cal-nav{ display:flex; align-items:center; justify-content:space-between; padding:4px 2px 14px; }
.cal-nav .cal-month{ font-family:'Oswald',sans-serif; font-size:15px; font-weight:600; letter-spacing:.02em; }
.cal-nav button{
  width:30px; height:30px; border-radius:50%; border:1px solid var(--border); background:var(--surface);
  color:var(--text-dim); display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.cal-nav button svg{ width:14px; height:14px; }

.cal-weekdays{ display:grid; grid-template-columns:repeat(7,1fr); text-align:center; margin-bottom:6px; }
.cal-weekdays span{ font-size:10.5px; font-weight:700; color:var(--text-faint); }

.cal-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:5px; }
.cal-day{
  position:relative; aspect-ratio:1; border-radius:12px; border:1px solid var(--border);
  background:var(--surface); display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:4px; cursor:pointer; padding:2px;
}
.cal-day[data-pad="true"]{ visibility:hidden; pointer-events:none; }
.cal-day .d{ font-family:'Oswald',sans-serif; font-size:13px; color:var(--text-dim); font-weight:500; }
.cal-day[data-today="true"]{ border-color:var(--accent); box-shadow:0 0 0 1.5px var(--accent) inset; }
.cal-day[data-today="true"] .d{ color:var(--accent); font-weight:700; }
.cal-day[data-has="true"] .d{ color:var(--text); font-weight:700; }
.cal-dots{ display:flex; gap:2.5px; justify-content:center; flex-wrap:wrap; max-width:26px; }
.cal-dots span{ width:5px; height:5px; border-radius:50%; flex:none; }

/* list */
.list{ padding:2px 20px 100px; flex:1; }
.day-group{ margin-top:18px; }
.day-label{ font-family:'Oswald',sans-serif; font-size:12px; font-weight:500; color:var(--text-faint); margin:0 2px 8px; text-transform:uppercase; letter-spacing:.09em; }

.entry{
  position:relative;
  display:flex; align-items:center; gap:12px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:16px; padding:12px 14px 12px 20px; margin-bottom:8px;
  cursor:pointer; text-align:left; width:100%;
  box-shadow:var(--shadow-sm);
  transition:transform .12s ease;
}
.entry:active{ transform:scale(.98); }
.entry::before{
  content:""; position:absolute; left:7px; top:11px; bottom:11px; width:3.5px;
  border-radius:3px; background:var(--bar,var(--border));
}
.entry .icon{
  width:40px; height:40px; border-radius:12px; flex:none;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 7px 14px -7px currentColor;
}
.entry .icon svg{ width:21px; height:21px; }
.entry .body{ flex:1; min-width:0; }
.entry .row1{ display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.entry .title{ font-weight:900; font-size:14.5px; }
.entry .time{ font-family:'Oswald',sans-serif; font-size:12px; color:var(--text-faint); font-weight:500; flex:none; }
.entry .sub{ font-size:12.5px; color:var(--text-dim); margin-top:3px; font-variant-numeric:tabular-nums; }
.entry .sub b{ color:var(--text); font-weight:700; }

.empty{
  text-align:center; padding:54px 24px 20px; color:var(--text-dim);
}
.empty .big{ font-size:38px; margin-bottom:10px; }
.empty h3{ font-family:'Black Han Sans','Gothic A1',sans-serif; font-weight:400; font-size:17px; margin-bottom:6px; }
.empty p{ font-size:13px; color:var(--text-faint); line-height:1.6; margin:0; }

/* fab */
.fab{
  position:absolute; right:20px; bottom:24px; z-index:30;
  width:58px; height:58px; border-radius:50%;
  background:var(--accent); color:var(--accent-ink);
  border:none; box-shadow:0 16px 30px -10px var(--accent-glow), 0 5px 12px -4px var(--accent-glow);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; transition:transform .12s ease;
}
.fab:active{ transform:scale(.92); }
.fab svg{ width:26px; height:26px; }

/* sheets */
.sheet-layer{ position:fixed; inset:0; z-index:100; display:none; }
.sheet-layer[data-open="true"]{ display:block; }
.sheet-overlay{ position:absolute; inset:0; background:var(--overlay); }
.sheet{
  position:absolute; left:50%; bottom:0; transform:translateX(-50%);
  width:100%; max-width:460px;
  background:var(--sheet-bg);
  border-radius:24px 24px 0 0;
  max-height:88vh; display:flex; flex-direction:column;
  box-shadow:0 -10px 40px rgba(0,0,0,.25);
  overflow:hidden;
}
.sheet::before{
  content:""; position:absolute; top:0; left:0; right:0; height:3px;
  background:linear-gradient(90deg, var(--accent), var(--teal));
}
.sheet-grip{ width:36px; height:4px; border-radius:3px; background:var(--border); margin:12px auto 2px; flex:none; }
.sheet-head{ display:flex; align-items:center; justify-content:space-between; padding:10px 18px 4px; flex:none; }
.sheet-head h2{ font-size:16.5px; font-weight:800; }
.icon-btn{
  width:32px; height:32px; border-radius:50%; border:none; background:var(--surface-2);
  color:var(--text-dim); display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.icon-btn svg{ width:16px; height:16px; }
.sheet-body{ overflow-y:auto; padding:14px 18px 22px; }

.sport-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-top:4px; }
.sport-tile{
  display:flex; flex-direction:column; align-items:center; gap:9px;
  padding:18px 6px 13px; border-radius:18px; border:1px solid var(--border);
  background:var(--surface-2); cursor:pointer; transition:transform .12s ease;
}
.sport-tile:active{ transform:scale(.95); }
.sport-tile .ic{ width:46px; height:46px; border-radius:14px; display:flex; align-items:center; justify-content:center; box-shadow:0 10px 20px -9px currentColor; }
.sport-tile .ic svg{ width:22px; height:22px; }
.sport-tile span{ font-size:12.5px; font-weight:900; }

.paste-link{
  margin-top:14px; width:100%; border:1px dashed var(--border); background:transparent;
  border-radius:14px; padding:12px; font-size:12.5px; font-weight:700; color:var(--teal);
  cursor:pointer; display:flex; align-items:center; justify-content:center; gap:7px;
}
.paste-link svg{ width:15px; height:15px; }

.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12px; font-weight:700; color:var(--text-dim); margin-bottom:6px; }
.field .hint{ font-size:11px; color:var(--text-faint); margin-top:5px; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], select, textarea{
  width:100%; border:1px solid var(--border); background:var(--surface-2);
  color:var(--text); border-radius:12px; padding:11px 12px; font-size:14.5px;
  font-family:inherit; -webkit-appearance:none; appearance:none;
}
input:focus, select:focus, textarea:focus{ outline:2px solid var(--accent); outline-offset:1px; }
textarea{ resize:vertical; min-height:72px; line-height:1.5; }
.pace-readout{
  display:flex; justify-content:space-between; align-items:center;
  background:var(--surface-2); border:1px solid var(--border); border-radius:12px;
  padding:10px 14px; margin:-4px 0 14px;
}
.pace-readout .pl{ font-size:12px; font-weight:700; color:var(--text-dim); }
.pace-readout .pv{ font-size:16px; font-weight:600; color:var(--text); }
.row2{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.row3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; }
.row4{ display:grid; grid-template-columns:1.7fr .75fr .75fr .75fr; gap:6px; }
.dur-field{ display:flex; flex-direction:column; align-items:center; gap:5px; min-width:0; }
.dur-field input{ width:100%; text-align:center; padding-left:4px; padding-right:4px; }
.dur-date input{ font-size:12.5px; padding-left:6px; padding-right:2px; }
.dur-field span{ font-size:10px; font-weight:700; color:var(--text-faint); }

.seg{ display:flex; gap:6px; flex-wrap:wrap; }
.seg button{
  border:1px solid var(--border); background:var(--surface-2); color:var(--text-dim);
  font-weight:700; font-size:12.5px; padding:8px 12px; border-radius:10px; cursor:pointer;
}
.seg button[data-on="true"]{ background:var(--sport-color, var(--accent)); border-color:var(--sport-color, var(--accent)); color:#fff; }

.mood-row{ display:flex; justify-content:space-between; gap:6px; }
.mood-row button{
  flex:1; border:1px solid var(--border); background:var(--surface-2); border-radius:12px;
  padding:9px 0 7px; font-size:19px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:3px;
}
.mood-row button span{ font-size:9.5px; font-weight:700; color:var(--text-faint); }
.mood-row button[data-on="true"]{ background:var(--sport-color, var(--accent)); border-color:var(--sport-color, var(--accent)); }
.mood-row button[data-on="true"] span{ color:rgba(255,255,255,.85); }

.ex-row{ display:grid; grid-template-columns:1.5fr .8fr .6fr .6fr auto; gap:6px; margin-bottom:8px; align-items:center; }
.ex-row input{ padding:9px 8px; font-size:13px; }
.style-row{ display:grid; grid-template-columns:1.3fr .8fr auto; gap:8px; margin-bottom:8px; align-items:center; }
.style-row select, .style-row input{ padding:9px 8px; font-size:13px; }
.ex-remove{ width:30px; height:30px; border-radius:9px; border:1px solid var(--border); background:var(--surface-2); color:var(--danger); cursor:pointer; }
.add-ex{
  width:100%; border:1px dashed var(--border); background:transparent; color:var(--text-dim);
  border-radius:10px; padding:9px; font-size:12.5px; font-weight:700; cursor:pointer; margin-top:2px;
}

.save-bar{ position:sticky; bottom:0; background:var(--sheet-bg); padding:12px 18px calc(16px + env(safe-area-inset-bottom)); border-top:1px solid var(--border); flex:none; }
.btn-primary{
  width:100%; border:none; border-radius:14px; padding:14px; font-size:15px; font-weight:800;
  background:var(--sport-color, var(--accent)); color:#fff; cursor:pointer;
}
.btn-danger-ghost{
  width:100%; border:1px solid var(--border); background:transparent; color:var(--danger);
  border-radius:14px; padding:12px; font-size:13.5px; font-weight:700; cursor:pointer; margin-top:8px;
}

.pill-badge{
  display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:700;
  padding:3px 9px; border-radius:100px; margin-bottom:10px;
}

.toast{
  position:absolute; left:50%; bottom:96px; transform:translateX(-50%);
  background:var(--text); color:var(--shell); font-size:12.5px; font-weight:700;
  padding:10px 16px; border-radius:100px; box-shadow:var(--shadow-lg);
  opacity:0; pointer-events:none; transition:opacity .25s, transform .25s;
  z-index:200; white-space:nowrap;
}
.toast[data-show="true"]{ opacity:1; transform:translateX(-50%) translateY(-4px); }

@media (prefers-reduced-motion:reduce){ *{ transition:none !important; } }
