@font-face {
    font-family: 'GowunBatang-Regular';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2108@1.1/GowunBatang-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --default-font: 'GowunBatang-Regular', serif;
    /* 테마 변수는 recipe.js의 THEMES에서 덮어씁니다 */
    --bg: #FFCCBC;
    --surface: #FFF4EF;
    --text: #2B1D1A;
    --sub: #7A5A52;
    --accent: #FF8A80;
    --accent-text: #2B1D1A;
    --line: #0000001f;
    --overlay: #00000026;
    --radius: .75rem;
    --topbar-h: 3.5rem;
    --nav-h: 3.6rem;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--default-font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    -webkit-tap-highlight-color: transparent;
    transition: background-color .3s;
}
body.no-scroll { overflow: hidden; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hide { display: none !important; }

/* y접힘 / x접힘 (파티노트와 동일) */
.collapse-y {
    max-height: 0 !important;
    overflow: hidden;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-width: 0 !important;
}
.collapse-x {
    max-width: 0 !important;
    overflow: hidden;
}

.scroll::-webkit-scrollbar { width: 6px; height: 0; }
.scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 1rem; }
.scroll:hover::-webkit-scrollbar-thumb { background: var(--overlay); }

/* ---------- 탑바 ---------- */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) .5rem 0 .75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg);
    box-shadow: inset 0 -100px 0 var(--overlay);
}
.logo-cover {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.35rem;
    font-weight: bold;
    min-width: 0;
}
.logo-img { width: 1.6rem; height: 1.6rem; border-radius: .35rem; }
.logo-text { white-space: nowrap; }
.right-position { display: flex; align-items: center; }

.top-bar-btn {
    position: relative;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.top-bar-btn:hover, .top-bar-btn.active { background-color: #0000002b; }
.top-bar-btn .badge {
    position: absolute;
    top: .3rem;
    right: .25rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 .25rem;
    border-radius: 1rem;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .65rem;
    font-weight: bold;
    line-height: 1.05rem;
    font-family: system-ui, sans-serif;
}
.top-bar-btn .badge:empty { display: none; }

/* ---------- 검색 ---------- */
.search-banner {
    position: sticky;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    z-index: 15;
    max-height: 5rem;
    background-color: var(--bg);
    box-shadow: inset 0 -100px 0 #00000014;
    transition: max-height .35s ease;
}
.search-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .5rem .75rem;
    padding: 0 .25rem 0 .75rem;
    border: 1px solid var(--text);
    border-radius: 2rem;
    background: var(--surface);
}
.search-inner > i { color: var(--sub); font-size: .9rem; }
#recipe-searcher {
    flex: 1;
    min-width: 0;
    border: 0;
    padding: .55rem 0;
    background: transparent;
    outline: none;
}
#recipe-searcher::-webkit-search-cancel-button { display: none; }
.search-deleter {
    border: 0;
    background: transparent;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
}

/* ---------- 필터 ---------- */
.filter-panel {
    max-height: 40rem;
    transition: max-height .35s ease;
    border-bottom: 1px solid var(--line);
}
.filter-inner {
    padding: .75rem .75rem .5rem;
    max-width: 1200px;
    margin: 0 auto;
}
.filter-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
}
#sort-select {
    border: 1px solid var(--line);
    border-radius: 2rem;
    padding: .3rem .6rem;
    background: var(--surface);
    font-size: .85rem;
}
.filter-row { margin-bottom: .5rem; }
.filter-label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .85rem;
    font-weight: bold;
    color: var(--sub);
    margin-bottom: .3rem;
}
.filter-row .chips {
    display: flex;
    gap: .35rem;
    overflow-x: auto;
    padding-bottom: .25rem;
    scrollbar-width: none;
}
.filter-row .chips::-webkit-scrollbar { display: none; }
.empty-hint { font-size: .8rem; color: var(--sub); }

.text-btn {
    border: 0;
    background: transparent;
    padding: .2rem .4rem;
    font-size: .8rem;
    color: var(--sub);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.filter-head .text-btn { margin-left: auto; }

/* ---------- 칩(태그) ---------- */
.chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .28rem .7rem;
    border: 1px solid var(--line);
    border-radius: 2rem;
    background: var(--surface);
    font-size: .85rem;
    white-space: nowrap;
    line-height: 1.3;
}
button.chip:hover { border-color: var(--text); }
.chip.on {
    background: var(--accent);
    color: var(--accent-text);
    border-color: transparent;
    font-weight: bold;
}
.chip .count {
    font-size: .7rem;
    opacity: .6;
    font-family: system-ui, sans-serif;
}
.chip.mini { padding: .08rem .5rem; font-size: .75rem; }
.chip-x {
    border: 0;
    background: transparent;
    padding: 0 0 0 .1rem;
    font-size: .75rem;
    opacity: .7;
}
.favorite-filter.on i { color: inherit; }
.favorite-filter i { color: #F9A825; }

/* ---------- 목록 ---------- */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: .5rem .75rem calc(var(--nav-h) + 6rem + env(safe-area-inset-bottom)); /* 아래 탭 + 추첨 버튼 자리 */
}
.result-count {
    font-size: .8rem;
    color: var(--sub);
    margin: .25rem .1rem .6rem;
}
.recipe-container.box-style {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
    gap: .75rem;
}
.recipe-container.list-style {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.recipe-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 0 0 1px var(--line);
    transition: transform .25s ease, box-shadow .25s ease;
}
.recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: 1px 3px 10px var(--overlay);
}
.card-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #ffffff33;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-letter {
    font-size: 3rem;
    font-weight: bold;
    opacity: .35;
}
.card-fav {
    position: absolute;
    top: .5rem;
    right: .55rem;
    color: #F9A825;
    filter: drop-shadow(0 0 2px #0006);
}
.card-body {
    padding: .65rem .75rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
}
.card-title {
    margin: 0;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-meta {
    display: flex;
    gap: .6rem;
    font-size: .78rem;
    opacity: .75;
    flex-wrap: wrap;
}
.card-methods { display: flex; gap: .25rem; flex-wrap: wrap; }
.card-methods .chip { background: #ffffff66; }
.card-methods .chip.on { background: var(--accent); }
.card-ingredients {
    font-size: .8rem;
    opacity: .85;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.card-ingredients .hit {
    font-weight: bold;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
}

/* 리스트 레이아웃 */
.list-style .recipe-card { flex-direction: row; }
.list-style .card-thumb {
    width: 6.5rem;
    min-height: 6.5rem;
    aspect-ratio: auto;
    flex-shrink: 0;
}
.list-style .thumb-letter { font-size: 2.2rem; }
.list-style .card-body { flex: 1; justify-content: center; }

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--sub);
}
.empty-state > i { font-size: 2.5rem; opacity: .5; }
.empty-state p { margin: .75rem 0 1.25rem; }

/* ---------- 버튼 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: .5rem;
    border: 1px solid var(--text);
    background: transparent;
    font-weight: bold;
    font-size: .9rem;
}
.btn:hover { filter: brightness(.92); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: #E53935; color: #fff; border-color: transparent; }
.btn.danger-ghost { color: #E53935; border-color: #E53935; }
.btn.ghost { background: var(--surface); border-color: var(--line); }

.icon-btn {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.icon-btn:hover { background: var(--overlay); }
.icon-btn.solid { background: var(--accent); color: var(--accent-text); }

/* ---------- 팝업 ---------- */
.popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: #00000055;
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.popup {
    width: 100%;
    max-width: 720px;
    height: 100%;
    max-height: 60rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 1px 1px 12px #0000006e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pop-in .2s ease;
}
@keyframes pop-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .5rem .5rem 1rem;
    min-height: 3.25rem;
    border-bottom: 1px solid var(--line);
}
.popup-header .title {
    font-size: 1.15rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.popup-header .actions { display: flex; }
.popup-header .fa-star.fas { color: #F9A825; }
.popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    overscroll-behavior: contain;
}

/* ---------- 상세 ---------- */
.detail section { margin-top: 1.5rem; }
.detail h4 {
    display: flex;
    align-items: baseline;
    gap: .4rem;
    margin: 0 0 .6rem;
    font-size: 1rem;
}
.detail h4 i { color: var(--accent); width: 1.1rem; text-align: center; }
.detail h4 small { font-weight: normal; font-size: .75rem; color: var(--sub); margin-left: .25rem; }
.detail-photo {
    width: 100%;
    max-height: 24rem;
    object-fit: cover;
    border-radius: var(--radius);
    display: block;
    margin-bottom: 1rem;
}
.detail-summary { margin: 0 0 .75rem; font-size: 1.02rem; }
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.detail-meta span {
    padding: .3rem .7rem;
    border-radius: .5rem;
    background: var(--bg);
    font-size: .85rem;
}
.chips.wrap { display: flex; flex-wrap: wrap; gap: .35rem; }

.check-list, .step-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.check-list li label, .step-list li label {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    cursor: pointer;
}
.check-list input, .step-list input { display: none; }
.check-list.ingredients {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    column-gap: 1.5rem;
}
.check-list li label {
    padding: .45rem .1rem;
    border-bottom: 1px dashed var(--line);
    align-items: center;
}
.check-list li label::before {
    content: '';
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--sub);
    border-radius: .25rem;
    flex-shrink: 0;
}
.check-list input:checked ~ span { text-decoration: line-through; opacity: .45; }
.check-list li:has(input:checked) label::before { background: var(--accent); border-color: var(--accent); }
.ing-name { font-weight: bold; }
.check-list .ing-amount { margin-left: auto; color: var(--sub); font-size: .9rem; text-align: right; }

.step-list li label {
    padding: .7rem 0;
    border-bottom: 1px solid var(--line);
}
.step-no {
    flex-shrink: 0;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: .85rem;
    font-family: system-ui, sans-serif;
}
.step-text { white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; padding-top: .1rem; }
.step-list input:checked ~ .step-text { opacity: .4; text-decoration: line-through; }
.step-list input:checked ~ .step-no { opacity: .4; }
.detail-tips {
    margin: 0;
    padding: .75rem 1rem;
    border-radius: .5rem;
    background: var(--bg);
    white-space: pre-wrap;
}
.detail-date {
    margin-top: 2rem;
    font-size: .75rem;
    color: var(--sub);
    text-align: right;
}

/* ---------- 편집기 ---------- */
.editor {
    display: flex;
    flex-direction: column;
    gap: .9rem;
}
.editor input[type="text"], .editor input[type="number"], .editor select, .editor textarea {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    padding: .5rem .25rem;
    outline: none;
    border-radius: 0;
}
.editor input:focus, .editor select:focus, .editor textarea:focus { border-bottom-color: var(--accent); }
.editor textarea {
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .5rem .6rem;
    resize: none; /* 글 길이에 맞춰 자동으로 늘어남 (ui.js autoGrow) */
    overflow: hidden;
    line-height: 1.6;
}
.editor ::placeholder { color: var(--sub); opacity: .75; }
.title-input { font-size: 1.3rem; font-weight: bold; }

.field-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
}
.field { display: flex; flex-direction: column; gap: .4rem; }
.field-label {
    font-size: .8rem;
    font-weight: bold;
    color: var(--sub);
    display: flex;
    align-items: center;
    gap: .35rem;
}
.field > .field-label { font-size: .9rem; color: var(--text); }
.field > .field-label i { color: var(--accent); }
.field-hint { font-size: .75rem; color: var(--sub); }

.photo-picker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 7rem;
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    color: var(--sub);
    cursor: pointer;
    overflow: hidden;
}
.photo-picker.has-photo { height: 13rem; border-style: solid; }
.photo-preview { display: none; width: 100%; height: 100%; object-fit: cover; }
.photo-remove { display: none; position: absolute; top: .5rem; right: .5rem; }
.photo-picker.has-photo .photo-preview,
.photo-picker.has-photo .photo-remove { display: flex; }
.photo-picker.has-photo .photo-empty { display: none; }

/* 태그 입력기 */
.tag-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    padding: .4rem .5rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    cursor: text;
}
.tag-box:focus-within { border-color: var(--accent); }
.tag-list { display: contents; }
.editor .tag-box input[type="text"] {
    flex: 1;
    min-width: 8rem;
    border: 0;
    padding: .2rem;
}
.tag-suggest {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}
.tag-suggest:empty { display: none; }
.tag-suggest .chip { background: transparent; font-size: .78rem; padding: .18rem .55rem; color: var(--sub); }

/* 재료 입력기 */
.ingredient-input { display: flex; flex-direction: column; gap: .45rem; }
.ing-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.ing-list li { display: flex; align-items: center; gap: .35rem; }
.ing-list .chip { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
/* 재료 이름: 칩 모양이지만 눌러서 바로 고칠 수 있는 입력칸 */
.editor .ing-list .ing-name-inline {
    width: auto;
    flex: 1.4 1 0; /* 이름 : 양 = 1.4 : 1 */
    min-width: 0;
    padding: .28rem .7rem;
    border: 1px solid transparent;
    border-radius: 2rem;
    background: var(--accent); /* .editor input 공통 스타일(투명 배경)보다 우선 */
    color: var(--accent-text);
    font-weight: bold;
    cursor: text;
}
.editor .ing-list li.optional .ing-name-inline {
    background: transparent;
    color: var(--text);
    border: 1px dashed var(--accent);
}
.editor .ing-list .ing-name-inline:focus {
    border: 1px solid var(--text);
    background: var(--surface);
    color: var(--text);
}
/* 양: 눌러서 고칠 수 있는 칸이라는 게 보이도록 점선 테두리 */
.editor .ing-list .ing-amount-inline {
    flex: 1 1 0;
    min-width: 0;
    padding: .3rem .5rem;
    font-size: .9rem;
    border: 1px dashed var(--line);
    border-radius: .45rem;
    cursor: text;
}
.editor .ing-list .ing-amount-inline:hover { border-color: var(--sub); }
.editor .ing-list .ing-amount-inline:focus { border: 1px solid var(--text); background: var(--surface); }
.ing-list .icon-btn { width: 1.9rem; height: 1.9rem; font-size: .8rem; opacity: .7; }
.ing-row { display: flex; gap: .5rem; align-items: center; }
.editor .ing-row .ing-name { flex: 3; }
.editor .ing-row .ing-amount { flex: 2; }

/* 단계 입력기 */
.step-editor { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.step-editor li { display: flex; align-items: flex-start; gap: .5rem; }
.step-editor .step-no { margin-top: .4rem; }
.step-editor textarea { flex: 1; }
.step-tools { display: flex; flex-direction: column; }
.step-tools .icon-btn { width: 1.8rem; height: 1.6rem; font-size: .75rem; opacity: .7; border-radius: .3rem; }
.add-step { align-self: flex-start; }

.editor-btns {
    position: sticky;
    bottom: -1rem;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin: .5rem -1rem -1rem;
    padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
}

/* ---------- 메뉴 드로어 ---------- */
.menu-overlay {
    position: fixed;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    z-index: 30;
    display: flex;
    justify-content: flex-end;
    overflow: hidden;
    transition: visibility 0s;
}
/* 어두운 배경만 따로 서서히 (메뉴 판은 비치지 않게 항상 불투명) */
.menu-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #00000040;
    transition: opacity .28s ease;
}
/* 닫힌 상태: 공용 .collapse-x(max-width: 0)를 쓰지 않고, 다 빠져나간 뒤에 숨김 */
.menu-overlay.collapse-x {
    max-width: 100vw !important;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s .28s;
}
.menu-overlay.collapse-x::before { opacity: 0; }
.menu-screen {
    position: relative; /* 어두운 배경(::before) 위에 */
    width: min(22rem, 100vw);
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    padding: 1rem 1.1rem 2rem;
    background: var(--bg);
    box-shadow: -2px 0 10px var(--overlay);
    /* 오른쪽에서 미끄러져 들어오고, 같은 길로 나감 */
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
}
.menu-overlay.collapse-x .menu-screen { transform: translateX(100%); }
/* 기기의 '동작 줄이기' 설정과 상관없이 움직입니다. (사용자가 원한 효과인데 그 설정 때문에 꺼져 보였음)
   메뉴·선택창·룰렛·폭죽 모두 같은 방침 */
.menu-screen h3 { margin: 1.75rem 0 .25rem; }
.menu-screen h3:first-child { margin-top: 0; }
.config-caption { font-size: .85rem; color: var(--sub); margin-bottom: .5rem; }
.radio-group { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.radio-group label { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.radio-group input { accent-color: var(--accent); }
.menu-btn-group { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }

/* ---------- 토스트 / 다이얼로그 ---------- */
.toast-zone {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    pointer-events: none;
}
.toast {
    padding: .6rem 1.1rem;
    border-radius: 2rem;
    background: var(--text);
    color: var(--surface);
    font-size: .9rem;
    box-shadow: 0 2px 10px #0004;
    animation: pop-in .2s ease;
    transition: opacity .4s;
    white-space: nowrap;
}
.toast.out { opacity: 0; }

.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: #00000066;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.dialog {
    width: min(22rem, 100%);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 4px 20px #0005;
    animation: pop-in .15s ease;
}
.dialog-message { white-space: pre-line; margin-bottom: 1.25rem; }
.dialog-btns { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- 모바일 ---------- */
@media (max-width: 768px) {
    .popup-overlay { padding: 0; }
    .popup {
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
    }
    .recipe-container.box-style { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .box-style .card-body { padding: .5rem .6rem .6rem; }
    .box-style .card-title { font-size: .95rem; }
    .box-style .card-ingredients { display: none; }
    .field-grid { gap: .5rem; }
    .check-list.ingredients { grid-template-columns: 1fr; }
}

/* ---------- 선택 재료 ---------- */
.opt-toggle {
    flex-shrink: 0;
    padding: .15rem .5rem;
    border: 1px dashed var(--sub);
    border-radius: 2rem;
    background: transparent;
    font-size: .72rem;
    color: var(--sub);
}
.opt-toggle.on {
    border-style: solid;
    border-color: var(--text);
    background: var(--text);
    color: var(--surface);
}
.ing-list li.optional .chip {
    background: transparent;
    color: var(--text);
    border: 1px dashed var(--accent);
}
.card-ingredients .opt { opacity: .6; }
.card-ingredients .opt::after { content: '(선택)'; font-size: .85em; }

/* ---------- 분류 ---------- */
/* 스크롤해도 위쪽 바(검색창이 열려 있으면 그 아래)에 붙어 있음 */
.category-tabs {
    position: sticky;
    top: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--search-h, 0px));
    z-index: 14;
    display: flex;
    gap: .25rem;
    margin: .25rem -.75rem .5rem; /* 양옆 여백까지 배경으로 덮어 카드가 비치지 않게 */
    padding: 0 .75rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
    transition: top .35s ease;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .55rem .9rem;
    border: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--sub);
    font-size: .95rem;
}
.category-tab:hover { color: var(--text); }
.category-tab.on {
    color: var(--text);
    font-weight: bold;
    border-bottom-color: var(--accent);
}
.category-tab .count {
    font-size: .72rem;
    font-family: system-ui, sans-serif;
    opacity: .7;
}
.card-category {
    position: absolute;
    top: .45rem;
    left: .45rem;
    padding: .1rem .5rem;
    border-radius: 2rem;
    background: var(--surface);
    color: var(--text);
    font-size: .7rem;
    opacity: .9;
}

.segmented {
    display: flex;
    border: 1px solid var(--line);
    border-radius: .6rem;
    padding: .2rem;
    gap: .2rem;
}
.segmented label { flex: 1; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem;
    border-radius: .45rem;
    color: var(--sub);
    font-size: .9rem;
}
.segmented input:checked + span {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: bold;
}
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- 메뉴 추첨 ---------- */
.emoji {
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    font-style: normal;
    line-height: 1;
}
.lottery-fab {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right));
    bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); /* 아래 탭 바로 위 */
    z-index: 25;
    width: 3.6rem;
    height: 3.6rem;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 3px 12px #00000040;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease;
}
.lottery-fab .emoji { font-size: 1.7rem; }
.lottery-fab:hover { transform: scale(1.06) rotate(-8deg); }
.lottery-fab:active { transform: scale(.94); }
.lottery-fab .badge {
    position: absolute;
    top: -.15rem;
    right: -.15rem;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 .3rem;
    border-radius: 1rem;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 0 0 2px var(--accent);
    font-size: .72rem;
    font-weight: bold;
    line-height: 1.35rem;
    font-family: system-ui, sans-serif;
}

/* 추첨 팝업은 모바일에서도 가운데 작은 카드 */
.popup[data-variant="lottery"] {
    max-width: 24rem;
    height: auto;
    max-height: calc(100% - 2rem);
    border-radius: var(--radius);
    overflow: visible;
}
.popup[data-variant="lottery"] .popup-header { border-bottom: 0; padding-bottom: 0; min-height: 2.75rem; }
.popup[data-variant="lottery"] .popup-header .title { display: flex; align-items: center; gap: .4rem; }
.popup[data-variant="lottery"] .popup-header .emoji { font-size: 1.4rem; }
.popup[data-variant="lottery"] .popup-content { overflow: visible; padding-top: .25rem; }
.lottery-title-text {
    display: inline-block; /* transform 애니메이션은 inline 요소에 안 먹음 */
    font-size: 1.2rem;
    font-weight: bold;
    animation: winner-pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
.lottery-title-text:empty { display: none; }

.lottery { position: relative; }
.lottery-reel {
    height: 9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--bg);
    overflow: hidden;
    text-align: center;
    padding: 0 1rem;
}
.lottery-reel span {
    font-size: 1.5rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lottery-reel span.tick { animation: reel-tick .12s ease-out; }
.lottery-reel span.landed {
    /* 글자색은 그대로 두고 형광펜처럼 밑줄 강조 (배경과 강조색이 비슷한 테마 대비) */
    box-shadow: inset 0 -.4em 0 var(--accent);
    padding: 0 .15em;
}
@keyframes reel-tick {
    from { transform: translateY(-60%); opacity: .2; }
    to { transform: none; opacity: 1; }
}

.lottery-result { animation: winner-pop .55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes winner-pop {
    0% { transform: scale(.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.lottery-card {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card);
    box-shadow: 0 0 0 1px var(--line), 0 6px 18px var(--overlay);
}
.lottery-thumb {
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff33;
    overflow: hidden;
}
.lottery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lottery-thumb .thumb-letter { font-size: 4rem; }
.lottery-body { padding: .75rem .9rem .9rem; display: flex; flex-direction: column; gap: .35rem; }
.lottery-category { font-size: .75rem; opacity: .75; }
.lottery-title { margin: 0; font-size: 1.35rem; }
.lottery-ingredients { font-size: .82rem; opacity: .85; }
.lottery-body .card-methods .chip { background: #ffffff66; }
.lottery-btns {
    display: flex;
    gap: .5rem;
    margin-top: .9rem;
}
.lottery-btns .btn { flex: 1; }

.confetti-layer {
    position: absolute;
    left: 50%;
    top: 40%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 5;
}
.confetti {
    position: absolute;
    width: .55rem;
    height: .8rem;
    border-radius: 2px;
    opacity: 0;
    animation: confetti-fly var(--d) cubic-bezier(.15, .7, .3, 1) forwards;
}
@keyframes confetti-fly {
    0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
    75% { opacity: 1; }
    100% { transform: translate(var(--x), calc(var(--y) + 120px)) rotate(var(--r)) scale(1); opacity: 0; }
}

@media (max-width: 768px) {
    .popup-overlay:has(.popup[data-variant="lottery"]) { padding: 1rem; }
    .popup[data-variant="lottery"] { padding-top: 0; }
}

/* ---------- 이름만 레이아웃 ---------- */
.title-fav { display: none; }
.recipe-container.name-style {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: .4rem;
}
.name-style .recipe-card {
    flex-direction: row;
    border-left: .45rem solid var(--card);
    background: var(--surface);
}
.name-style .recipe-card:hover { transform: none; }
.name-style .card-thumb,
.name-style .card-meta,
.name-style .card-methods,
.name-style .card-ingredients { display: none; }
.name-style .card-body {
    flex: 1;
    padding: .7rem .8rem;
}
.name-style .card-title {
    font-size: 1rem;
    font-weight: bold;
}
.name-style .title-fav {
    display: inline;
    color: #F9A825;
    font-size: .8em;
    margin-right: .35rem;
}
@media (max-width: 768px) {
    .recipe-container.name-style { grid-template-columns: 1fr; }
}

/* ---------- 전체 삭제 (메뉴 맨 아래) ---------- */
.danger-zone {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px dashed #E5393566;
}
.danger-zone h3 { margin-top: 0; color: #E53935; }
.dialog-typed {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin: -.5rem 0 1.25rem;
    font-size: .88rem;
}
.dialog-typed b { color: #E53935; }
.dialog-typed input {
    padding: .55rem .65rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--bg);
    outline: none;
}
.dialog-typed input:focus { border-color: #E53935; }
.btn:disabled { opacity: .35; cursor: not-allowed; filter: none; }

/* ---------- 장바구니 ---------- */
.shopping { display: flex; flex-direction: column; gap: .4rem; }
.shop-add-row { display: flex; gap: .5rem; align-items: center; }
.shop-input {
    flex: 1;
    min-width: 0;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    background: var(--bg);
    outline: none;
}
.shop-input:focus { border-color: var(--accent); }
.shop-body { margin-top: .5rem; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li {
    display: flex;
    align-items: center;
    border-bottom: 1px dashed var(--line);
}
.shop-item {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .75rem .25rem;
    border: 0;
    background: transparent;
    text-align: left;
}
.shop-check {
    flex-shrink: 0;
    width: 1.3rem;
    height: 1.3rem;
    border: 1.5px solid var(--sub);
    border-radius: .35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    color: transparent;
}
.shop-text { overflow-wrap: anywhere; font-size: 1.02rem; }
.shop-list li.checked .shop-check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.shop-list li.checked .shop-text { text-decoration: line-through; opacity: .45; }
.shop-list .icon-btn { opacity: .55; font-size: .85rem; }
.shop-done-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 1.25rem 0 .1rem;
    font-size: .82rem;
    font-weight: bold;
    color: var(--sub);
}
.shop-done-head .text-btn { margin: 0; }
.shop-empty, .shop-all-done {
    text-align: center;
    color: var(--sub);
    padding: 2rem 0 1rem;
}
.shop-empty > i { font-size: 2rem; opacity: .5; }
.shop-empty p { margin: .6rem 0 0; }
.shop-all-done { padding: 1rem 0 .25rem; font-weight: bold; }

/* 탑바 버튼이 5개라 좁은 화면에서는 조금 작게 */
@media (max-width: 480px) {
    .top-bar-btn { width: 2.45rem; height: 2.45rem; font-size: 1rem; }
    .logo-cover { font-size: 1.15rem; gap: .4rem; }
    .logo-img { width: 1.4rem; height: 1.4rem; }
}
@media (max-width: 350px) {
    .logo-text { display: none; }
}

/* 메모 속 외부 링크 */
.ext-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
    word-break: break-all;
}
.ext-link::after {
    content: '\f35d'; /* fa-external-link-alt */
    display: inline-block; /* 밑줄이 아이콘까지 이어지지 않게 */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: .7em;
    margin-left: .3em;
    opacity: .6;
}
.dialog-message { overflow-wrap: anywhere; }

/* ---------- 화면 전환 (아래 탭) ---------- */
/* 지금 탭이 아닌 화면과, 레시피 화면 전용 도구(검색·필터·새 레시피·추첨)는 숨김 */
body:not([data-view="recipes"]) .view-recipes,
body:not([data-view="meals"]) .view-meals,
body:not([data-view="shopping"]) .view-shopping,
body:not([data-view="recipes"]) .search-banner,
body:not([data-view="recipes"]) .filter-panel,
body:not([data-view="recipes"]) .search-btn,
body:not([data-view="recipes"]) .filter-toggle,
body:not([data-view="recipes"]) .recipe-writer,
body:not([data-view="recipes"]) .lottery-fab {
    display: none !important;
}
.view-meals, .view-shopping { max-width: 720px; }
.view-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .5rem 0 1rem;
    font-size: 1.25rem;
}
.view-title i { color: var(--accent); }

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 26;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: var(--bg);
    box-shadow: inset 0 100px 0 #00000014, 0 -1px 0 var(--line);
}
.bottom-nav button {
    position: relative;
    flex: 1;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    color: var(--sub);
    font-size: .72rem;
}
.bottom-nav button i { font-size: 1.15rem; }
.bottom-nav button[aria-current="page"] { color: var(--text); font-weight: bold; }
.bottom-nav button[aria-current="page"] i { color: var(--accent); }
.bottom-nav .badge {
    position: absolute;
    top: .35rem;
    left: calc(50% + .45rem);
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 .25rem;
    border-radius: 1rem;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .65rem;
    font-weight: bold;
    line-height: 1.05rem;
    font-family: system-ui, sans-serif;
}
.bottom-nav .badge:empty { display: none; }

/* ---------- 식단 ---------- */
.meal-week-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin: .25rem 0 .75rem;
}
.meal-week-label { font-weight: bold; font-size: 1.05rem; padding: 0 .25rem; }
.meal-this-week { margin-left: auto; }
.meal-days { display: flex; flex-direction: column; gap: .5rem; }
.meal-day {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 0 0 1px var(--line);
    padding: .35rem .5rem .35rem .85rem;
}
.meal-day.today { box-shadow: 0 0 0 2px var(--accent); }
.meal-day-head { display: flex; align-items: center; gap: .45rem; min-height: 2.25rem; }
.meal-weekday { font-weight: bold; font-size: 1.05rem; }
.meal-weekday.sun { color: #E53935; }
.meal-weekday.sat { color: #1E88E5; }
[data-theme="cryptic"] .meal-weekday.sun { color: #FF6E6E; }
[data-theme="cryptic"] .meal-weekday.sat { color: #6EB6FF; }
.meal-date { color: var(--sub); font-size: .88rem; font-family: system-ui, sans-serif; }
.meal-today {
    padding: .05rem .5rem;
    border-radius: 2rem;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .7rem;
    font-weight: bold;
}
.meal-add { margin-left: auto; opacity: .7; }
.meal-list { list-style: none; margin: 0 0 .3rem; padding: 0; }
.meal-list li {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .2rem 0;
    border-top: 1px dashed var(--line);
}
.meal-slot {
    flex-shrink: 0;
    min-width: 2.6rem;
    text-align: center;
    padding: .08rem .45rem;
    border-radius: 2rem;
    background: var(--bg);
    font-size: .75rem;
    font-weight: bold;
}
.meal-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.meal-title.linked { cursor: pointer; }
.meal-del { width: 1.9rem; height: 1.9rem; font-size: .8rem; opacity: .5; }

.popup[data-variant="meal"] {
    max-width: 26rem;
    height: auto;
    max-height: calc(100% - 2rem);
    border-radius: var(--radius);
}
.popup[data-variant="meal"] .popup-content { overflow: visible; }
.meal-form { display: flex; flex-direction: column; gap: .75rem; }
.meal-slots span { padding: .45rem .2rem; font-size: .85rem; }
.meal-name-input {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    background: var(--bg);
    outline: none;
    font-size: 1rem;
}
.meal-name-input:focus { border-color: var(--accent); }
.meal-suggest .chip { font-size: .8rem; }
@media (max-width: 768px) {
    .popup-overlay:has(.popup[data-variant="meal"]) { padding: 1rem; align-items: flex-start; padding-top: 12vh; }
    .popup[data-variant="meal"] { padding-top: 0; }
}
.dialog-btns.wrap { flex-wrap: wrap; }
.dialog-btns.stack { flex-direction: column; align-items: stretch; }

/* 식단 탭 맨 아래: 3주 전 식단 비우기 */
.meal-clear { margin-top: 1.25rem; text-align: center; }

/* ---------- 식사 일기 ---------- */
/* 꾸미기 스티커: 이모지 또는 img/stickers/sticker_N.png (도트 그림은 뭉개지지 않게 pixelated, 정수배로만 확대) */
.sticker { display: inline-block; flex-shrink: 0; line-height: 1; vertical-align: middle; }
img.sticker { image-rendering: pixelated; object-fit: contain; }
img.sticker.broken { visibility: hidden; }
.sticker.sm { font-size: 1.35rem; }
img.sticker.sm { width: 32px; height: 32px; }
.sticker.lg { font-size: 3rem; }
img.sticker.lg { width: 64px; height: 64px; }

/* 맛 평가: 색이 입혀진 태그 */
.rating-tag {
    display: inline-block;
    padding: .35rem .8rem;
    border: 2px solid transparent;
    border-radius: .5rem;
    color: #3A2A26;
    font-size: .9rem;
    font-weight: bold;
    white-space: nowrap;
}
.rating-tag.yum { background: #FF8A80; }
.rating-tag.ok { background: #FFD54F; }
.rating-tag.healthy { background: #C5E1A5; color: #2E6B1F; } /* 연두 바탕 + 초록 글씨 */
.rating-tag.again { background: #A9D4F5; color: #1A4F8A; }   /* 하늘 바탕 + 파란 글씨 */
.rating-tag.bad { background: #B0BEC5; }
.rating-tag.sm { padding: .05rem .45rem; border-width: 0; border-radius: .35rem; font-size: .68rem; vertical-align: middle; }

.meal-title { cursor: pointer; padding: .3rem 0; }
.meal-has-diary { color: var(--sub); font-size: .9rem; }

.diary { display: flex; flex-direction: column; gap: 1rem; }
.diary-pane { display: flex; flex-direction: column; gap: 1rem; }
.diary-tabs { display: flex; gap: .4rem; }
.diary-tab {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .8rem;
    border: 1px solid var(--line);
    border-radius: 2rem;
    background: transparent;
    color: var(--sub);
    font-size: .85rem;
}
.diary-tab.on {
    background: var(--accent);
    color: var(--accent-text);
    border-color: transparent;
    font-weight: bold;
}
.diary-tab:disabled { opacity: .4; cursor: not-allowed; }
.diary-food { margin: 0; font-size: 1.3rem; }

/* 스티커 기울기 네 가지 (보여 줄 때마다 무작위로 하나, 저장하지 않음) */
.sticker.tilt-0 { transform: rotate(-12deg); }
.sticker.tilt-1 { transform: rotate(-5deg); }
.sticker.tilt-2 { transform: rotate(6deg); }
.sticker.tilt-3 { transform: rotate(12deg); }

/* 조회 화면: 평가 태그 + 스티커 한 줄 */
/* 왼쪽 끝에 평가, 오른쪽 끝에 스티커 (평가가 없어도 스티커는 오른쪽) */
.diary-marks { display: flex; align-items: center; gap: 1rem; min-height: 2rem; }
.sticker-pop {
    margin-left: auto;
    margin-right: .5rem;
    padding: 0;
    border: 0;
    background: transparent;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
/* 스티커를 누르면 떨어지는 작은 조각들 (화면에 고정된 층, 누르는 것을 방해하지 않음) */
.sticker-particles { position: fixed; z-index: 66; width: 0; height: 0; pointer-events: none; }
.sticker.particle { position: absolute; left: 0; top: 0; opacity: 0; font-size: 1rem; will-change: transform, opacity; }
img.sticker.particle { width: 16px; height: 16px; }
.diary .detail-photo { margin-bottom: 0; }

/* 편집 화면: 맛 평가 / 스티커 칸 - ( + ) 또는 고른 것 하나만 */
.diary-slots { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.diary-slot { display: flex; flex-direction: column; gap: .4rem; }
.slot-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 5.25rem;
    padding: .5rem;
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    background: transparent;
}
.slot-btn:hover { border-color: var(--sub); }
.slot-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--bg);
    color: var(--sub);
}
/* 편집 화면의 사진 칸: 사진이 없을 때는 작은 버튼 한 줄 */
.diary .photo-picker { height: 3rem; }
.diary .photo-picker.has-photo { height: 13rem; }

/* ---------- 아래에서 올라오는 선택창 ---------- */
.sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sheet-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #00000055;
    opacity: 0;
    transition: opacity .25s ease;
}
.sheet-overlay.open::before { opacity: 1; }
.sheet {
    position: relative;
    width: 100%;
    max-width: 30rem;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    padding: .5rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
    border-radius: 1.1rem 1.1rem 0 0;
    background: var(--surface);
    box-shadow: 0 -4px 20px #0003;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
}
.sheet-overlay.open .sheet { transform: none; }
.sheet-handle { width: 2.5rem; height: .28rem; margin: 0 auto .6rem; border-radius: 1rem; background: var(--line); }
.sheet-title { font-weight: bold; margin-bottom: .75rem; }
.sheet-content { overflow-y: auto; }
.sheet-clear { display: block; margin: 1rem auto 0; }

.sheet-ratings { display: flex; flex-direction: column; gap: .5rem; }
.sheet-ratings .rating-tag { padding: .8rem 1rem; font-size: 1.05rem; text-align: center; }
.sheet-ratings .rating-tag.on { border-color: var(--text); }
.sheet-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.75rem, 1fr)); gap: .4rem; }
.sticker-option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 4.75rem;
    padding: 0;
    border: 2px solid transparent;
    border-radius: .75rem;
    background: var(--bg);
}
.sticker-option.on { border-color: var(--accent); }

.diary-note {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .6rem .7rem;
    background: transparent;
    line-height: 1.6;
    resize: none;
    overflow: hidden;
    outline: none;
}
.diary-note:focus { border-color: var(--accent); }
.diary-note::placeholder { color: var(--sub); opacity: .75; }
.diary-btns { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; }
.diary-btns .text-btn { margin-right: auto; }

/* ---------- 앱으로 설치 안내 ---------- */
.install-section .btn { margin-top: .25rem; }
.install-section .fa-check-circle { color: #43A047; }
/* 화면 아래 안내 한 줄 (아래 탭 바로 위) */
.install-banner {
    position: fixed;
    left: .75rem;
    right: .75rem;
    bottom: calc(var(--nav-h) + .6rem + env(safe-area-inset-bottom));
    z-index: 27;
    display: flex;
    align-items: center;
    gap: .6rem;
    max-width: 30rem;
    margin: 0 auto;
    padding: .55rem .4rem .55rem .7rem;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--line), 0 4px 16px #00000033;
    animation: install-banner-in .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes install-banner-in {
    from { transform: translateY(1.5rem); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.install-banner-icon { width: 1.75rem; height: 1.75rem; border-radius: .4rem; flex-shrink: 0; }
.install-banner-text { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.35; }
.install-banner .btn { padding: .4rem .75rem; font-size: .82rem; white-space: nowrap; flex-shrink: 0; }
/* 안내가 떠 있는 동안 추첨 버튼과 알림은 그 위로 */
body.has-install-banner .lottery-fab { bottom: calc(var(--nav-h) + 5rem + env(safe-area-inset-bottom)); }
body.has-install-banner .toast-zone { bottom: calc(var(--nav-h) + 5rem + env(safe-area-inset-bottom)); }

.install-steps { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: .7rem; line-height: 1.6; }
.install-steps i, .share-icon { color: var(--accent); }
.share-icon { width: 1.25em; height: 1.25em; vertical-align: -.25em; }
.install-note { margin: 1rem 0 0; padding: .6rem .8rem; border-radius: .5rem; background: var(--bg); font-size: .82rem; }
.install-guide-btns { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }

/* ---------- 후원하기 (메뉴) ---------- */
/* 바깥 스크립트(위젯)를 쓰지 않고 Ko-fi 페이지로 가는 링크만 둡니다. */
.support-btn { background: #72A4F2; color: #fff; border-color: transparent; text-decoration: none; }
/* Ko-fi 공식 심볼 (img/kofi_symbol.png, Ko-fi 브랜드 자료에서 받은 것) */
.support-icon { height: 1.35em; width: auto; }

/* ---------- 아이폰: 입력칸을 눌러도 화면이 확대되지 않게 ---------- */
/* 아이폰(Safari)은 글자가 16px보다 작은 입력칸에 커서를 두면 화면을 확대합니다.
   아이폰에서만 입력칸 글자를 16px로 맞춰 확대를 막습니다. (다른 기기는 그대로) */
@supports (-webkit-touch-callout: none) {
    input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), textarea, select { font-size: 16px !important; }
    .title-input { font-size: 1.3rem !important; }
}
