/* 미룬이 · 화면 스타일
   따뜻한 회백색 바탕, 아이보리 감열지, 검정 글자, 작은 주홍색 포인트
   글꼴(Neo둥근모 Pro)은 css/font.css에 들어 있습니다. */

:root {
  --bg: #f2eee6;
  --bg-deep: #e8e2d7;
  --card: #fffdf8;
  --field: #f7f3eb;
  --paper: #fbf7ec;
  --ink: #1e1b17;
  --ink-2: #4a453e;
  --mute: #7a7367;
  --line: #ddd5c7;
  --line-soft: #ebe5da;
  --accent: #e2462b;
  --accent-soft: #fbe3dc;
  --printer: #2b2825;
  --pixel: 'NeoDunggeunmo Pro', 'Apple SD Gothic Neo', monospace;
  --sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --paper-w: min(360px, calc(100vw - 40px));
  --dock-h: 88px;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .28 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(var(--dock-h) + 28px + env(safe-area-inset-bottom));
}

/* ---------- 상단 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 0 6px;
}

.brand {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 32px;
  line-height: 1;
}
.brand__dot { width: 6px; height: 6px; margin-bottom: 4px; background: var(--accent); }

.sound-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 14px;
  color: var(--ink-2);
}
.sound-btn svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sound-btn svg path:first-child { stroke: none; }
.sound-btn__off { display: none; }
.sound-btn[aria-pressed='true'] .sound-btn__on { display: none; }
.sound-btn[aria-pressed='true'] .sound-btn__off { display: block; }
.sound-btn[aria-pressed='true'] { color: var(--mute); }

/* ---------- 첫 화면 ---------- */
.hero { padding: 26px 0 22px; }
.hero__eyebrow {
  display: inline-block;
  margin: 0 0 14px;
  padding: 3px 8px 2px;
  border: 1px solid var(--ink);
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.3;
}
.hero__title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.hero__lede { margin: 14px 0 0; color: var(--ink-2); font-size: 16px; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 10px;
}
.list-head__title { margin: 0; font-size: 17px; font-weight: 700; }
.list-head__tools { display: flex; gap: 2px; }

.text-btn {
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}
.text-btn--back { text-decoration: none; font-size: 15px; padding-left: 0; }

/* ---------- 항목 카드 ---------- */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.item {
  position: relative;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(60, 40, 10, 0.03);
}
.item.is-done { background: #fffaf5; }
.item.is-new { animation: pop 0.24s ease-out; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

.item__row { display: flex; align-items: center; gap: 8px; }
.item__no {
  flex: none;
  width: 26px;
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--mute);
  text-align: center;
}
.item__title {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--field);
  font-size: 17px;
  font-weight: 600;
}
.item__title::placeholder { color: #aaa192; font-weight: 400; }
.item__title:focus { outline: none; border-color: var(--ink); background: #fff; }
.item.is-done .item__title { text-decoration: line-through; text-decoration-color: var(--accent); color: var(--mute); }

.item__remove {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--mute);
  font-size: 22px;
  line-height: 1;
}
.item__remove:hover { background: var(--field); color: var(--ink); }

.item__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 4px 4px 4px 34px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
  color: var(--ink-2);
}
.item__summary { flex: 1; min-width: 0; }
.item__result { flex: none; display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.chev { flex: none; color: var(--mute); transition: transform 0.2s; }
.item__toggle[aria-expanded='true'] .chev { transform: rotate(180deg); }

.item__details { padding: 6px 4px 4px 34px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.item__details[hidden] { display: none; }

.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { font-size: 14px; font-weight: 600; color: var(--ink-2); padding: 0; }
.opt { font-weight: 400; color: var(--mute); margin-left: 4px; }
.field__combo { display: flex; gap: 6px; align-items: center; }
.field__combo input, .field__combo select {
  height: 46px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font-size: 16px;
}
.field__combo input { flex: 1; }
.field__combo select { flex: none; width: 92px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; }
.field__combo input:focus, .field__combo select:focus { outline: none; border-color: var(--ink); background-color: #fff; }
.field__combo .unit { flex: none; width: 24px; color: var(--mute); font-size: 15px; }
.field.has-error input { border-color: var(--accent); background: #fff6f3; }

.field-error { margin: 0; font-size: 13.5px; color: var(--accent); font-weight: 600; }
.field-error:empty { display: none; }
.item > .field-error { padding-left: 34px; margin-top: 4px; }

.kinds__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kinds__grid label { position: relative; }
.kinds__grid input { position: absolute; opacity: 0; pointer-events: none; }
.kinds__grid span {
  display: block;
  min-height: 52px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}
.kinds__grid small { display: block; font-weight: 400; color: var(--mute); font-size: 12.5px; }
.kinds__grid input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.kinds__grid input:checked + span small { color: #cfc6b6; }
.kinds__grid input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; color: var(--ink-2); }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }

.calc {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 14px;
}
.calc__row { display: flex; gap: 8px; align-items: baseline; }
.calc__row b { font-family: var(--pixel); font-weight: 400; font-size: 16px; white-space: nowrap; }
.calc__row span { color: var(--ink-2); }
.calc__note { margin: 2px 0 0; font-size: 12.5px; color: var(--mute); }

.item__done {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0 34px;
  font-size: 13.5px;
  color: var(--accent);
  font-weight: 700;
}
.item__done[hidden] { display: none; }
.item__done button { border: 0; background: none; padding: 6px 4px; color: var(--ink-2); font-size: 13.5px; text-decoration: underline; }

.tag {
  display: inline-block;
  padding: 1px 4px 0;
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 18px;
  white-space: nowrap;
}
.tag--actual { background: var(--ink); color: var(--paper); }
.tag--risk, .tag--saved { box-shadow: inset 0 0 0 1.2px var(--ink); }
.tag--penalty { background: var(--accent); color: var(--paper); }
.amt { font-family: var(--pixel); font-size: 16px; white-space: nowrap; }

/* ---------- 추가 ---------- */
.add-area { margin-top: 12px; }
.add-btn {
  width: 100%;
  min-height: 52px;
  border: 1.5px dashed #c9bfae;
  border-radius: var(--radius);
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-2);
}
.add-btn:hover { border-color: var(--ink); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 14px;
  color: var(--ink-2);
}
.chip:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- 안내 ---------- */
.legend {
  margin-top: 28px;
  padding: 16px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
.legend h2 { margin: 0 0 10px; font-family: var(--pixel); font-size: 16px; font-weight: 400; }
.legend dl { margin: 0; display: grid; gap: 10px; }
.legend dl div { display: flex; gap: 10px; align-items: flex-start; }
.legend dt { flex: none; padding-top: 1px; }
.legend dd { margin: 0; font-size: 14px; color: var(--ink-2); }
.legend__privacy { margin: 14px 0 0; font-size: 13px; color: var(--mute); }

/* ---------- 영수증 화면 ---------- */
.view[hidden] { display: none; }
.receipt-bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-top: 4px; }
.receipt-bar__status { font-family: var(--pixel); font-size: 16px; color: var(--mute); }

.printer {
  position: relative;
  z-index: 1;
  width: calc(var(--paper-w) + 28px);
  margin: 10px auto 0;
}
.printer__body {
  position: relative;
  display: block;
  height: 92px;
  border-radius: 24px 24px 14px 14px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.09), transparent 60%),
    linear-gradient(180deg, #3a3631 0%, #2b2825 55%, #24211e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 14px 22px -12px rgba(40, 25, 10, 0.55);
}
.printer__seam {
  position: absolute;
  left: 18px; right: 18px; top: 40px;
  height: 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.printer__label {
  position: absolute;
  left: 22px; top: 14px;
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: #9a9184;
}
.printer__label small { margin-left: 8px; font-size: 16px; color: #6c655b; letter-spacing: 0; }
.printer__led {
  position: absolute;
  right: 58px; top: 17px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #5d564d;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4);
}
.printer__feed {
  position: absolute;
  right: 20px; top: 10px;
  width: 24px; height: 22px;
  border-radius: 7px;
  background: linear-gradient(#45403a, #35312c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.4);
}
.printer__slot {
  position: absolute;
  left: 8px; right: 8px; top: 71px;
  height: 10px;
  border-radius: 6px;
  background: #0e0d0c;
  box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.07);
}
.printer.is-printing .printer__body { animation: hum 0.07s linear infinite; }
.printer.is-printing .printer__led { background: var(--accent); box-shadow: 0 0 8px 1px rgba(226, 70, 43, 0.75); animation: blink 0.3s steps(2) infinite; }
@keyframes hum { 0% { transform: translate(0, 0); } 50% { transform: translate(0.4px, -0.3px); } 100% { transform: translate(-0.3px, 0.2px); } }
@keyframes blink { 50% { opacity: 0.35; } }

.paper-path {
  position: relative;
  z-index: 2;
  width: var(--paper-w);
  height: 0;
  margin: -12px auto 0;
  clip-path: inset(0 -40px -60px -40px);
}
.paper-path::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  z-index: 1;
  height: 10px;
  background: linear-gradient(rgba(20, 15, 10, 0.28), rgba(20, 15, 10, 0));
  pointer-events: none;
}
.paper-path canvas {
  position: absolute;
  left: 0; bottom: 0;
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(70, 50, 20, 0.16)) drop-shadow(0 1px 1px rgba(70, 50, 20, 0.12));
  transform-origin: 50% 0;
}
.paper-path.is-settled { height: auto; }
.paper-path.is-settled canvas { position: relative; }
.paper-path canvas.is-cut { animation: cut 0.5s cubic-bezier(0.3, 0.7, 0.4, 1) forwards; }
.paper-path canvas.is-leaving { animation: leave 0.34s ease-in forwards; }
@keyframes cut {
  0% { transform: none; }
  35% { transform: translateY(7px) rotate(-0.8deg); }
  100% { transform: translateY(3px) rotate(-0.4deg); }
}
@keyframes leave { to { transform: translateY(60px) rotate(2deg); opacity: 0; } }

/* ---------- 하단 버튼 ---------- */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, rgba(242, 238, 230, 0));
  pointer-events: none;
}
.dock__row { max-width: 448px; margin: 0 auto; display: flex; gap: 8px; pointer-events: auto; }
.dock__row[hidden] { display: none; }
.dock.is-busy .dock__row { opacity: 0.4; pointer-events: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn--primary { flex: 1.4; background: var(--ink); color: var(--paper); }
.btn--ghost { flex: 1; background: var(--card); color: var(--ink); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn--print { width: 100%; font-family: var(--pixel); font-weight: 400; font-size: 16px; letter-spacing: 0.04em; }
.btn__led { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px rgba(226, 70, 43, 0.8); }

/* ---------- 처리 시트 ---------- */
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 -10px 40px rgba(40, 25, 10, 0.2);
}
.sheet::backdrop { background: rgba(30, 27, 23, 0.42); }
.sheet[open] { animation: rise 0.24s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet__inner { padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet__grip { justify-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
.sheet__title { margin: 4px 0 0; font-family: var(--pixel); font-size: 16px; font-weight: 400; }
.sheet__desc { margin: 0; font-size: 14px; color: var(--ink-2); }
.sheet__list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.sheet__pick {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  text-align: left;
}
.sheet__pick:hover { border-color: var(--ink); }
.sheet__pick b { font-size: 16px; }
.sheet__pick span { font-size: 13.5px; color: var(--accent); font-weight: 600; }
.sheet__close { width: 100%; }

/* ---------- 미리보기 ---------- */
.preview {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 27, 23, 0.6);
}
.preview[hidden] { display: none; }
.preview__panel { width: 100%; max-width: 440px; max-height: 92vh; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding: 14px; border-radius: 18px; background: var(--card); }
.preview__title { margin: 0; font-weight: 700; text-align: center; }
.preview__scroll { overflow: auto; border-radius: 10px; background: var(--bg-deep); }
.preview__img { display: block; width: 100%; height: auto; -webkit-touch-callout: default; }
.preview__actions { display: flex; gap: 8px; }

/* ---------- 알림 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 18px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14.5px;
  font-weight: 600;
  text-align: center;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.shake { animation: shake 0.36s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

@media (min-width: 640px) {
  .hero { padding-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
