/* =========================================================
   가영님 스크랩북 · styles.css
   warm cream / terracotta · mobile first (375px 기준)
   ========================================================= */

:root {
  --cream: #FAF6F0;
  --cream-2: #F5ECE1;
  --cream-3: #EFE1D2;
  --card: #FFFFFF;
  --ink: #3B2A20;
  --ink-2: #6B5648;
  --muted: #9C8A7B;
  --terra: #C85A32;
  --terra-dark: #A9481F;
  --terra-soft: #F8E3D8;
  --terra-line: #F0CDBB;
  --brown: #7C4A2D;
  --line: #ECE0D3;
  --line-soft: #F3EAE0;
  --ok: #5C8A5E;
  --ok-soft: #E8F0E5;
  --danger: #B23B3B;
  --danger-soft: #FBE9E7;
  --shadow-sm: 0 2px 8px rgba(124, 74, 45, .05);
  --shadow: 0 10px 26px rgba(124, 74, 45, .08);
  --r-xl: 24px;
  --r-lg: 20px;
  --r-md: 15px;
  --r-sm: 11px;
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
          'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(120% 60% at 50% 0%, #FDF8F1 0%, rgba(250, 246, 240, 0) 60%),
    var(--cream);
  overflow-x: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(.985); }

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #FFFDFB;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 12px;
  width: 100%;
  min-width: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: #BCAC9C; }
input:focus, select:focus, textarea:focus {
  border-color: var(--terra-line);
  box-shadow: 0 0 0 3px rgba(200, 90, 50, .08);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; font-size: 14px; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }

/* ---------- 레이아웃 ---------- */
.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 0 calc(96px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 8px;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { font-size: 21px; line-height: 1; }
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--brown);
  white-space: nowrap;
}
.brand-text p {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-btns { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.lock-btn {
  padding: 7px 11px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.lock-btn[hidden] { display: none; }

.main { padding: 6px 16px 0; }

/* ---------- 요약 · 검색 · 칩 ---------- */
.summary { padding: 2px 16px 0; }

.sum-card {
  background: linear-gradient(160deg, #FFFDFB 0%, #FBF2E7 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 13px 14px 12px;
}

.sum-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sum-title { font-size: 12.5px; font-weight: 800; color: var(--brown); letter-spacing: -.2px; }
.sum-sub { font-size: 11px; color: var(--muted); }

.sum-stats { display: flex; align-items: flex-end; gap: 14px; margin-top: 4px; }
.sum-stat { display: flex; align-items: baseline; gap: 4px; }
.sum-num { font-size: 24px; font-weight: 800; letter-spacing: -.8px; color: var(--brown); line-height: 1.1; }
.sum-unit { font-size: 11px; font-weight: 700; color: var(--muted); }
.sum-badge {
  margin-left: auto;
  align-self: center;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--terra-dark);
  background: var(--terra-soft);
  border: 1px solid var(--terra-line);
  border-radius: 999px;
  white-space: nowrap;
}
.sum-badge.is-clear { color: var(--ok); background: var(--ok-soft); border-color: #D6E4D1; }

.search-row { position: relative; margin-top: 11px; }
.search-row .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}
.search-row input {
  padding: 10px 34px 10px 30px;
  font-size: 13.5px;
  background: #fff;
  border-radius: 999px;
}
.search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--cream-2);
  border-radius: 50%;
}
.search-clear[hidden] { display: none; }

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 11px 2px 3px;
  margin: 0 -2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.chip .chip-n { font-size: 10.5px; font-weight: 800; color: var(--muted); }
.chip.on {
  color: #fff;
  background: var(--terra);
  border-color: var(--terra);
  box-shadow: 0 3px 10px rgba(200, 90, 50, .20);
}
.chip.on .chip-n { color: rgba(255, 255, 255, .82); }
.chip.chip-unseen.on { background: var(--brown); border-color: var(--brown); }

/* ---------- 목록 ---------- */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 2px 7px;
}
.list-count { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.list-sort { font-size: 11px; font-weight: 700; color: var(--muted); }

.cards { display: flex; flex-direction: column; gap: 11px; }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: opacity .16s ease, filter .16s ease;
}
.card.is-seen { opacity: .58; }
.card.is-seen .card-title { text-decoration: none; }

.card-thumb {
  position: relative;
  display: block;
  width: 100%;
  background: var(--cream-2);
  border-bottom: 1px solid var(--line-soft);
}
.card-thumb img {
  display: block;
  width: 100%;
  max-height: 230px;
  object-fit: cover;
  object-position: center top;
}
.card-thumb.multi { display: flex; gap: 1px; background: var(--cream-3); }
.card-thumb.multi img { width: 50%; max-height: 190px; object-fit: contain; background: var(--cream-2); }

.card-body { padding: 12px 13px 11px; }

.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: -.1px;
  border-radius: 999px;
  white-space: nowrap;
}
.card-date {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
}

.card-title {
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.38;
  letter-spacing: -.3px;
  color: var(--ink);
  word-break: keep-all;
}

.card-summary {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.52;
  color: var(--ink-2);
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card.is-open .card-summary { display: none; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.card-meta .src { color: var(--brown); }
.card-meta .dot { color: var(--line); }

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.tag {
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--cream-2);
  border-radius: 6px;
}

.card-detail {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}
.card-detail li {
  position: relative;
  padding-left: 11px;
  margin-bottom: 5px;
  font-size: 12.3px;
  line-height: 1.55;
  color: var(--ink-2);
  word-break: keep-all;
}
.card-detail li:last-child { margin-bottom: 0; }
.card-detail li::before {
  content: '';
  position: absolute;
  left: 1px;
  top: 8px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--terra-line);
}
.card-detail li.is-head {
  padding-left: 0;
  margin-top: 9px;
  font-weight: 800;
  color: var(--brown);
}
.card-detail li.is-head:first-child { margin-top: 0; }
.card-detail li.is-head::before { display: none; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-2);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 9px;
  white-space: nowrap;
  text-decoration: none;
}
.act.seen.on {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #D6E4D1;
}
.act.open { color: var(--terra-dark); background: var(--terra-soft); border-color: var(--terra-line); }
.act.more { margin-left: auto; padding: 6px 9px; font-size: 14px; line-height: 1; }
.act.link { text-decoration: none; }

/* ---------- 빈 화면 ---------- */
.empty {
  margin-top: 26px;
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.empty .emoji { font-size: 26px; }
.empty h3 { margin-top: 8px; font-size: 14px; font-weight: 800; color: var(--ink-2); }
.empty p { margin-top: 4px; font-size: 12px; line-height: 1.55; }

/* ---------- 추가 버튼 ---------- */
.fab {
  position: fixed;
  right: max(18px, calc(50vw - 242px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 46px;
  padding: 0 18px;
  font-size: 13.5px;
  font-weight: 800;
  color: #fff;
  background: var(--terra);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(200, 90, 50, .30);
}

/* ---------- 잠금 화면 ---------- */
.lock {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(120% 60% at 50% 0%, #FDF8F1 0%, rgba(250, 246, 240, 0) 60%),
    var(--cream);
}
.lock[hidden] { display: none; }
.lock-inner { width: 100%; max-width: 320px; margin: auto; text-align: center; }
.lock-mark { font-size: 34px; line-height: 1; }
.lock-title {
  margin: 10px 0 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--brown);
}
.lock-msg { min-height: 19px; margin: 7px 0 0; font-size: 12.5px; color: var(--muted); }
.lock-msg.is-error { color: var(--terra-dark); font-weight: 700; }
.lock-dots { display: flex; justify-content: center; gap: 13px; margin: 20px 0 22px; }
.lock-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--terra-line);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.lock-dot.on { background: var(--terra); border-color: var(--terra); transform: scale(1.08); }
.lock-dots.shake { animation: lockShake .44s ease-in-out; }
@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  45% { transform: translateX(7px); }
  70% { transform: translateX(-4px); }
  88% { transform: translateX(2px); }
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  display: grid;
  place-items: center;
  height: 54px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
}
.key:active { background: var(--cream-2); }
.key-del { font-size: 18px; color: var(--ink-2); }
.keypad.busy { opacity: .5; pointer-events: none; }

/* ---------- 모달 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 42, 32, .34);
  z-index: 50;
  animation: fade .16s ease;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 51;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--cream);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 34px rgba(59, 42, 32, .16);
  animation: sheetUp .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translate(-50%, 26px); opacity: .6; } to { transform: translate(-50%, 0); opacity: 1; } }

.sheet-grip {
  width: 38px;
  height: 4px;
  margin: 2px auto 12px;
  background: var(--line);
  border-radius: 999px;
}
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-head h2 { font-size: 15.5px; font-weight: 800; letter-spacing: -.3px; color: var(--brown); }
.sheet-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.field { margin-top: 11px; }
.field:first-child { margin-top: 0; }
.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-2);
}
.field .hint { margin-top: 4px; font-size: 10.5px; color: var(--muted); }
.field-row { display: flex; gap: 9px; }
.field-row > * { flex: 1 1 0; }

.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 800;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
}
.btn.primary { color: #fff; background: var(--terra); border-color: var(--terra); box-shadow: 0 6px 16px rgba(200, 90, 50, .22); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); background: var(--danger-soft); border-color: #F1CFC9; }

/* 시트 안 상세 */
.sheet-note {
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 11px 12px;
  font-size: 12.3px;
  line-height: 1.58;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.sheet-note ul { margin: 0; }
.sheet-note li { position: relative; padding-left: 11px; margin-top: 5px; }
.sheet-note li:first-child { margin-top: 0; }
.sheet-note li::before {
  content: '';
  position: absolute;
  left: 1px;
  top: 8px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--terra-line);
}
.sheet-note li.is-head {
  padding-left: 0;
  margin-top: 9px;
  font-weight: 800;
  color: var(--brown);
}
.sheet-note li.is-head::before { display: none; }
.sheet-note li.is-head:first-child { margin-top: 0; }

.sheet-sec { margin-top: 14px; }
.sheet-sec > h3 { font-size: 11.5px; font-weight: 800; color: var(--ink-2); margin-bottom: 6px; }

.cat-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-pick {
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.cat-pick.on {
  color: #fff;
  background: var(--terra);
  border-color: var(--terra);
}

.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 13px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.menu-item .mi-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 15px;
  background: var(--cream-2);
  border-radius: 9px;
}
.menu-item .mi-text { display: block; font-size: 9.5px; font-weight: 600; color: var(--muted); margin-top: 1px; }
.menu-item.danger { color: var(--danger); }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 10px);
  max-width: 88vw;
  padding: 11px 16px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: rgba(59, 42, 32, .93);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(59, 42, 32, .22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 70;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 작은 화면 ---------- */
@media (max-width: 359px) {
  .brand-text h1 { font-size: 15.5px; }
  .card-title { font-size: 13.8px; }
  .sum-num { font-size: 22px; }
}

/* ---------- 넓은 화면 ---------- */
@media (min-width: 600px) {
  body { background: #F3EBE1; }
  .app {
    background: var(--cream);
    box-shadow: 0 0 60px rgba(124, 74, 45, .10);
    min-height: 100vh;
  }
}
