:root {
  color-scheme: light;
  --forest: #173d33;
  --forest-2: #28594b;
  --mint: #dceadf;
  --cream: #f4f1e8;
  --paper: #fffdf8;
  --ink: #17231f;
  --muted: #69736e;
  --line: #d8ddd8;
  --gold: #e4a83a;
  --danger: #a84435;
  --shadow: 0 10px 30px rgba(26, 50, 43, 0.08);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body { margin: 0; color: var(--ink); background: var(--cream); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.35; }
input, select, textarea { color: var(--ink); }

.app-shell { min-height: 100dvh; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 18px 14px; color: white; background: rgba(23, 61, 51, 0.96); backdrop-filter: blur(16px); }
.app-header h1 { margin: 2px 0 0; font-family: Georgia, "Times New Roman", "Noto Serif KR", serif; font-size: clamp(1.35rem, 5vw, 1.7rem); font-weight: 700; letter-spacing: -0.04em; }
.eyebrow { margin: 0; color: #b9d5c7; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.save-status { flex: none; padding: 6px 9px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; color: #d8e8df; font-size: .72rem; }
.save-status[data-tone="positive"] { color: #173d33; background: #d9f0dd; border-color: transparent; }
.save-status[data-tone="warning"] { color: #fff0da; border-color: #c78358; }

#app { width: min(100%, 760px); min-height: 70vh; margin: 0 auto; outline: none; }
.selection-panel { padding: 18px 16px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.week-row { display: grid; grid-template-columns: 42px 1fr 42px; align-items: end; gap: 10px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; color: var(--forest); background: white; font-size: 1.75rem; line-height: 1; }
.week-select-wrap { display: grid; gap: 4px; }
.week-select-wrap span { color: var(--muted); font-size: .72rem; font-weight: 700; }
.week-select-wrap select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: white; font-weight: 800; }
.day-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 14px; }
.day-tab { min-height: 42px; border: 1px solid transparent; border-radius: 14px; color: var(--muted); background: #f0f1ec; font-weight: 800; }
.day-tab.is-active { color: white; background: var(--forest); box-shadow: 0 6px 14px rgba(23,61,51,.2); }

.day-summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 16px; padding: 18px; border-radius: 22px; color: white; background: linear-gradient(135deg, #244e42, #173d33); box-shadow: var(--shadow); }
.day-summary p { margin: 0 0 4px; color: #bcd5c8; font-size: .8rem; font-weight: 700; }
.day-summary h2 { margin: 0; font-family: Georgia, "Noto Serif KR", serif; font-size: 1.25rem; letter-spacing: -.035em; }
.progress-ring { display: grid; flex: none; width: 58px; height: 58px; place-items: center; border-radius: 50%; background: conic-gradient(#e6bd64 var(--progress), rgba(255,255,255,.15) 0); position: relative; }
.progress-ring::before { content: ""; position: absolute; inset: 5px; border-radius: inherit; background: var(--forest); }
.progress-ring span { position: relative; font-size: .76rem; font-weight: 900; }

.workout-list { display: grid; gap: 14px; padding: 0 16px 24px; }
.workout-card { overflow: hidden; padding: 18px; border: 1px solid rgba(23,61,51,.08); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.workout-card.is-optional { border-style: dashed; border-color: #c7aa70; background: #fffcf4; box-shadow: 0 10px 28px rgba(82,66,33,.08); }
.card-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.card-heading h3 { margin: 4px 0 0; font-size: 1.15rem; letter-spacing: -.03em; }
.exercise-target { margin: 0; color: var(--forest-2); font-size: .74rem; font-weight: 800; }
.optional-badge { display: inline-flex; margin: 0 0 6px; padding: 4px 8px; border-radius: 999px; color: #624713; background: #f4dfad; font-size: .68rem; font-weight: 900; }
.optional-workout-heading { margin-top: 4px; padding: 15px 16px; border: 1px dashed #c7aa70; border-radius: 18px; background: #fff8e8; }
.optional-workout-heading div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.optional-workout-heading span { color: #624713; font-size: .78rem; font-weight: 900; }
.optional-workout-heading strong { color: var(--forest); font-size: .8rem; }
.optional-workout-heading p { margin: 5px 0 0; color: #6d6553; font-size: .76rem; line-height: 1.45; }
.guide-button { flex: none; width: 32px; height: 32px; border: 1px solid #bdd0c7; border-radius: 50%; color: var(--forest); background: var(--mint); font-weight: 900; }
.guide-copy { margin: 12px 0 0; padding: 11px 12px; border-radius: 12px; color: #395249; background: #edf4ee; font-size: .82rem; line-height: 1.55; }
.bodyweight-note { margin: 0; padding: 10px 12px; border-radius: 12px; color: #395249; background: #edf4ee; font-size: .78rem; font-weight: 700; }
.workout-form { display: grid; gap: 15px; margin-top: 18px; }
.weight-field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; }
.weight-field > label, .sets-fieldset legend, .metrics-grid span, .date-field span, .recovery-field > span, .memo-field span { font-size: .76rem; font-weight: 800; color: var(--muted); }
.weight-field small { grid-column: 1 / -1; color: var(--forest-2); font-size: .72rem; }
.number-with-unit { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.number-with-unit:focus-within { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(40,89,75,.1); }
.number-with-unit input { width: 88px; height: 44px; padding: 0 8px 0 12px; border: 0; outline: 0; text-align: right; font-weight: 800; background: transparent; }
.number-with-unit span, .number-with-unit em { padding-right: 11px; color: var(--muted); font-size: .75rem; font-style: normal; white-space: nowrap; }
.sets-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.sets-fieldset legend { margin-bottom: 7px; }
.sets-fieldset legend span { font-weight: 500; }
.sets-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sets-1 { grid-template-columns: minmax(0, 1fr); }
.sets-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sets-grid label { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.sets-grid span { padding-left: 10px; color: var(--forest-2); font-size: .72rem; font-weight: 900; }
.sets-grid input { width: 100%; min-width: 0; height: 44px; border: 0; outline: 0; text-align: center; font-weight: 900; background: transparent; }
.sets-grid label:focus-within { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(40,89,75,.1); }
.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.metrics-grid label { display: grid; gap: 5px; }
.metrics-grid input { width: 100%; min-width: 0; height: 42px; padding: 0 7px; border: 1px solid var(--line); border-radius: 11px; text-align: center; font-weight: 800; background: white; }
.metrics-grid input:focus { outline: 3px solid rgba(40,89,75,.1); border-color: var(--forest-2); }
.result-panel { display: grid; grid-template-columns: 1fr 1.35fr; gap: 1px; overflow: hidden; border-radius: 14px; background: var(--line); }
.result-panel > div { display: grid; gap: 3px; padding: 11px 12px; background: #f3f2ed; }
.result-panel span { color: var(--muted); font-size: .68rem; font-weight: 700; }
.result-panel strong { font-size: .86rem; }
.result-panel[data-tone="positive"] > div { background: #e0eee3; }
.result-panel[data-tone="positive"] strong { color: #236342; }
.result-panel[data-tone="warning"] > div { background: #fff0d9; }
.result-panel[data-tone="warning"] strong { color: #97551f; }
.result-panel[data-tone="muted"] strong { color: #777f7b; }
.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: 0 16px; border-radius: 14px; font-weight: 900; }
.primary-button { border: 0; color: white; background: var(--forest); box-shadow: 0 7px 15px rgba(23,61,51,.16); }
.secondary-button { border: 1px solid #aabdb4; color: var(--forest); background: white; }
.danger-button { border: 1px solid #d8a79d; color: var(--danger); background: #fff8f6; }

.page-heading { padding: 28px 18px 18px; }
.page-heading .eyebrow { color: var(--forest-2); }
.page-heading h2 { margin: 5px 0 7px; font-family: Georgia, "Noto Serif KR", serif; font-size: 1.75rem; letter-spacing: -.045em; }
.page-heading > p:last-child { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 16px 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.stats-strip div { display: grid; gap: 2px; padding: 14px 8px; text-align: center; }
.stats-strip div + div { border-left: 1px solid var(--line); }
.stats-strip strong { color: var(--forest); font-size: 1.3rem; }
.stats-strip span { color: var(--muted); font-size: .7rem; }
.history-list { display: grid; gap: 11px; padding: 0 16px 24px; }
.history-card { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.history-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; font-weight: 700; }
.history-card h3 { margin: 7px 0 4px; font-size: 1rem; }
.history-card > p { margin: 0; color: var(--muted); font-size: .82rem; }
.history-result { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .8rem; }
.history-result[data-tone="positive"] strong { color: #236342; }
.history-result[data-tone="warning"] strong { color: #97551f; }
.empty-state, .fatal-state { display: grid; justify-items: center; gap: 7px; padding: 42px 22px; text-align: center; color: var(--muted); }
.empty-state > span { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 50%; color: var(--forest); background: var(--mint); font-size: 1.5rem; }
.empty-state h3, .fatal-state h2 { margin: 8px 0 0; color: var(--ink); }
.empty-state p, .fatal-state p { margin: 0 0 10px; }

.recovery-card { display: grid; gap: 18px; margin: 0 16px 24px; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.date-field, .memo-field { display: grid; gap: 7px; }
.date-field input, .memo-field textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.recovery-field { display: grid; gap: 6px; min-width: 0; }
.recovery-field .number-with-unit input { flex: 1; width: 0; min-width: 0; }
.memo-field textarea { resize: vertical; line-height: 1.5; }

.settings-list { display: grid; gap: 12px; padding: 0 16px; }
.settings-card { display: grid; gap: 16px; padding: 17px; border: 1px solid var(--line); border-radius: 19px; background: var(--paper); }
.settings-card > div { display: flex; gap: 12px; align-items: start; }
.settings-card h3 { margin: 1px 0 4px; font-size: 1rem; }
.settings-card p { margin: 0; color: var(--muted); font-size: .79rem; line-height: 1.5; }
.settings-card.emphasis { border-color: #9eb9aa; background: #f4faf5; }
.settings-icon { display: grid; flex: none; width: 34px; height: 34px; place-items: center; border-radius: 11px; color: var(--forest); background: var(--mint); font-weight: 900; }
.danger-zone .settings-icon { color: var(--danger); background: #f8e3df; }
.about-panel { margin: 16px 16px 28px; padding: 12px 16px; border-radius: 16px; background: rgba(255,255,255,.5); }
.about-panel dl { margin: 0; }
.about-panel dl div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; font-size: .76rem; }
.about-panel dl div + div { border-top: 1px solid var(--line); }
.about-panel dt { color: var(--muted); }
.about-panel dd { margin: 0; text-align: right; font-weight: 700; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 0; display: grid; width: min(100%, 760px); grid-template-columns: repeat(4, 1fr); padding: 9px 8px calc(9px + env(safe-area-inset-bottom)); transform: translateX(-50%); border-top: 1px solid rgba(23,61,51,.12); background: rgba(255,253,248,.96); backdrop-filter: blur(18px); }
.nav-item { display: grid; justify-items: center; gap: 3px; min-height: 50px; padding: 5px; border: 0; border-radius: 13px; color: #7c8581; background: transparent; font-size: .68rem; font-weight: 800; }
.nav-item span:first-child { font-size: 1.05rem; }
.nav-item.is-active { color: var(--forest); background: var(--mint); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 11px 15px; transform: translate(-50%, 20px); border-radius: 13px; color: white; background: #233a32; box-shadow: 0 12px 30px rgba(0,0,0,.2); font-size: .8rem; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.toast[data-tone="warning"] { background: #8f4b32; }

@media (min-width: 620px) {
  .app-header { padding-left: max(24px, calc((100% - 720px) / 2)); padding-right: max(24px, calc((100% - 720px) / 2)); }
  .workout-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day-summary, .selection-panel, .page-heading { padding-left: 24px; padding-right: 24px; }
  .settings-card { grid-template-columns: 1fr auto; align-items: center; }
  .settings-card button { min-width: 150px; }
}

@media (max-width: 360px) {
  .app-header { padding-left: 13px; padding-right: 13px; }
  .selection-panel, .workout-list { padding-left: 12px; padding-right: 12px; }
  .day-summary { margin-left: 12px; margin-right: 12px; }
  .workout-card { padding: 15px; }
  .metrics-grid { gap: 6px; }
  .result-panel { grid-template-columns: 1fr; }
}

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