/* 쉘터 제 1연구소 유통물자 검토파일: 게임 태그 색(이끼, 겨자, 녹, 재)을 팔레트로, 기준가는 겨자색 가격표 하나로 강조한다 */
:root {
  --paper: #e6e9e1;
  --sheet: #f6f7f2;
  --ink: #1f241c;
  --ink-2: #545b4e;
  --line: #c8cdc0;
  --moss: #44613a;
  --moss-soft: #dbe5d2;
  --mustard: #d6a92c;
  --mustard-ink: #33290a;
  --rust: #a04a2a;
  --rust-soft: #f3ddd2;
  --ash: #8b9186;
  --font: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  --r-s: 4px;
  --r-m: 10px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #20251f;
    --sheet: #2a3028;
    --ink: #e4e7de;
    --ink-2: #a9b0a3;
    --line: #3e463b;
    --moss: #8fb47c;
    --moss-soft: #34422d;
    --mustard: #d9b13e;
    --mustard-ink: #2a2105;
    --rust: #e3825d;
    --rust-soft: #4a2c20;
    --ash: #7d8478;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--moss); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* 머리 */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto; padding: 16px 16px 8px;
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand .sub { margin: 0; font-size: 13px; color: var(--ink-2); }
.top-actions { display: flex; flex: none; gap: 8px; }
@media (max-width: 560px) {
  .top { flex-wrap: wrap; }
  .brand { flex: 1 1 100%; }
  .top-actions { flex: 1 1 100%; }
  .top-actions .btn { flex: 1; justify-content: center; }
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--ink); border-radius: var(--r-s);
  background: var(--ink); color: var(--sheet);
  font-weight: 500; white-space: nowrap; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.moss { background: var(--moss); border-color: var(--moss); color: var(--sheet); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.badge {
  min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--mustard); color: var(--mustard-ink);
  font-size: 12px; font-weight: 700; text-align: center;
}

/* 찾기 */
.finder {
  position: sticky; top: 0; z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.finder > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.search { display: block; padding: 8px 16px 6px; }
.search input {
  width: 100%; min-height: 46px; padding: 0 14px;
  border: 1.5px solid var(--ink); border-radius: var(--r-s);
  background: var(--sheet); font-size: 16px;
}
.filters { display: flex; gap: 8px; align-items: center; padding: 4px 16px 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 16px;
  background: transparent; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--moss); border-color: var(--moss); color: var(--sheet); }
.filters select {
  flex: none; min-height: 32px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--sheet);
}

/* 배치 */
.layout { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
  .detail { position: sticky; top: 132px; max-height: calc(100vh - 148px); overflow-y: auto; }
  .only-mobile { display: none !important; }
}
.count { margin: 12px 0 6px; font-size: 13px; color: var(--ink-2); }

/* 목록: 장부의 한 줄 */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; padding: 12px 4px; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer;
}
.row:hover { background: color-mix(in srgb, var(--sheet) 70%, transparent); }
.row[aria-current="true"] { background: var(--sheet); box-shadow: inset 3px 0 0 var(--moss); }
.row .nm { display: block; font-weight: 600; font-size: 16px; }
.row .meta { display: block; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 가격표: 이 페이지에서 유일하게 힘을 준 요소 */
.tag {
  --h: 30px;
  position: relative; display: inline-flex; align-items: center;
  height: var(--h); padding: 0 12px 0 calc(var(--h) * .55 + 8px);
  background: var(--mustard); color: var(--mustard-ink);
  font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
  clip-path: polygon(calc(var(--h) * .45) 0, 100% 0, 100% 100%, calc(var(--h) * .45) 100%, 0 50%);
  border-radius: 0 var(--r-s) var(--r-s) 0;
}
.tag::before {
  content: ''; position: absolute; left: calc(var(--h) * .42); top: 50%;
  width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: var(--paper);
}
.tag.unknown {
  clip-path: none; padding: 0 10px; border: 1.5px dashed var(--ash); border-radius: var(--r-s);
  background: transparent; color: var(--ink-2); font-weight: 500;
}
.tag.unknown::before { display: none; }
.tag.big { --h: 52px; font-size: 26px; padding-right: 18px; }
.tag.big::before { width: 10px; height: 10px; margin-top: -5px; }

.empty { padding: 32px 4px; }
.empty p { margin: 0 0 10px; }

/* 상세 */
.detail { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-m); }
.detail-body { padding: 20px; }
.detail h2 { margin: 0; font-size: 22px; line-height: 1.3; letter-spacing: -0.01em; }
.idline { margin: 2px 0 14px; font-size: 13px; color: var(--ink-2); word-break: break-all; }
.price-block { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 6px; }
.src { margin: 0; font-size: 13px; color: var(--ink-2); }
.facts { margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.facts li { padding: 2px 0; }
.block { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.block h3 { margin: 0 0 10px; font-size: 16px; }
.block ul { margin: 0; padding-left: 18px; }
.block p { margin: 0 0 8px; }
.info-sec + .info-sec { margin-top: 12px; }
.info-sec h4 { margin: 0 0 4px; font-size: 14px; color: var(--ink-2); font-weight: 600; }

/* 계산기 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; margin-bottom: 12px; }
.seg button { min-height: 34px; padding: 0 14px; border: 0; background: transparent; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; color: var(--ink-2); }
.field[hidden] { display: none; }
.field.wide { grid-column: 1 / -1; }
.field input, .field select {
  width: 100%; min-width: 0; min-height: 42px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--paper); color: var(--ink); font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.result {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--r-s);
  background: var(--moss-soft); color: var(--ink);
}
.result .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result p { margin: 2px 0; }
.result.warn { background: var(--rust-soft); }

/* 관찰 가격 표 */
.scroll-x { overflow-x: auto; }
table.obs { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.obs th, table.obs td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.obs th { font-weight: 600; color: var(--ink-2); }
table.obs td.r, table.obs th.r { text-align: right; }
details.add-obs { margin-top: 12px; }
details.add-obs summary { cursor: pointer; font-weight: 500; color: var(--moss); }
details.add-obs .fields { margin-top: 10px; }

/* 모바일 상세 시트 */
@media (max-width: 899px) {
  .detail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    max-height: 88vh; overflow-y: auto;
    border-radius: var(--r-m) var(--r-m) 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(105%); transition: transform .22s ease-out;
    visibility: hidden;
  }
  .detail.open { transform: none; visibility: visible; }
  .sheet-bar { position: sticky; top: 0; display: flex; justify-content: flex-end; padding: 8px 12px 0; background: var(--sheet); z-index: 1; }
  .scrim { position: fixed; inset: 0; z-index: 15; background: rgba(20, 24, 18, .45); }
}
@media (prefers-reduced-motion: reduce) { .detail { transition: none; } }

/* 데이터 대화상자 */
dialog {
  width: min(760px, 100vw); max-width: 100vw; max-height: 100dvh;
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--sheet); color: var(--ink);
}
@media (max-width: 899px) { dialog { width: 100vw; height: 100dvh; margin: 0; border-radius: 0; } }
dialog::backdrop { background: rgba(20, 24, 18, .5); }
.dlg-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--sheet); border-bottom: 1px solid var(--line);
}
.dlg-head h2 { margin: 0; font-size: 20px; }
.dlg-body { padding: 4px 20px 28px; }
.dlg-body section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.dlg-body section:last-child { border-bottom: 0; }
.dlg-body h3 { margin: 0 0 6px; font-size: 16px; }
.dlg-body p { margin: 0 0 10px; }
.dlg-body textarea {
  width: 100%; min-height: 150px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--paper); font: 13px/1.45 ui-monospace, Consolas, monospace;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.inline-field input { width: 80px; min-height: 38px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--paper); }

.preview { margin-top: 14px; padding: 14px; border: 1.5px solid var(--moss); border-radius: var(--r-s); }
.preview h4 { margin: 12px 0 4px; font-size: 14px; }
.preview h4:first-child { margin-top: 0; }
.preview ul { margin: 0; padding-left: 18px; font-size: 14px; }
.preview .conflict { color: var(--rust); }
.preview label { display: inline-flex; gap: 6px; align-items: center; }
.err { color: var(--rust); font-weight: 500; }

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: var(--r-s);
  background: var(--ink); color: var(--sheet); font-size: 14px;
}

/* 캠프 창고 */
.goal { padding: 8px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.goal-head { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.goal-head .left { font-weight: 600; }
.goal .bar { height: 8px; margin-top: 6px; background: var(--paper); border-radius: 4px; overflow: hidden; }
.goal .bar i { display: block; height: 100%; background: var(--mustard); }
.goal.done .bar i { background: var(--moss); }
.short { color: var(--rust); font-weight: 600; }
.ok { color: var(--moss); font-weight: 600; }
.store-sum { margin: 0 0 8px; font-size: 14px; color: var(--ink-2); }
table.stock { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
table.stock td, table.stock th { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.stock th { font-weight: 600; color: var(--ink-2); font-size: 13px; }
table.stock .r { text-align: right; white-space: nowrap; }
.linkish { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
