/* 옷장 코디네이터 화면 스타일: 모바일 우선, 라이트·다크 자동 */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --line: #e2e0da;
  --text: #1c1c1a;
  --text-2: #5f5d57;
  --text-3: #6b6963;
  --ink: #1c1c1a;        /* 주 버튼 */
  --ink-text: #ffffff;
  --focus: #2f5fb3;
  --danger: #b3302f;
  --ok: #2f7a4f;
  --radius: 12px;
  --radius-card: 14px;
  --radius-tile: 10px;
  --tile-ink-dark: #1B1A17;   /* 밝은 색 면 위 글자 */
  --tile-ink-light: #F7F7F5;  /* 어두운 색 면 위 글자 */
  --tile-neutral: #D9D8D3;    /* 색을 모르는 옷 */
  --tile-neutral-ink: #1B1A17;
  --gutter: 16px;
  --nav-h: 60px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #272725;
    --line: #34332f;
    --text: #eeede8;
    --text-2: #b3b1aa;
    --text-3: #96948d;
    --ink: #eeede8;
    --ink-text: #141413;
    --focus: #8fb0d6;
    --danger: #e07b7a;
    --ok: #7cc39a;
    --tile-neutral: #3A3935;
    --tile-neutral-ink: #F7F7F5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  overflow-x: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 틀 */
.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.top h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.top .sub { color: var(--text-3); font-size: 14px; font-weight: 500; margin-left: 6px; }
.section { padding: 0 var(--gutter); }
.section + .section { margin-top: 20px; }
.label { font-size: 13px; color: var(--text-2); margin: 0 0 8px; font-weight: 600; }
.hint { font-size: 13px; color: var(--text-3); margin: 6px 0 0; }
.muted { color: var(--text-3); }

/* 아래 탭 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); height: var(--nav-h); }
.nav a {
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--text-3); font-size: 14px; font-weight: 600;
}
.nav a[aria-current="page"] { color: var(--text); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { background: none; border: 0; padding: 0 4px; margin: 0 -4px; min-height: 44px; display: inline-flex; align-items: center; color: var(--text-2); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* 입력 */
.field { display: block; }
.input, .select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 16px; /* iOS 확대 방지 */
  -webkit-appearance: none; appearance: none; /* 브라우저 기본 광택·그림자 끄기 */
}
.select {
  padding-right: 36px; line-height: 1.4;
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235f5d57' stroke-width='1.6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23b3b1aa' stroke-width='1.6'/%3E%3C/svg%3E"); }
}
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; min-width: 44px; justify-content: center; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.chip-sub { font-size: 13px; color: var(--text-3); margin-left: 5px; font-weight: 500; }
.chip[aria-pressed="true"] .chip-sub { color: inherit; opacity: .75; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: none; }
@media (prefers-color-scheme: dark) { .dot { border-color: rgba(255,255,255,.28); } }

/* 구분 탭(검색·사진·링크) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* 옷장 카드 */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  overflow: hidden; text-align: left; padding: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: stretch; min-width: 0; width: 100%;
}
.thumb { width: 100%; aspect-ratio: 1 / 1; background: var(--surface-2); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; border-radius: var(--radius-tile); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-body { padding: 10px 0 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-name { font-size: 15px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { position: absolute; left: 8px; top: 8px; font-size: 13px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.tag.idle { color: var(--text-2); }

/* 검색 결과 줄 */
.results { display: flex; flex-direction: column; gap: 8px; }
.result { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 10px; }
.result .thumb { width: 88px; }
.result-title { font-size: 15px; font-weight: 600; line-height: 1.4; margin: 0; }
.result-meta { font-size: 13px; color: var(--text-2); margin: 2px 0 8px; }
.result-meta a { color: var(--text-2); display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.added { font-size: 13px; color: var(--ok); font-weight: 600; }
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; }
.result-count { font-size: 15px; font-weight: 700; }
.result-head + .hint { margin-top: 2px; }
.quick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.owned { font-size: 13px; color: var(--text-2); font-weight: 600; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }

/* 알림 상자 */
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--text-2); }
.note.warn { border: 1px solid var(--danger); color: var(--text); background: var(--surface); }
.empty { text-align: center; color: var(--text-2); padding: 40px 16px; }
.empty p { margin: 0 0 14px; }

/* 시트(아래에서 올라오는 상세) */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 16px 16px 0 0; padding: 16px var(--gutter) calc(env(safe-area-inset-bottom) + 20px);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 18px; margin: 0; min-width: 0; }
.media-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.media-cap { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.media-cap a { color: var(--text-2); display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* 사진 편집 */
.photo-stage { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.photo-stage canvas { width: 100%; height: auto; display: block; }

/* 알림 띠(토스트) */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); transform: translateX(-50%);
  background: var(--ink); color: var(--ink-text); padding: 10px 14px; border-radius: 10px; font-size: 14px; z-index: 30;
  max-width: calc(100vw - 32px);
}

/* 시작 화면 */
.start { padding: 64px var(--gutter) 24px; display: flex; flex-direction: column; gap: 20px; }
.start h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; }
.start p { margin: 0; color: var(--text-2); }

/* 코디 추천 */
.seg.two { grid-template-columns: repeat(2, 1fr); }
.btn[aria-pressed="true"] { border-color: var(--ink); }
.rec-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.rec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 12px; container-type: inline-size; }
/* 12칸 격자: 칸마다 span을 줘서 마지막 줄을 넓혀 채운다(5벌 = 윗줄 3 + 아랫줄 2). 모든 타일 높이 = 윗줄 타일의 폭(--k는 윗줄 칸 수) */
.rec-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; --k: 2; }
.rec-grid .rec-item .thumb { aspect-ratio: auto; height: calc((100cqw - 8px * (var(--k) - 1)) / var(--k)); }
.rec-item { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px; min-width: 0; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.rec-kind { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-reason { margin: 10px 0 0; font-size: 14px; color: var(--text-2); text-align: left; }
.rec-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.rec-actions2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rec-actions2.one { grid-template-columns: 1fr; }
.saved-row { display: grid; grid-template-columns: 156px minmax(0, 1fr); gap: 12px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 10px; }
.saved-photos { display: grid; grid-template-columns: repeat(3, 48px); gap: 6px; }
.saved-photos .thumb { border-radius: 6px; }
.saved-photos .tile-kind, .saved-photos .tile-color { display: none; } /* 48px 칸은 색 면만 */
.saved-text .result-meta { margin-bottom: 4px; }
.saved-links { display: flex; flex-wrap: wrap; column-gap: 12px; }
/* 코디 추천 끝 */

/* 사진·판매처 이미지가 없는 옷: 큰 회색 칸 대신 색 견본 한 줄 */
.swatch-line { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; min-width: 0; }
.swatch-line .swatch { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }
@media (prefers-color-scheme: dark) { .swatch-line .swatch { border-color: rgba(255,255,255,.28); } }
.photo-attach { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }

/* 옷 타일: 사진이 없으면 옷 색 면 + 종류 큰 글자 */
.tile { --pad: 12px; --kind: 20px; --cname: 13px; }
.tile.tile-rec { --kind: 22px; }
.tile.tile-sm { --pad: 8px; --kind: 16px; }
.tile.face { align-items: flex-end; justify-content: flex-start; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.tile.face.neutral { background: var(--tile-neutral); color: var(--tile-neutral-ink); }
.tile.face[data-ink="dark"] { color: var(--tile-ink-dark); }
.tile.face[data-ink="light"] { color: var(--tile-ink-light); box-shadow: none; }
.tile-text { display: flex; flex-direction: column; gap: 1px; padding: var(--pad); min-width: 0; max-width: 100%; text-align: left; }
.tile-kind { font-size: var(--kind); font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-color { font-size: var(--cname); font-weight: 600; opacity: .85; line-height: 1.3; }
.tile.tile-sm .tile-color { display: none; }

/* 코디 탭 날씨 한 줄 요약 */
.wx-sum { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 2px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; font-size: 15px; font-weight: 600; color: var(--text); }
.wx-sum .chev { color: var(--text-3); transition: transform .15s; }
.wx-sum[aria-expanded="true"] .chev { transform: rotate(90deg); }
[hidden] { display: none !important; }
@media (prefers-color-scheme: dark) {
  .tile.face[data-ink="light"], .tile.face.neutral { box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
}

/* 공유(친구에게 보내기) */
.home-note { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.yline { align-items: center; }
.share-preview { display: block; margin: 0 auto; width: auto; max-width: 100%; max-height: 50vh; aspect-ratio: 4 / 5; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check-row input[type="checkbox"] { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--ink); }
.photo-row .mini { width: 40px; height: 40px; flex: none; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.photo-row .mini img { width: 100%; height: 100%; object-fit: contain; }
.danger-text { color: var(--danger); }

/* 친구 유입·알림 */
.start-via { font-size: 15px; font-weight: 600; color: var(--text); }
.start .start-steps { font-size: 16px; color: var(--text-2); margin-top: -8px; }
.start .start-via { color: var(--text); margin-bottom: -8px; }
.consent { align-items: flex-start; min-height: 44px; padding: 4px 0; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.consent input[type="checkbox"] { margin-top: 1px; }
.check-note { padding-left: 34px; }
.notice-line .notice-text, .notice-line .notice-more { font-size: 14px; line-height: 1.5; }
.inbound .inbound-title { font-size: 15px; color: var(--text); margin: 0 0 10px; }
.inbound-links { display: flex; flex-wrap: wrap; align-items: center; column-gap: 16px; margin-top: 4px; }
.inbound-off { font-size: 14px; color: var(--text-2); min-height: 44px; display: inline-flex; align-items: center; }

/* 개인정보처리방침·고지 링크 */
.legal { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) var(--gutter) 48px; }
.legal h1 { font-size: 22px; margin: 8px 0 0; letter-spacing: -0.01em; }
.legal h2 { font-size: 16px; margin: 28px 0 6px; }
.legal-meta { font-size: 13px; color: var(--text-3); margin: 4px 0 0; }
.legal ul { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 15px; }
.legal li { margin: 6px 0; }
.legal p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.legal-back { margin: 0 !important; }
.legal-report { margin-top: 36px !important; padding-top: 16px; border-top: 1px solid var(--line); }
.legal-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-2); font-size: 14px; text-decoration: underline; }
