/* 편의점 냉장고 관리 - 외부 라이브러리 없는 스타일 */
:root {
  --blue: #2563eb; --blue-d: #1d4ed8; --blue-50: #eff6ff; --blue-100: #dbeafe; --blue-200: #bfdbfe;
  --red: #dc2626; --red-50: #fef2f2; --red-200: #fecaca; --amber: #f59e0b; --amber-50: #fffbeb; --amber-300: #fcd34d;
  --green: #059669; --green-50: #ecfdf5;
  --g50: #f9fafb; --g100: #f3f4f6; --g200: #e5e7eb; --g300: #d1d5db; --g400: #9ca3af; --g500: #6b7280; --g600: #4b5563; --g700: #374151; --g800: #1f2937;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--g100); color: var(--g800);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin: 0; }
ol { margin: 0; padding-left: 1.2em; }
.hidden { display: none !important; }
.block { display: block; }
.pre { white-space: pre-line; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--g500); }
.small { font-size: 12px; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 22px; height: 22px; }
.ic-xl { width: 44px; height: 44px; stroke-width: 1.6; }
.ic-blue { color: var(--blue); }

/* 레이아웃 */
#app {
  max-width: 28rem; margin: 0 auto; height: 100vh; height: 100dvh; background: #fff; position: relative;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 40px rgba(0, 0, 0, .15);
}
.topbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; z-index: 10;
  background: var(--blue); color: #fff; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; min-height: 56px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.topbar-left { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex: none; }
.topbar h1 { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: #fff; }
.icon-btn:hover, .icon-btn:active { background: rgba(255, 255, 255, .18); }
.icon-btn-dark { color: var(--g500); }
.icon-btn-dark:hover, .icon-btn-dark:active { background: var(--g100); }
.top-pill { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .16); color: #fff; font-size: 13px; font-weight: 700; }
.install-btn { color: #fde68a; }
#main { flex: 1; overflow-y: auto; background: var(--g50); position: relative; -webkit-overflow-scrolling: touch; }
.view { min-height: 100%; padding-bottom: calc(80px + var(--safe-b)); }
.pad { padding: 16px; }
.stack > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 20px; }
.stack-sm > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-gap { display: flex; gap: 8px; padding-top: 4px; }
.grow { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--g400); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--g200); }

/* 카드·폼 */
.card { background: #fff; border: 1px solid var(--g200); border-radius: 14px; padding: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.card-title { font-size: 15px; font-weight: 700; }
.hint { font-size: 12px; color: var(--g500); line-height: 1.5; }
.note { font-size: 13px; color: var(--g600); background: var(--g50); border: 1px solid var(--g200); border-radius: 10px; padding: 10px 12px; line-height: 1.55; }
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--g700); margin-bottom: 6px; }
.input { width: 100%; border: 1px solid var(--g300); border-radius: 10px; padding: 12px; background: #fff; outline: none; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.input-strong { font-weight: 700; }
.code-input { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.form-error { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--red-50); border: 1px solid var(--red-200); color: #991b1b; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 12px; padding: 11px 16px; font-weight: 700; font-size: 14px; text-align: center; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 16px; font-size: 15px; border-radius: 14px; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 3px rgba(37, 99, 235, .4); }
.btn-primary:hover { background: var(--blue-d); }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-soft { background: var(--blue-50); color: var(--blue-d); border-color: var(--blue-200); }
.btn-gray { background: var(--g100); color: var(--g700); border-color: var(--g300); }
.btn-green { background: var(--green); color: #fff; cursor: pointer; }
.btn-danger-soft { background: var(--red-50); color: var(--red); border-color: var(--red-200); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--g500); }
.link { background: none; border: 0; padding: 4px; color: var(--blue); text-decoration: underline; font-size: 12px; }

/* 방 입장 */
.gate-hero { text-align: center; padding: 18px 0 22px; }
.gate-hero h2 { font-size: 22px; margin: 10px 0 6px; }
.gate-logo { width: 76px; height: 76px; margin: 0 auto; border-radius: 22px; background: linear-gradient(145deg, #3b82f6, #1d4ed8); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(37, 99, 235, .35); }

/* 목록 */
.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.list-head h2 { font-size: 20px; }
.fridge-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--g200); border-radius: 14px; padding: 14px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.fridge-item:active { background: var(--g50); }
.fridge-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fridge-ico { width: 46px; height: 46px; flex: none; border-radius: 999px; background: var(--blue-100); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.fridge-name { font-weight: 700; font-size: 17px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fridge-meta { font-size: 12px; color: var(--g500); margin-top: 3px; }
.fridge-side { text-align: right; flex: none; }
.fridge-side .lbl { font-size: 11px; color: var(--g400); }
.fridge-side .num { font-weight: 800; color: var(--blue); font-size: 16px; }
.fridge-side .num small { color: var(--g400); font-weight: 400; font-size: 12px; }
.fridge-side .need { font-size: 11px; color: var(--red); font-weight: 700; margin-top: 2px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 0; color: var(--g400); }
.empty p { font-size: 14px; font-weight: 600; }

/* 상세 */
.detail-head { padding: 14px 16px; margin-bottom: 14px; }
.detail-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.detail-head h2 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; }
.stats { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--g500); }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.stat .ic { color: #60a5fa; }
.stats .need, .stats .need .ic { color: var(--red); font-weight: 700; }
.detail-head .hint { margin-top: 6px; }
.shelf { background: #fff; border-radius: 14px; padding: 12px; border: 1px solid var(--g200); border-bottom: 6px solid var(--g300); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.shelf-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--g400); margin-bottom: 8px; padding: 0 4px; }
.shelf-head small { font-weight: 400; font-size: 10px; color: var(--g300); }
.shelf-row { display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 8px; scroll-snap-type: x proximity; touch-action: pan-x pan-y; }
.shelf-row::-webkit-scrollbar { height: 6px; }
.shelf-row::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.slot { flex: none; width: 88px; display: flex; flex-direction: column; align-items: center; background: none; border: 0; padding: 0; scroll-snap-align: center; user-select: none; -webkit-user-select: none; }
.slot-box { position: relative; width: 80px; height: 96px; border-radius: 10px; background: var(--g50); border: 2px solid var(--g200); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 4px; color: var(--g300); }
.slot-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot-box .ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--blue-50); color: #93c5fd; }
.slot-box .ph .ic { width: 30px; height: 30px; }
.slot-qty { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; background: rgba(0, 0, 0, .62); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 0; }
.slot-badge { position: absolute; top: 3px; right: 3px; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 999px; color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 1px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.b-red { background: #ef4444; } .b-amber { background: var(--amber); }
.slot-name { width: 100%; text-align: center; font-size: 12px; font-weight: 700; color: var(--g800); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-empty { font-size: 10px; color: var(--g400); }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 50; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 28rem; margin: 0 auto; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: #fff; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); animation: slideUp .28s cubic-bezier(.16, 1, .3, 1); }
.sheet-body { padding: 18px 18px calc(22px + var(--safe-b)); overflow-y: auto; }
.grabber { display: flex; justify-content: center; padding: 10px 0 2px; cursor: pointer; }
.grabber span { width: 48px; height: 6px; border-radius: 999px; background: var(--g300); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-title { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 800; }
.coord { font-size: 13px; font-weight: 400; color: var(--blue); margin-left: 6px; }
.modal-center { display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet:focus, .dialog:focus { outline: none; } /* 포커스를 옮겨 스크린리더에 제목을 읽히기 위한 것이라 윤곽선은 숨긴다 */
.dialog { position: relative; width: 100%; max-width: 22rem; background: #fff; border-radius: 18px; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: pop .18s ease-out; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; background: var(--g100); padding: 4px; border-radius: 10px; }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 4px; border: 0; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--g500); }
.tab[aria-selected="true"] { background: #fff; color: var(--blue); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.dropzone { position: relative; overflow: hidden; border: 2px dashed #93c5fd; border-radius: 14px; background: var(--blue-50); padding: 18px; text-align: center; color: #1e3a8a; }
.file-cover { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; }
.dz-state { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dz-state .small { color: var(--blue); }
.dz-icon { width: 48px; height: 48px; border-radius: 999px; background: var(--blue-100); color: var(--blue); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.dz-result { position: relative; z-index: 3; }
.dz-result img { height: 80px; max-width: 100%; object-fit: contain; border-radius: 10px; background: #fff; padding: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); margin-bottom: 6px; }
.pill-name { background: var(--blue); color: #fff; padding: 4px 14px; border-radius: 999px; font-weight: 800; font-size: 14px; }
.dz-links { display: flex; gap: 12px; margin-top: 6px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--blue-200); border-top-color: var(--blue); animation: spin .8s linear infinite; margin: 6px 0; }
.photo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; border: 1px solid var(--g200); background: var(--g50); }
.qty-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--g50); border: 1px solid var(--g200); border-radius: 14px; padding: 12px 14px; }
.qty-ctl { display: flex; align-items: center; gap: 8px; }
.qty-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--g300); background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--g700); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.qty-btn:active { background: var(--g100); }
.qty-plus { background: var(--blue); border-color: var(--blue); color: #fff; }
.qty-plus:active { background: var(--blue-d); }
.qty-input { width: 56px; text-align: center; font-weight: 800; font-size: 19px; padding: 6px 0; border: 1px solid var(--g300); border-radius: 10px; outline: none; -moz-appearance: textfield; appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input:focus { border-color: var(--blue); }

.code-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; border-radius: 16px; background: linear-gradient(145deg, var(--blue-50), #e0e7ff); border: 1px solid var(--blue-200); }
.code-big { font-size: 34px; letter-spacing: .12em; font-weight: 800; color: var(--blue-d); font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; }

.banner { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.banner-warn { background: var(--amber-50); border: 1px solid var(--amber-300); color: #78350f; }
#offlineBanner { flex: none; border-radius: 0; border-width: 0 0 1px; align-items: center; }
.guide { border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.guide h4 { margin: 0 0 6px; font-size: 14px; }
.guide li + li { margin-top: 3px; }
.guide-blue { background: var(--blue-50); border: 1px solid var(--blue-200); color: #1e3a8a; }
.guide-green { background: var(--green-50); border: 1px solid #a7f3d0; color: #065f46; }

.toast { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, -16px); z-index: 100; display: flex; align-items: center; gap: 8px; max-width: min(92vw, 26rem); padding: 10px 18px; border-radius: 20px; background: var(--g800); color: #fff; font-size: 14px; font-weight: 700; line-height: 1.35; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.toast.success .ic { color: #4ade80; }

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