/* house.orch-lab.tech — 하우스 조립실
   모바일 퍼스트 · 840px 중앙정렬 · BEM + CSS Custom Properties */

:root {
    --paper: #f7f5f0;
    --paper-2: #efece4;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e4ded3;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --warm: #c2620a;
    --warm-soft: #fdecd8;
    --card: #ffffff;
    --blueprint: #1e3a5f;
    --grid-line: #c9d6e6;
    --human: #e23b3b;
    --ok: #16a34a;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 10px 30px rgba(20, 30, 50, .05);
    --shadow-sm: 0 1px 2px rgba(20, 30, 50, .08);
    --max: 840px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Malgun Gothic", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(circle at 1px 1px, rgba(30, 58, 95, .05) 1px, transparent 0) 0 0 / 22px 22px,
        var(--paper);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ───────── 레이아웃 셸 ───────── */
.app {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 16px 120px;
}

.header {
    text-align: center;
    padding: 26px 0 10px;
}
.header__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.02em;
}
.header__title .em { color: var(--accent); }
.header__tagline {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: .9rem;
}

/* 탭 */
.tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 6px;
    padding: 10px 0;
    margin-bottom: 8px;
    background: linear-gradient(var(--paper) 70%, transparent);
    backdrop-filter: blur(2px);
}
.tabs__btn {
    flex: 1;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    border-radius: 999px;
    padding: 10px 8px;
    font-size: .95rem;
    font-weight: 700;
    transition: .15s;
}
.tabs__btn[aria-selected="true"] {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}
.tabs__btn .badge {
    display: inline-block;
    min-width: 18px;
    margin-left: 4px;
    padding: 0 5px;
    font-size: .72rem;
    font-weight: 800;
    color: var(--ink);
    background: var(--warm-soft);
    border-radius: 999px;
}
.tabs__btn[aria-selected="true"] .badge { color: var(--ink); background: #fff; }

.view[hidden] { display: none; }
.section-intro {
    font-size: .9rem;
    color: var(--muted);
    margin: 4px 2px 14px;
}

/* ───────── 스케일 가이드 ───────── */
.scale {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.scale__head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: .98rem;
    margin-bottom: 4px;
}
.scale__head .tag {
    font-size: .72rem;
    font-weight: 700;
    color: var(--human);
    background: #fdeaea;
    padding: 2px 8px;
    border-radius: 999px;
}
.scale__body { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.scale__svg { flex: 0 0 auto; }
.scale__note { flex: 1 1 180px; font-size: .85rem; color: var(--muted); }
.scale__note b { color: var(--ink); }

/* ───────── 필터 칩 ───────── */
.filters {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 2px 2px 10px;
    margin: 0 -2px 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: .86rem;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
    transition: .15s;
}
.chip[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--blueprint);
}

/* ───────── 방 카드 그리드 ───────── */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: var(--shadow-sm);
    transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card__thumb {
    background: #fbfaf7;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 8px;
}
.card__thumb svg { width: 100%; height: 100%; }
.card__name { font-weight: 800; font-size: .92rem; display: flex; align-items: center; gap: 4px; }
.card__meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.card__meta .py { color: var(--warm); font-weight: 800; }
.card__add {
    width: 100%;
    margin-top: 9px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    padding: 8px;
    font-weight: 800;
    font-size: .86rem;
    transition: .15s;
}
.card__add--in {
    background: var(--ok);
    border-color: var(--ok);
}
.card__count {
    position: absolute;
    top: 6px; right: 6px;
    min-width: 22px; height: 22px;
    display: grid; place-items: center;
    background: var(--ok); color: #fff;
    border-radius: 999px;
    font-size: .76rem; font-weight: 800;
    box-shadow: var(--shadow-sm);
}

/* ───────── 하단 트레이 ───────── */
.tray {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(6px);
    box-shadow: 0 -6px 24px rgba(20, 30, 50, .07);
}
.tray__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 12px;
}
.tray__summary { flex: 1; min-width: 0; }
.tray__count { font-weight: 800; font-size: .95rem; }
.tray__pyeong { font-size: .82rem; color: var(--muted); }
.tray__pyeong b { color: var(--warm); }
.tray__btn {
    flex: 0 0 auto;
    border: none;
    background: var(--ink);
    color: #fff;
    border-radius: 999px;
    padding: 13px 20px;
    font-weight: 800;
    font-size: .95rem;
    box-shadow: var(--shadow);
    transition: .15s;
}
.tray__btn:disabled { opacity: .4; }
.tray__btn--accent { background: var(--accent); }

/* ───────── 조립 결과 모달/패널 ───────── */
.result {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(20, 30, 50, .45);
}
.result[hidden] { display: none; }
.result__sheet {
    width: 100%;
    max-width: var(--max);
    max-height: 92vh;
    overflow-y: auto;
    background: var(--paper);
    border-radius: 20px 20px 0 0;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(40px); } to { transform: none; } }
.result__grip { width: 42px; height: 5px; background: var(--line); border-radius: 999px; margin: 8px auto 12px; }
.result__title { font-size: 1.15rem; font-weight: 800; margin: 0 0 2px; }
.result__sub { color: var(--muted); font-size: .86rem; margin: 0 0 12px; }
.result__plan {
    background: #fbfaf7;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    overflow: auto;
}
.result__plan svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }

/* AI 코멘트 */
.comment {
    margin: 14px 0;
    border: 1px solid var(--accent-soft);
    background: linear-gradient(180deg, #f4f8ff, #fff);
    border-radius: var(--radius);
    padding: 14px;
}
.comment__head { display: flex; align-items: center; gap: 7px; font-weight: 800; font-size: .9rem; margin-bottom: 8px; }
.comment__head .ai { font-size: .7rem; color: #fff; background: var(--accent); padding: 2px 7px; border-radius: 999px; }
.comment__list { margin: 0; padding-left: 2px; list-style: none; display: grid; gap: 7px; }
.comment__list li { display: flex; gap: 8px; font-size: .88rem; }
.comment__list .ic { flex: 0 0 auto; }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.stat {
    flex: 1 1 90px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
}
.stat__k { font-size: .72rem; color: var(--muted); }
.stat__v { font-size: 1.05rem; font-weight: 800; }
.stat__v .u { font-size: .72rem; color: var(--muted); font-weight: 600; }

.result__actions { display: flex; gap: 9px; margin-top: 16px; }
.btn {
    flex: 1;
    border-radius: 999px;
    padding: 13px;
    font-weight: 800;
    font-size: .92rem;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ───────── 관리실 ───────── */
.manage__empty {
    text-align: center;
    color: var(--muted);
    padding: 50px 20px;
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    background: var(--card);
}
.manage__empty .big { font-size: 2rem; }
.manage__empty .go {
    margin-top: 14px;
    display: inline-block;
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 11px 18px;
    border-radius: 999px;
    font-weight: 800;
}
.manage__lead {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 14px;
}
.manage__lead .ttl { font-weight: 800; }
.manage__lead .desc { font-size: .82rem; color: var(--muted); flex-basis: 100%; }

.elgroup { margin-bottom: 16px; }
.elgroup__title {
    font-size: .82rem; font-weight: 800; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
    margin: 0 2px 8px;
}
.el {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 9px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.el__head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 13px;
}
.el__check {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    border: 2px solid var(--line);
    border-radius: 7px;
    display: grid; place-items: center;
    background: var(--paper);
    color: transparent;
    font-size: .9rem; font-weight: 900;
    transition: .12s;
}
.el__check[aria-checked="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.el__icon { font-size: 1.3rem; flex: 0 0 auto; }
.el__main { flex: 1; min-width: 0; }
.el__name { font-weight: 800; font-size: .95rem; }
.el__cycle { font-size: .8rem; color: var(--warm); font-weight: 700; }
.el__sys { font-size: .68rem; color: var(--blueprint); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; margin-left: 4px; vertical-align: middle; }
.el__toggle {
    flex: 0 0 auto;
    border: none; background: transparent;
    color: var(--muted); font-size: 1.1rem;
    transition: transform .15s;
}
.el[open] .el__toggle { transform: rotate(180deg); }
.el__body {
    padding: 0 14px 14px 60px;
    font-size: .86rem;
    color: var(--ink);
}
.el__body[hidden] { display: none; }
.el__meta { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.el__meta .pill {
    font-size: .72rem; font-weight: 700;
    background: var(--paper-2); color: var(--muted);
    padding: 2px 9px; border-radius: 999px;
}
.el__rooms { color: var(--muted); font-size: .78rem; margin-top: 8px; }

/* 관리실 하단 다운로드 바 (트레이 재사용) */
.dlbar .tray__btn { background: var(--warm); }

/* 공통 작은 유틸 */
.center { text-align: center; }
.spinner {
    width: 30px; height: 30px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 40px auto;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    left: 50%; bottom: 92px;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: #fff;
    padding: 11px 18px; border-radius: 999px;
    font-size: .86rem; font-weight: 700;
    box-shadow: var(--shadow);
    opacity: 0; pointer-events: none;
    transition: .25s;
    z-index: 60;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
