/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; background: #E8ECEF; }

/* ── Screen System ───────────────────────────── */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; transition: opacity .25s; }
.screen.hidden { opacity: 0; pointer-events: none; display: none; }

/* ── Splash ──────────────────────────────────── */
#screen-splash {
  background: linear-gradient(160deg, #0D1F3C 0%, #0A1628 60%, #071020 100%);
  align-items: center; justify-content: center; gap: 20px;
}
.splash-icon { font-size: 72px; animation: spring .6s cubic-bezier(.34,1.56,.64,1); }
.splash-title { color: #fff; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; opacity: 0; animation: fadeIn .5s .4s forwards; }
.splash-sub { color: rgba(255,255,255,0.4); font-size: 14px; opacity: 0; animation: fadeIn .5s .6s forwards; }
@keyframes spring { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes fadeIn { to { opacity: 1; } }

/* ── Login ───────────────────────────────────── */
#screen-login { background: #F0F4F8; align-items: center; justify-content: center; padding: 32px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 0; }
.login-fridge-icon {
  width: 120px; height: 160px; background: #fff;
  border-radius: 16px; border: 2px solid #E0E0E0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  position: relative; overflow: hidden; margin-bottom: 28px;
}
.login-fridge-icon .f-handle { position: absolute; right: 10px; top: 40px; width: 6px; height: 50px; background: #ccc; border-radius: 3px; }
.login-sticker { position: absolute; border-radius: 3px; }
.login-title { font-size: 26px; font-weight: 900; color: #1a1a1a; text-align: center; }
.login-sub { font-size: 14px; color: #888; margin-top: 6px; margin-bottom: 36px; text-align: center; }
.login-google-wrap { width: 100%; margin-bottom: 14px; display: flex; justify-content: center; }
.login-google-wrap > div { width: 100% !important; }
.btn-guest {
  width: 100%; height: 50px; border: 1.5px solid #ddd; border-radius: 12px;
  background: #fff; color: #666; font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s;
}
.btn-guest:hover { background: #f5f5f5; }
.guest-note { font-size: 12px; color: #aaa; text-align: center; margin-top: 10px; line-height: 1.6; white-space: pre-line; }

/* ── App Shell ───────────────────────────────── */
#screen-app { background: #E8ECEF; }
.app-bar {
  height: 56px; flex-shrink: 0;
  background: #fff; border-bottom: 1px solid #EAEEF2;
  display: flex; align-items: center; padding: 0 16px; gap: 10px;
  position: relative; z-index: 50;
}
.app-bar h1 { flex: 1; font-size: 18px; font-weight: 800; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.app-bar h1 .arr { font-size: 14px; color: #aaa; margin-left: 4px; }
.bar-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #666; transition: background .15s; }
.bar-btn:hover { background: #f0f0f0; }

/* ── Fridge Container ────────────────────────── */
.fridge-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 10px; gap: 8px; }

.freezer-zone {
  border-radius: 14px; border: 2px solid rgba(144,202,249,0.4);
  display: flex; align-items: center; padding: 0 14px;
  cursor: pointer; transition: background .15s; position: relative;
  flex-shrink: 0; height: 52px;
}
.freezer-zone .fz-label { font-size: 14px; font-weight: 700; color: #5B9BD5; }
.freezer-zone .fz-count {
  position: absolute; right: 14px;
  background: rgba(144,202,249,0.2); color: #1976D2;
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 8px;
}
.freezer-zone .fz-handle {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; background: rgba(144,202,249,0.35); border-radius: 2px;
}
.freezer-zone.drag-over { border-color: #64B5F6 !important; background: rgba(100,181,246,0.15) !important; }
.freezer-zone.drop-active { animation: pulse .5s infinite alternate; }
@keyframes pulse { to { border-color: #2196F3; box-shadow: 0 0 0 4px rgba(33,150,243,0.15); } }

.fridge-body {
  flex: 1; border-radius: 14px; border: 2px solid rgba(200,215,230,0.5);
  position: relative; overflow: hidden; min-height: 0;
}
.fridge-handle { position: absolute; right: 8px; top: 16px; width: 6px; height: 44px; border-radius: 3px; z-index: 5; }

.empty-hint {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; pointer-events: none;
}
.empty-hint p { font-size: 14px; color: #aaa; text-align: center; line-height: 1.7; white-space: pre-line; }

/* ── Post-it ─────────────────────────────────── */
.post-it {
  position: absolute; border-radius: 5px;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.15);
  cursor: grab; user-select: none; touch-action: none;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  transition: box-shadow .15s;
  word-break: break-word; text-align: center;
  font-size: 13px; font-weight: 600; color: rgba(0,0,0,0.7);
  line-height: 1.4;
}
.post-it:active { cursor: grabbing; box-shadow: 4px 6px 16px rgba(0,0,0,0.22); z-index: 1000 !important; }
.post-it.dragging { opacity: .85; z-index: 1000 !important; box-shadow: 6px 8px 24px rgba(0,0,0,0.25); }
.post-it.completing { animation: flyUp .3s ease-in forwards; }
@keyframes flyUp { to { transform: translateY(-80px) scale(0.6); opacity: 0; } }

/* ── FAB ─────────────────────────────────────── */
.fab {
  position: absolute; bottom: 20px; right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: #2196F3; color: #fff;
  border: none; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(33,150,243,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s; z-index: 10;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(33,150,243,0.5); }
.fab:active { transform: scale(0.95); }

/* ── Bottom Sheet ────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.overlay.visible { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 16px 20px 32px; z-index: 101;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,1,.23,1);
  max-width: 600px; margin: 0 auto;
}
.bottom-sheet.visible { transform: translateY(0); }
.sheet-drag { width: 36px; height: 4px; background: #ddd; border-radius: 2px; margin: 0 auto 16px; }
.sheet-title { font-size: 18px; font-weight: 800; color: #1a1a1a; margin-bottom: 14px; }

.memo-input {
  width: 100%; min-height: 80px; max-height: 140px;
  border: 2px solid #E0E2E6; border-radius: 12px;
  padding: 12px; font-size: 16px; font-family: inherit;
  resize: none; outline: none; transition: border-color .15s;
  color: #333;
}
.memo-input:focus { border-color: #2196F3; }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.color-dot {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2.5px solid transparent; cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: #333; transform: scale(1.1); }

.slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.slider-label { font-size: 13px; color: #888; width: 32px; }
.slider-row input[type=range] {
  flex: 1; height: 4px; accent-color: #2196F3; cursor: pointer;
}

.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-cancel { flex: 1; height: 48px; border-radius: 12px; border: 1.5px solid #E0E0E0; background: #fff; font-size: 16px; font-weight: 600; color: #666; cursor: pointer; }
.btn-save { flex: 2; height: 48px; border-radius: 12px; border: none; background: #2196F3; font-size: 16px; font-weight: 700; color: #fff; cursor: pointer; transition: background .15s; }
.btn-save:hover { background: #1976D2; }
.btn-delete { padding: 0 16px; height: 48px; border-radius: 12px; border: none; background: #FFEBEE; color: #E53935; font-size: 14px; font-weight: 600; cursor: pointer; }

/* ── Freezer Screen ──────────────────────────── */
#screen-freezer { background: #EDF6FF; }
#screen-freezer .app-bar { background: #BBDEFB; border-bottom-color: #90CAF9; }
#screen-freezer .app-bar h1 { color: #0D47A1; }
.freezer-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.freezer-card {
  border-radius: 12px; padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 2px 6px rgba(33,150,243,0.05);
  display: flex; align-items: center; gap: 12px;
}
.fc-text { flex: 1; font-size: 15px; color: rgba(0,0,0,0.5); text-decoration: line-through; }
.fc-date { font-size: 11px; color: rgba(0,0,0,0.28); margin-top: 3px; }
.fc-restore { width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(33,150,243,0.1); color: #1976D2; font-size: 16px; cursor: pointer; flex-shrink: 0; }
.fc-restore:hover { background: rgba(33,150,243,0.2); }
.freezer-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.freezer-empty p { color: #90CAF9; font-size: 15px; font-weight: 600; }
.freezer-empty small { color: #aaa; font-size: 13px; }
.btn-clear-freezer {
  margin: 0 12px 12px; padding: 14px; border-radius: 12px;
  border: none; background: #FFEBEE; color: #E53935;
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ── Skin Shop ───────────────────────────────── */
#screen-skins { background: #F8F9FA; }
.skin-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.skin-card {
  background: #fff; border-radius: 16px; padding: 14px;
  border: 1px solid #eee; position: relative; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: transform .15s;
}
.skin-card:hover { transform: translateY(-2px); }
.skin-card.selected { border: 2.5px solid #2196F3; }
.skin-preview {
  width: 75%; height: 110px; margin: 0 auto 10px;
  border-radius: 10px; position: relative; overflow: hidden;
}
.skin-preview .sp-top { height: 28%; border-radius: 10px 10px 0 0; }
.skin-preview .sp-body { height: 72%; border-radius: 0 0 10px 10px; }
.skin-preview .sp-handle { position: absolute; right: 8px; top: 36%; width: 4px; height: 26px; border-radius: 2px; }
.skin-name { font-size: 14px; font-weight: 700; color: #333; text-align: center; }
.skin-check {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%; background: #2196F3;
  color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.skin-lock {
  position: absolute; inset: 0; background: rgba(0,0,0,0.3);
  border-radius: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
}
.skin-lock span { color: #fff; font-size: 12px; font-weight: 600; }
.btn-unlock {
  margin: 4px 12px 12px; padding: 14px; border-radius: 12px;
  border: none; background: #2196F3; color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
}

/* ── Fridge Selector Modal ───────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.modal.visible { opacity: 1; pointer-events: auto; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-box {
  position: relative; background: #fff; width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 16px 0 32px; z-index: 1;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,1,.23,1);
  max-height: 70vh; display: flex; flex-direction: column;
}
.modal.visible .modal-box { transform: translateY(0); }
.modal-handle { width: 36px; height: 4px; background: #ddd; border-radius: 2px; margin: 0 auto 12px; }
.modal-title { font-size: 16px; font-weight: 800; color: #1a1a1a; padding: 0 20px 10px; border-bottom: 1px solid #f0f0f0; }
.fridge-list { overflow-y: auto; flex: 1; }
.fridge-item {
  display: flex; align-items: center; padding: 14px 20px; gap: 12px;
  cursor: pointer; transition: background .1s;
}
.fridge-item:hover { background: #f8f8f8; }
.fridge-item.active { background: #EEF6FF; }
.fi-dot { width: 10px; height: 10px; border-radius: 50%; background: #ddd; flex-shrink: 0; }
.fridge-item.active .fi-dot { background: #2196F3; }
.fi-name { flex: 1; font-size: 15px; font-weight: 600; color: #333; }
.fi-rename { width: 32px; height: 32px; border-radius: 50%; border: none; background: none; font-size: 14px; cursor: pointer; color: #aaa; }
.fi-rename:hover { background: #f0f0f0; color: #555; }
.btn-add-fridge {
  margin: 10px 16px 0; padding: 14px; border-radius: 12px;
  border: 1.5px dashed #ccc; background: none; color: #888;
  font-size: 15px; font-weight: 600; cursor: pointer; width: calc(100% - 32px);
}
.btn-add-fridge:hover { background: #f8f8f8; }

/* ── Settings Panel ──────────────────────────── */
.settings-panel {
  position: fixed; top: 56px; right: 0; width: 260px;
  background: #fff; border-radius: 0 0 0 16px;
  box-shadow: -4px 4px 20px rgba(0,0,0,0.12);
  z-index: 60; transform: translateX(110%);
  transition: transform .25s, visibility .25s, opacity .25s;
  padding: 16px 0;
  visibility: hidden; opacity: 0;
}
.settings-panel.visible { transform: translateX(0); visibility: visible; opacity: 1; }
.sp-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; cursor: pointer; transition: background .1s;
}
.sp-item:hover { background: #f8f8f8; }
.sp-label { font-size: 14px; font-weight: 600; color: #333; }
.sp-value { font-size: 13px; color: #888; }
.sp-divider { height: 1px; background: #f0f0f0; margin: 6px 0; }
.sp-danger { color: #E53935; }

/* ── Confirm Dialog ──────────────────────────── */
.confirm-dialog {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.confirm-dialog.visible { opacity: 1; pointer-events: auto; }
.confirm-box {
  background: #fff; border-radius: 16px; padding: 24px 20px 16px;
  width: 100%; max-width: 300px; text-align: center;
}
.confirm-box p { font-size: 16px; color: #333; margin-bottom: 20px; font-weight: 500; line-height: 1.5; }
.confirm-btns { display: flex; gap: 8px; }
.confirm-btns button { flex: 1; height: 44px; border-radius: 10px; border: none; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-confirm-no { background: #f0f0f0; color: #555; }
.btn-confirm-yes { background: #E53935; color: #fff; }

/* ── Toast ───────────────────────────────────── */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.75); color: #fff; padding: 10px 18px;
  border-radius: 24px; font-size: 14px; font-weight: 500; white-space: nowrap;
  z-index: 999; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Input Modal (rename/add) ────────────────── */
.input-modal {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.input-modal.visible { opacity: 1; pointer-events: auto; }
.input-modal-box { background: #fff; border-radius: 16px; padding: 24px 20px 16px; width: 100%; max-width: 320px; }
.input-modal-box h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.input-modal-box input {
  width: 100%; height: 46px; border: 2px solid #E0E0E0; border-radius: 10px;
  padding: 0 12px; font-size: 15px; font-family: inherit; outline: none;
  transition: border-color .15s;
}
.input-modal-box input:focus { border-color: #2196F3; }
.input-modal-btns { display: flex; gap: 8px; margin-top: 14px; }
.input-modal-btns button { flex: 1; height: 44px; border-radius: 10px; border: none; font-size: 15px; font-weight: 700; cursor: pointer; }

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

/* ── Responsive ──────────────────────────────── */
@media (min-width: 600px) {
  #screen-app, #screen-freezer, #screen-skins { max-width: 480px; margin: 0 auto; border-left: 1px solid #ddd; border-right: 1px solid #ddd; }
  .bottom-sheet { max-width: 480px; left: 50%; transform: translateX(-50%) translateY(100%); right: auto; width: 480px; }
  .bottom-sheet.visible { transform: translateX(-50%) translateY(0); }
  .modal-box { max-width: 480px; }
  .settings-panel { right: calc(50% - 240px); }
}
