:root {
  color-scheme: light;
  --ink: #17342b;
  --ink-soft: #547067;
  --cream: #f5f3eb;
  --paper: #fffefa;
  --green: #1e7455;
  --green-dark: #15533f;
  --green-soft: #dceade;
  --lime: #d8ec8d;
  --blue: #5d7ea8;
  --line: #dfe4dc;
  --danger: #a84538;
  --shadow: 0 20px 50px rgba(24, 57, 47, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { background: #dfe8e1; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(216, 236, 141, .5), transparent 30%),
    linear-gradient(150deg, #e9eee7 0%, #dbe7de 100%);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--cream);
  box-shadow: var(--shadow);
  position: relative;
  overflow-x: hidden;
}

.auth-shell {
  min-height: 100vh;
  padding: 44px 24px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 88% 4%, rgba(216, 236, 141, .8), transparent 24%),
    linear-gradient(180deg, #f7f4e9 0%, #edf0e5 100%);
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-size: 28px;
  box-shadow: 0 12px 28px rgba(30, 116, 85, .25);
}

.eyebrow {
  margin: 20px 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(34px, 9vw, 48px); line-height: 1.07; letter-spacing: -.055em; }
h2 { margin-bottom: 8px; font-size: 27px; letter-spacing: -.04em; }
h3 { margin-bottom: 8px; font-size: 18px; letter-spacing: -.025em; }
.lead { color: var(--ink-soft); line-height: 1.65; }

.auth-card {
  margin-top: 36px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 28px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(23, 63, 50, .09);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 14px;
  background: #e8ece5;
}

.segmented button {
  border: 0;
  border-radius: 11px;
  padding: 11px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 750;
  cursor: pointer;
}

.segmented button.active { background: var(--paper); color: var(--ink); box-shadow: 0 4px 12px rgba(23,52,43,.08); }

.field { display: grid; gap: 7px; margin: 13px 0; }
.field span { font-size: 13px; font-weight: 750; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px 15px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(30,116,85,.1); }
.hint { margin: 7px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }

.primary, .secondary, .ghost, .danger-button {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s, opacity .16s, box-shadow .16s;
}
.primary { color: white; background: var(--green); box-shadow: 0 10px 22px rgba(30,116,85,.2); }
.primary:hover { background: var(--green-dark); }
.secondary { background: var(--green-soft); color: var(--green-dark); }
.ghost { background: transparent; color: var(--ink-soft); }
.danger-button { background: #f7e3df; color: var(--danger); }
.primary:active, .secondary:active, .ghost:active { transform: scale(.98); }
.primary:disabled, .secondary:disabled { opacity: .48; cursor: wait; }
.wide { width: 100%; }

.topbar {
  min-height: 78px;
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245,243,235,.9);
  backdrop-filter: blur(18px);
}

.wordmark { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 900; letter-spacing: -.04em; }
.wordmark-dot { width: 13px; height: 13px; border-radius: 5px 5px 5px 1px; background: var(--green); transform: rotate(-8deg); }
.avatar {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  font-weight: 850;
  cursor: pointer;
}

.content { padding: 10px 20px 110px; }
.page-intro { padding: 8px 2px 20px; }
.page-intro .date { margin-bottom: 8px; color: var(--ink-soft); font-size: 14px; }
.page-intro h1 { font-size: 36px; }

.hero-card {
  padding: 24px;
  border-radius: 28px;
  background: var(--ink);
  color: white;
  overflow: hidden;
  position: relative;
  box-shadow: 0 18px 42px rgba(23,52,43,.22);
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 155px;
  height: 155px;
  right: -45px;
  top: -50px;
  border: 26px solid rgba(216,236,141,.14);
  border-radius: 50%;
}
.streak-label { color: var(--lime); font-size: 13px; font-weight: 800; }
.streak-number { margin: 5px 0 20px; font-size: 42px; font-weight: 900; letter-spacing: -.055em; }
.hero-card .primary { background: var(--lime); color: var(--ink); box-shadow: none; position: relative; z-index: 1; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 26px; }
.status-card { padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); }
.status-card.friend { background: #f1f5f8; }
.status-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-name { font-weight: 850; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #c7cfc9; }
.status-dot.done { background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.status-card.friend .status-dot.done { background: var(--blue); box-shadow: 0 0 0 5px #dfe7f1; }
.status-text { margin: 14px 0 0; color: var(--ink-soft); font-size: 13px; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 26px 2px 12px; }
.section-head h3 { margin: 0; }
.section-head button { border: 0; background: none; color: var(--green); font-size: 13px; font-weight: 800; cursor: pointer; }

.recent-list { display: grid; gap: 10px; }
.recent-card { padding: 16px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.date-box { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: var(--green-soft); color: var(--green-dark); font-weight: 900; }
.recent-main { flex: 1; min-width: 0; }
.recent-main strong { display: block; margin-bottom: 4px; }
.recent-main span { color: var(--ink-soft); font-size: 12px; }
.recent-duration { color: var(--ink-soft); font-size: 13px; }
.empty { padding: 30px 18px; border: 1px dashed #cad2cc; border-radius: 20px; text-align: center; color: var(--ink-soft); background: rgba(255,255,255,.35); }

.bottom-nav {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  width: min(calc(100% - 24px), 496px);
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 23px;
  background: rgba(23,52,43,.95);
  box-shadow: 0 18px 40px rgba(15,37,30,.28);
  backdrop-filter: blur(16px);
}
.nav-button { min-height: 58px; border: 0; border-radius: 17px; background: transparent; color: #c6d3cd; display: grid; place-items: center; gap: 2px; font-size: 11px; cursor: pointer; }
.nav-button span:first-child { font-size: 20px; }
.nav-button.active { color: var(--ink); background: var(--lime); font-weight: 850; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 10px 15px; background: var(--paper); color: var(--ink-soft); font-weight: 750; cursor: pointer; }
.chip.active { border-color: var(--green); background: var(--green); color: white; }

.request-exercise-button { width: 100%; margin: 0 0 14px; padding: 13px 15px; border: 1px solid #bed5c8; border-radius: 18px; background: var(--green-soft); color: var(--ink); display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; }
.request-exercise-button > span { width: 36px; height: 36px; border-radius: 12px; background: var(--green); color: white; display: grid; place-items: center; font-size: 20px; flex: 0 0 auto; }
.request-exercise-button > div { flex: 1; }
.request-exercise-button strong, .request-exercise-button small { display: block; }
.request-exercise-button small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.request-exercise-button > i { color: var(--green); font-size: 25px; font-style: normal; }
.request-lead { margin: 12px 0 18px; }

.exercise-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.exercise-card { min-height: 245px; padding: 11px 12px 14px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); cursor: pointer; text-align: left; position: relative; overflow: hidden; }
.exercise-card.selected { border: 2px solid var(--green); padding: 10px 11px 13px; box-shadow: 0 10px 24px rgba(30,116,85,.12); }
.exercise-visual { display: block; width: 100%; aspect-ratio: 1; margin-bottom: 10px; overflow: hidden; border-radius: 15px; background: #fff; }
.exercise-visual img { width: 100%; height: 100%; display: block; object-fit: contain; }
.exercise-card strong { display: block; margin-bottom: 7px; line-height: 1.25; }
.exercise-card small { display: block; color: var(--ink-soft); line-height: 1.45; }
.kind-tag { position: absolute; z-index: 1; top: 13px; right: 12px; padding: 5px 8px; border-radius: 999px; background: rgba(238,241,236,.94); color: var(--ink-soft); font-size: 10px; font-weight: 800; }
.selected-check { position: absolute; right: 12px; bottom: 12px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: white; background: var(--green); }

.record-stage { margin-top: 22px; }
.record-card { margin-bottom: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); }
.record-title { display: flex; align-items: center; gap: 12px; }
.record-exercise-visual { width: 66px; height: 66px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; flex: 0 0 auto; }
.record-exercise-visual img { width: 100%; height: 100%; display: block; object-fit: contain; }
.record-title > div:nth-child(2) { flex: 1; }
.record-title small { color: var(--ink-soft); }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 12px; background: #f5e9e6; color: var(--danger); cursor: pointer; }
.guidance { margin: 14px 0; padding: 12px 14px; border-radius: 14px; background: #f0f4ed; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.set-row { display: grid; grid-template-columns: 34px repeat(2, minmax(0,1fr)) 32px; gap: 7px; align-items: end; margin-top: 8px; }
.set-row.distance-row { grid-template-columns: 34px repeat(2, minmax(0,1fr)) 32px; }
.set-number { height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 850; }
.mini-field { display: grid; gap: 4px; color: var(--ink-soft); font-size: 10px; font-weight: 750; }
.mini-field input { width: 100%; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 11px; padding: 8px; background: #fbfcf8; }
.remove-set { height: 40px; border: 0; background: transparent; color: #a7b0aa; cursor: pointer; }
.add-set { width: 100%; margin-top: 10px; padding: 10px; border: 1px dashed #b8c8bd; border-radius: 13px; background: transparent; color: var(--green); font-size: 12px; font-weight: 800; cursor: pointer; }
.record-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; position: sticky; bottom: 88px; padding: 12px 0 4px; background: linear-gradient(transparent, var(--cream) 25%); }
.delete-workout-button { margin-top: 18px; }

.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-head button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); cursor: pointer; }
.calendar-head strong { font-size: 21px; }
.calendar { padding: 14px 10px 10px; border: 1px solid var(--line); border-radius: 24px; background: var(--paper); }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays span { padding: 7px 0 10px; color: var(--ink-soft); text-align: center; font-size: 11px; font-weight: 800; }
.day { min-height: 62px; border: 0; border-radius: 14px; background: transparent; padding: 8px 3px; display: flex; flex-direction: column; align-items: center; gap: 7px; cursor: pointer; }
.day:hover { background: #f2f5ef; }
.day.muted { opacity: .28; }
.day.today { box-shadow: inset 0 0 0 2px var(--green); }
.day-number { font-size: 13px; font-weight: 750; }
.attendance-dots { height: 8px; display: flex; gap: 3px; align-items: center; }
.attendance-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.attendance-dots i.me { background: var(--green); }
.legend { display: flex; gap: 16px; justify-content: center; margin: 14px 0 2px; color: var(--ink-soft); font-size: 11px; }
.legend span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; background: var(--green); }
.legend span.friend::before { background: var(--blue); }

.detail-sheet { margin-top: 18px; padding: 20px; border-radius: 24px; background: var(--ink); color: white; }
.detail-sheet .muted { color: #b7c7c1; }
.person-workout { margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); }
.person-workout:first-of-type { margin-top: 12px; padding-top: 0; border-top: 0; }
.person-label { display: flex; justify-content: space-between; gap: 12px; }
.person-label span { color: var(--lime); font-size: 12px; font-weight: 800; }
.edit-workout-button {
  width: 100%;
  margin: 12px 0 2px;
  padding: 10px 12px;
  border: 1px solid rgba(222, 245, 132, 0.65);
  border-radius: 12px;
  background: rgba(222, 245, 132, 0.1);
  color: var(--lime);
  font-weight: 800;
  cursor: pointer;
}
.detail-exercise { margin-top: 13px; padding: 10px; border-radius: 15px; background: rgba(255,255,255,.08); display: flex; align-items: center; gap: 11px; }
.detail-exercise img { width: 54px; height: 54px; object-fit: contain; border-radius: 12px; background: white; flex: 0 0 auto; }
.detail-exercise strong { display: block; margin-bottom: 6px; }
.set-summary { color: #d4ded9; font-size: 12px; line-height: 1.65; }

.invite-card { padding: 22px; border-radius: 24px; background: var(--green); color: white; }
.invite-code { margin: 14px 0; padding: 14px; border: 1px dashed rgba(255,255,255,.5); border-radius: 15px; text-align: center; font-size: 25px; font-weight: 900; letter-spacing: .12em; }
.invite-card .secondary { background: var(--lime); color: var(--ink); }
.friend-list { display: grid; gap: 10px; margin-top: 16px; }
.friend-card { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 19px; background: var(--paper); }
.friend-avatar { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; color: white; background: var(--blue); font-weight: 900; }
.friend-meta { flex: 1; }
.friend-meta strong { display: block; margin-bottom: 4px; }
.friend-meta small { color: var(--ink-soft); }
.complete-badge { padding: 6px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 10px; font-weight: 850; }

.profile-panel { padding: 22px; border: 1px solid var(--line); border-radius: 24px; background: var(--paper); }
.profile-row { display: flex; align-items: center; gap: 14px; }
.profile-row .avatar { width: 54px; height: 54px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; justify-items: center; padding: 16px; background: rgba(11,27,22,.55); backdrop-filter: blur(6px); }
.modal { width: min(100%, 488px); max-height: 88vh; overflow-y: auto; padding: 22px; border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.modal-head button { width: 38px; height: 38px; border: 0; border-radius: 12px; background: #edf0eb; cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: 95px; z-index: 100; transform: translate(-50%, 20px); width: min(calc(100% - 40px), 440px); padding: 13px 16px; border-radius: 15px; background: var(--ink); color: white; text-align: center; font-size: 13px; opacity: 0; pointer-events: none; transition: .24s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.loading { min-height: 100vh; display: grid; place-items: center; color: var(--ink-soft); }
.spinner { width: 36px; height: 36px; border: 4px solid var(--green-soft); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .shell, .auth-shell { min-height: calc(100vh - 48px); border-radius: 34px; }
  .bottom-nav { bottom: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
