/* 자재 라이브러리 */
.page-materials [hidden] { display: none !important; }

.mt-hero-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.mt-hero-stats li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; display: flex; align-items: baseline; gap: 8px; }
.mt-hero-stats b { font-size: 22px; letter-spacing: -0.02em; }
.mt-hero-stats span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* toolbar */
.mt-toolbar-wrap { position: sticky; top: var(--header-h); z-index: 50; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 12px 0 10px; }
.mt-cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.mt-cats::-webkit-scrollbar { display: none; }
.mt-cat { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 0 14px 0 11px; border-radius: 12px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 650; font-size: 14px; color: var(--ink-2); transition: all .15s; }
.mt-cat svg { width: 19px; height: 19px; color: var(--muted); }
.mt-cat em { font-style: normal; font-size: 12px; color: var(--muted); background: var(--stone); border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.mt-cat:hover { border-color: var(--ink); }
.mt-cat.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.mt-cat.is-on svg { color: #f0b48f; }
.mt-cat.is-on em { background: rgba(255,255,255,.16); color: #fff; }
.mt-filters { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.mt-search { position: relative; flex: 1; min-width: 220px; }
.mt-search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.mt-search .input { min-height: 42px; padding-left: 40px; font-size: 14.5px; }
.mt-selects { display: flex; gap: 8px; }
.mt-selects .select { min-height: 42px; width: auto; max-width: 190px; font-size: 14px; padding: 6px 30px 6px 12px; }
.mt-kindrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.mt-kinds { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.mt-kinds::-webkit-scrollbar { display: none; }
.mt-kinds:empty { display: none; }
.mt-kinds .opt { flex: none; min-height: 32px; font-size: 13px; padding: 0 12px; border-radius: 999px; }
.mt-kinds .opt small { color: inherit; opacity: .6; font-weight: 600; margin-left: 2px; }
.mt-fav-toggle { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; cursor: pointer; color: var(--accent-2); background: var(--accent-soft); border-radius: 999px; padding: 6px 12px; }
.mt-fav-toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* result head */
.mt-resulthead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.mt-count { font-size: 14px; color: var(--muted); margin: 0; }
.mt-count b { color: var(--ink); font-size: 16px; }
.mt-active { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mt-chipx { cursor: pointer; height: 28px; font-size: 12.5px; }
.mt-chipx span[aria-hidden] { color: var(--muted); margin-left: 2px; }
.mt-linkbtn { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }

/* grid & card */
.mt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; }
.mcard { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; display: flex; flex-direction: column; transition: box-shadow .2s, border-color .2s, transform .2s; }
.mcard:hover { box-shadow: var(--shadow); border-color: var(--line-2); transform: translateY(-2px); }
.mcard-sw { position: relative; aspect-ratio: 4 / 3; background: var(--stone); cursor: pointer; border: 0; padding: 0; display: block; width: 100%; overflow: hidden; }
.mcard-sw canvas, .mcard-sw .sw-flat { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
.mcard-badges { position: absolute; left: 10px; top: 10px; right: 10px; display: flex; gap: 5px; justify-content: space-between; align-items: flex-start; }
.mcard-sw .mk { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.94); color: var(--ink); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.mcard-ic { position: absolute; right: 12px; bottom: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; color: var(--ink-2); box-shadow: var(--shadow-s); }
.mcard-ic svg { width: 22px; height: 22px; }
.mcard-ic--lg { width: 64px; height: 64px; right: 20px; bottom: 20px; }
.mcard-ic--lg svg { width: 34px; height: 34px; }
.mcard-body { padding: 14px 16px 10px; display: grid; gap: 3px; flex: 1; align-content: start; }
.mcard-brand { font-size: 12px; color: var(--muted); font-weight: 700; }
.mcard-name { margin: 0; font-size: 16px; line-height: 1.35; }
.mcard-title { border: 0; background: none; padding: 0; font: inherit; font-weight: 750; letter-spacing: -0.02em; text-align: left; color: var(--ink); cursor: pointer; }
.mcard-title:hover { color: var(--accent); }
.mcard-code { font-size: 12.5px; color: var(--muted); }
.mcard-desc { font-size: 13px; color: var(--ink-3); margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }
.mcard-price { font-size: 14px; font-weight: 750; margin-top: 6px; color: var(--accent-2); }
.mcard-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; padding: 0 12px 12px; align-items: center; }
.mcard-actions .btn { min-height: 36px; font-size: 13px; padding: 0 8px; }
.mcard-actions .is-added { background: var(--ok); border-color: var(--ok); color: #fff; }
.mcard-cmp { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 650; color: var(--ink-3); cursor: pointer; padding: 0 2px; }
.mcard-cmp input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; }
.mt-more-wrap { display: flex; justify-content: center; margin-top: 24px; }

/* dock (sample + compare) */
.mt-dock { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 75; background: var(--ink); color: #fff; padding: 10px 0; box-shadow: 0 -6px 20px rgba(0,0,0,.15); }
.mt-dock-inner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mt-dock-part { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt-dock-part + .mt-dock-part { padding-left: 14px; border-left: 1px solid #343840; }
.mt-dock-text { display: grid; line-height: 1.3; }
.mt-dock-text .small { color: #b9bcc2; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-dock-actions { display: flex; gap: 6px; }
.mt-dock-ghost { border: 1px solid #5a5f68; color: #fff; background: transparent; }
.mt-dock-ghost:hover { background: #fff; color: var(--ink); }
.mt-dock-light { background: #fff; color: var(--ink); }
.mt-dock-light:hover { background: #f0b48f; color: var(--ink); }
.mt-dock-thumbs { display: flex; gap: 6px; }
.mt-dock-thumb, .mt-dock-slot { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; position: relative; }
.mt-dock-thumb { border: 2px solid #fff; padding: 0; background: #fff; cursor: pointer; }
.mt-dock-thumb canvas, .mt-dock-thumb .sw-flat { width: 100%; height: 100%; display: block; }
.mt-dock-thumb span { position: absolute; right: 0; top: 0; background: var(--ink); color: #fff; font-size: 11px; line-height: 1; padding: 2px 3px; border-bottom-left-radius: 4px; }
.mt-dock-slot { border: 1.5px dashed #4a4f57; }
body.has-sample-bar .fab { bottom: calc(var(--tabbar-h) + 84px); }
body.has-sample-bar .toast { bottom: calc(var(--tabbar-h) + 96px); }
body.has-sample-bar main { padding-bottom: 72px; }

/* dialogs */
.mt-dialog { border: 0; border-radius: var(--radius-l); padding: 0; width: min(820px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow-l); }
.mt-dialog::backdrop { background: rgba(15,16,20,.55); }
.mt-dialog-inner { display: grid; grid-template-columns: 320px 1fr; position: relative; }
.mtd-swatch { position: relative; min-height: 320px; background: var(--stone); }
.mtd-swatch canvas, .mtd-swatch .sw-flat { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mtd-body { padding: 30px 28px 26px; display: grid; gap: 10px; align-content: start; }
.mtd-body .eyebrow { margin: 0; }
.mtd-body h2 { font-size: 24px; margin: 0; padding-right: 36px; }
.mtd-brand { margin: 0; color: var(--muted); font-weight: 650; font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mtd-desc { margin: 4px 0 2px; color: var(--ink-2); line-height: 1.7; font-size: 15px; }
.mtd-est { background: var(--accent-soft); color: var(--accent-2); border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 14px; }
.mtd-body .kv { font-size: 14px; gap: 6px 16px; }
.mtd-spaces { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mtd-spaces-label { font-size: 13px; color: var(--muted); font-weight: 700; margin-right: 4px; }
.mtd-spaces .chip { height: 26px; font-size: 12.5px; }
.mtd-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.mtd-source { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.mt-cmp-dialog { width: min(1000px, calc(100vw - 24px)); }
.mt-cmp-inner { padding: 28px; position: relative; }
.mt-cmp-inner h2 { font-size: 24px; }
.mt-cmp-table { overflow-x: auto; margin-top: 12px; }
.cmp-tbl { min-width: 0; table-layout: fixed; }
.cmp-tbl th { width: 96px; font-size: 13px; vertical-align: top; background: var(--paper); }
.cmp-tbl td { vertical-align: top; font-size: 14px; line-height: 1.55; }
.cmp-sw { width: 100%; aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; background: var(--stone); position: relative; }
.cmp-sw canvas, .cmp-sw .sw-flat { position: absolute; inset: 0; width: 100%; height: 100%; }

@media (max-width: 960px) {
  .mt-filters { flex-wrap: wrap; }
  .mt-search { flex-basis: 100%; }
  .mt-selects { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .mt-selects .select { max-width: none; width: 100%; }
}
@media (max-width: 640px) {
  .mt-toolbar-wrap { position: static; }
  .mt-cat { min-height: 38px; padding: 0 11px 0 9px; font-size: 13px; }
  .mt-kindrow { flex-direction: column; align-items: stretch; }
  .mt-fav-toggle { margin-left: 0; align-self: flex-start; }
  .mt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mcard-body { padding: 10px 11px 6px; }
  .mcard-name { font-size: 14px; }
  .mcard-desc { display: none; }
  .mcard-badges .badge--accent { display: none; }
  .mcard-actions { grid-template-columns: 1fr 1fr; padding: 0 9px 9px; }
  .mcard-cmp { grid-column: span 2; justify-content: center; }
  .mt-dialog-inner { grid-template-columns: 1fr; }
  .mtd-swatch { min-height: 0; aspect-ratio: 16 / 9; }
  .mtd-body { padding: 20px 18px; }
  .mt-dock-part + .mt-dock-part { padding-left: 0; border-left: 0; }
  .mt-dock-inner { gap: 8px; }
  .mt-dock-text .small { display: none; }
  .mt-cmp-inner { padding: 20px 14px; }
  .mcard-price { font-size: 12.5px; }
  .mt-dock { padding: 8px 0; }
  .mt-dock-inner { flex-wrap: nowrap; gap: 8px; }
  .mt-dock-part { flex-wrap: nowrap; gap: 6px; }
  .mt-dock-thumbs, #sampleClear, #cmpClear, .mt-hide-sm { display: none; }
  .mt-dock .btn--sm { min-height: 34px; padding: 0 10px; font-size: 12.5px; }
  .mt-dock-text b { font-size: 13px; white-space: nowrap; }
  body.has-sample-bar .fab { bottom: calc(var(--tabbar-h) + 64px); }
  .cmp-tbl th { width: 64px; }
}

/* 견적서에 담기 (자재 상세) */
.mtd-quote { margin-top: 14px; padding: 14px; border: 1px solid #efd3bd; background: #fffaf5; border-radius: 12px; }
.mtd-quote-l { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.mtd-quote-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mtd-quote-row select { flex: 1 1 160px; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; font: inherit; background: #fff; }
.mtd-quote-msg { margin: 8px 0 0; font-size: 12.5px; min-height: 1em; }
.mtd-quote-msg a { color: var(--accent); font-weight: 700; }
