:root {
  --ink: #1F1F1D;
  --muted: #6B6B67;
  --line: #E9E9E6;
  --line-soft: #F1F1EF;
  --soft: #F4F4F1;
  --dash: #C9C9C4;
  --accent: #2E7D4F;
  --accent-soft: #EAF3EC;
  --memo: #FFF6D6;
  --danger: #B3261E;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #FFFFFF;
  color: var(--ink);
  font-family: 'Noto Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea { outline: 0; border: 0; min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, p, dl, dd { margin: 0; }
svg { flex: none; display: block; }
[hidden] { display: none !important; }

.page { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.pad { padding: 24px 20px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 28px; }
.center-msg { padding: 80px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* ---------- common pieces ---------- */
.icon-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px; flex: none; }
.icon-btn.muted { color: var(--muted); }
.topbar { height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.topbar .group { display: flex; }
.topbar.line { border-bottom: 1px solid var(--line); }
.text-btn { height: 44px; padding: 0 12px; display: flex; align-items: center; font-size: 15px; }
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.btn { height: 56px; border-radius: 14px; font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; }
.btn.primary { background: var(--accent); color: #FFFFFF; }
.btn.ghost { background: #FFFFFF; border: 1px solid var(--dash); }
.btn.soft { background: var(--soft); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.add-btn { height: 48px; border: 2px dashed var(--dash); border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--accent); width: 100%; }
.section-title { font-size: 18px; font-weight: 700; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.photo-ph { background: var(--line-soft); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #FFFFFF; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100vw - 40px); text-align: center; }

/* ---------- profile ---------- */
.profile-page { justify-content: center; gap: 40px; padding: 40px 28px; max-width: 480px; }
.profile-head { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.profile-head h1 { font-size: 28px; letter-spacing: -0.5px; }
.profile-head p, .profile-foot { font-size: 15px; color: var(--muted); text-align: center; }
.profile-foot { font-size: 13px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.profile-tile { height: 168px; border-radius: 20px; background: #F7F7F5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 18px; font-weight: 700; }
.profile-tile.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.profile-tile small { font-size: 13px; font-weight: 500; color: #3F5146; }

/* ---------- list ---------- */
.list-layout { min-height: 100dvh; }
.sidebar { display: none; }
.list-main { min-width: 0; display: flex; flex-direction: column; }
.list-head { padding: 28px 20px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-head h1 { font-size: 28px; letter-spacing: -0.5px; }
.profile-chip { width: 44px; height: 44px; border-radius: 50%; display: flex; flex: none; position: relative; }
.profile-chip::after { content: attr(data-tip); position: absolute; right: 0; top: calc(100% + 8px); background: var(--ink); color: #FFFFFF; font-size: 13px; font-weight: 500; line-height: 1.4; padding: 7px 11px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.12s; z-index: 6; }
.profile-chip:focus-visible::after { opacity: 1; }
@media (hover: hover) { .profile-chip:hover::after { opacity: 1; } }
.search { padding: 0 20px; position: relative; }
.search svg { position: absolute; left: 34px; top: 13px; color: var(--muted); }
.search-input { width: 100%; height: 46px; border-radius: 12px; background: var(--soft); padding: 0 16px 0 44px; -webkit-appearance: none; appearance: none; }
.filterbar { display: flex; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.chip-btn { height: 44px; padding: 0 14px; border: 1px solid var(--dash); border-radius: 22px; background: #FFFFFF; font-size: 15px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip-btn.strong { font-weight: 700; }
.chip-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.rows { display: flex; flex-direction: column; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.row { display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 20px; min-height: 88px; border-bottom: 1px solid var(--line-soft); }
.row-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; }
.fav-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #8A8A85; }
.fav-btn.on { color: var(--ink); }
.row .thumb { width: 68px; height: 68px; flex: none; border-radius: 12px; overflow: hidden; }
.row .thumb img, .cover img, .step-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .tag { font-size: 12px; font-weight: 700; color: var(--accent); }
.row .title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.fab { position: fixed; right: 20px; bottom: calc(28px + env(safe-area-inset-bottom)); height: 54px; padding: 0 22px 0 18px; border-radius: 27px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; box-shadow: 0 6px 16px rgba(46, 125, 79, 0.35); z-index: 5; }

/* ---------- bottom sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(31, 31, 29, 0.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 82dvh; overflow-y: auto; background: #FFFFFF; border-radius: 20px 20px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.sheet .grab { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--dash); flex: none; }
.sheet h2 { padding: 16px 0 8px; font-size: 18px; }
.sheet-row { display: flex; align-items: center; border-bottom: 1px solid var(--line-soft); }
.sheet-pick { flex: 1; min-width: 0; height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 16px; text-align: left; }
.sheet-pick.on { font-weight: 700; color: var(--accent); }
.sheet-pick .count { font-size: 14px; font-weight: 400; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.sheet-line { display: flex; justify-content: space-between; gap: 12px; min-height: 46px; align-items: center; border-bottom: 1px solid var(--line-soft); font-size: 16px; }
.sheet-line b { font-weight: 700; }
.newcat { display: flex; gap: 8px; margin-top: 12px; }
.newcat input { flex: 1; height: 48px; border-radius: 12px; background: var(--soft); padding: 0 14px; }
.newcat button { height: 48px; padding: 0 18px; border-radius: 12px; background: var(--accent); color: #FFFFFF; font-weight: 700; flex: none; }
.newcat button:disabled { opacity: 0.6; cursor: default; }

/* ---------- detail ---------- */
.cover { margin: 0 20px; height: 200px; flex: none; border-radius: 16px; overflow: hidden; }
.detail-title { font-size: 26px; letter-spacing: -0.5px; line-height: 1.3; }
.props { display: grid; grid-template-columns: 96px 1fr; font-size: 14px; }
.props dt, .props dd { min-height: 40px; display: flex; align-items: center; }
.props dt { color: var(--muted); }
.props dd { min-width: 0; overflow-wrap: anywhere; }
.props a { color: var(--accent); text-decoration: underline; }
.pill { background: var(--line-soft); border-radius: 6px; padding: 2px 8px; }
.sec { display: flex; flex-direction: column; gap: 4px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.sec-head h2 { font-size: 18px; }
.stepper { display: flex; align-items: center; background: var(--soft); border-radius: 22px; }
.stepper span { font-size: 15px; font-weight: 700; min-width: 48px; text-align: center; }
.ing { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; cursor: pointer; }
.ing input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.ing .name { flex: 1; min-width: 0; }
.ing .amount { font-weight: 700; }
.ing input:checked ~ .name, .ing input:checked ~ .amount { color: var(--muted); text-decoration: line-through; }
.steps { display: flex; flex-direction: column; gap: 18px; }
.step { display: flex; gap: 12px; }
.step-no { width: 28px; height: 28px; flex: none; border-radius: 14px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding-top: 2px; }
.step-body p { font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.step-photo { height: 160px; border-radius: 12px; overflow: hidden; }
.time-chip { align-self: flex-start; display: flex; align-items: center; gap: 5px; background: var(--accent-soft); border-radius: 8px; padding: 3px 10px; font-size: 13px; font-weight: 700; color: var(--accent); }
.memo { background: var(--memo); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.memo h2, .memo label { font-size: 14px; font-weight: 700; }
.memo p { font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- edit ---------- */
.photo-drop { height: 160px; width: 100%; border: 2px dashed var(--dash); border-radius: 16px; background: #FAFAF9; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 14px; }
.photo-set { position: relative; height: 200px; border-radius: 16px; overflow: hidden; }
.photo-set img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-set .tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 8px; }
.photo-set .tools button { width: 44px; height: 44px; border-radius: 22px; background: rgba(31, 31, 29, 0.8); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.title-input { width: 100%; padding: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; background: none; }
.form-grid { display: grid; grid-template-columns: 96px 1fr; align-items: center; row-gap: 8px; font-size: 14px; }
.form-grid > label, .form-grid > .lbl { color: var(--muted); }
.field { height: 46px; border-radius: 10px; background: var(--soft); padding: 0 14px; width: 100%; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 44px; padding: 0 14px; border-radius: 10px; background: var(--soft); font-size: 15px; }
.chip.on { background: var(--accent); color: #FFFFFF; font-weight: 700; }
.chip.add { width: 44px; padding: 0; border: 2px dashed var(--dash); background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.chips .newcat { margin: 0; width: 100%; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: var(--soft); border-radius: 12px; padding: 4px; }
.seg button { height: 44px; border-radius: 9px; font-size: 15px; }
.seg button.on { background: #FFFFFF; font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.num-field { display: flex; align-items: center; background: var(--soft); border-radius: 10px; width: max-content; }
.num-field span { min-width: 56px; text-align: center; font-size: 16px; font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.ing-edit { display: flex; align-items: center; gap: 8px; }
.ing-edit .field.amount { width: 96px; flex: none; font-weight: 700; }
.step-edit { display: flex; gap: 10px; align-items: flex-start; }
.step-edit .step-no { margin-top: 10px; }
.step-card { flex: 1; min-width: 0; background: var(--soft); border-radius: 12px; padding: 12px 6px 4px 14px; display: flex; flex-direction: column; gap: 6px; }
.step-card textarea { width: 100%; min-height: 56px; resize: vertical; background: none; padding: 0 8px 0 0; font-size: 16px; line-height: 1.6; }
.step-card .step-photo { height: 130px; margin-right: 8px; position: relative; }
.step-card .step-photo button { position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border-radius: 18px; background: rgba(31, 31, 29, 0.8); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.step-tools { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.step-tools .group { display: flex; align-items: center; }
.time-input { height: 36px; width: 104px; border-radius: 8px; background: #FFFFFF; padding: 0 10px; font-size: 14px; }
.memo textarea { width: 100%; min-height: 84px; resize: vertical; background: none; padding: 0; font-size: 15px; line-height: 1.6; }

/* ---------- cook mode ---------- */
.cook { height: 100dvh; min-height: 0; }
.cook .cook-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cook .progress-text { min-width: 44px; padding-right: 8px; text-align: right; font-size: 14px; color: var(--muted); flex: none; }
.bars { display: flex; gap: 6px; padding: 0 20px; flex: none; }
.bars span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.bars span.on { background: var(--accent); }
.cook-main { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 24px 12px; display: flex; flex-direction: column; gap: 20px; }
.cook-main .step-photo { height: 200px; flex: none; border-radius: 16px; }
.cook-label { font-size: 15px; font-weight: 700; color: var(--accent); }
.cook-text { font-size: 27px; font-weight: 700; line-height: 1.45; letter-spacing: -0.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cook-time { align-self: flex-start; background: var(--accent-soft); border-radius: 14px; padding: 10px 18px 10px 14px; display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: 24px; font-weight: 700; line-height: 1.2; }
.cook-foot { flex: none; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.cook-foot .link { height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; color: var(--muted); }
.cook-foot .btn { height: 64px; border-radius: 16px; font-size: 18px; }

/* ---------- wide screens ---------- */
@media (min-width: 900px) {
  .list-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; gap: 20px; background: #F7F7F5; padding: 28px 16px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
  .sidebar .brand { font-size: 20px; font-weight: 700; padding: 0 12px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .side-item { height: 44px; padding: 0 12px; border-radius: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 15px; text-align: left; width: 100%; }
  .side-item .count { color: var(--muted); font-weight: 400; }
  .side-item.on { background: #FFFFFF; font-weight: 700; color: var(--accent); }
  .side-row { display: flex; align-items: center; }
  .side-row .side-item { flex: 1; min-width: 0; }
  .sidebar .newcat { flex-direction: column; }
  .sidebar .newcat input { flex: none; background: #FFFFFF; }
  .list-head { padding: 28px 48px 14px; }
  .list-head h1 { font-size: 26px; }
  .search { padding: 0 48px; max-width: 640px; }
  .search svg { left: 62px; }
  .filterbar { display: none; }
  .rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px 20px; padding: 24px 48px 120px; }
  .row { display: block; padding: 0; border: 0; min-height: 0; position: relative; }
  .row-link { flex-direction: column; align-items: stretch; gap: 10px; }
  .row .thumb { width: 100%; height: 160px; border-radius: 14px; }
  .fav-btn { position: absolute; right: 8px; top: 8px; background: #FFFFFF; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
  .rows .center-msg { grid-column: 1 / -1; }
  .fab { right: 40px; bottom: 36px; }
  .cover { height: 320px; }
  .step-photo { height: 260px; }
  .photo-set { height: 320px; }
}
