/* 화이트는 기존 색상 그대로. 테마는 공개 메인·목록·상세에만 적용한다. */
:root {
  --theme-bg: #fff; --theme-panel: #fff; --theme-soft: #f1f1f1;
  --theme-text: #333; --theme-muted: #666; --theme-border: #c6cbd1;
  --theme-accent: #176447; --theme-highlight: #dd464d;
}
html[data-sonamu-theme="gray"] {
  --theme-bg: #e5e7eb; --theme-panel: #dce1e7; --theme-soft: #cdd3db;
  --theme-text: #24282e; --theme-muted: #535b65; --theme-border: #c6cbd1;
}
html[data-sonamu-theme="black"] {
  --theme-bg: #16181b; --theme-panel: #24272c; --theme-soft: #30353c;
  --theme-text: #f0f2f5; --theme-muted: #bcc4ce; --theme-border: #58616d;
  --theme-accent: #93dfb7; --theme-highlight: #ff9198;
}
.theme-row { display: none; }
html[data-sonamu-theme] .theme-row {
  display: flex; width: fit-content; justify-content: flex-end;
  margin: 3px max(8px, calc((100% - 1200px) / 2)) 3px auto; padding: 0; box-sizing: border-box;
  position: relative; z-index: 3000;
}
.theme-options {
  display: inline-flex; align-items: center; gap: 0;
}
.theme-options button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 23px; height: 28px; padding: 3px; border: 0;
  border-radius: 0; background: transparent; color: var(--theme-muted);
  cursor: pointer;
}
.theme-options svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-options .theme-half { fill: currentColor; stroke: none; }
.theme-options button[aria-pressed="true"] { color: var(--theme-accent); }
.theme-options button[aria-pressed="true"] svg { stroke-width: 2.7; }
.theme-options button:focus-visible { outline: 3px solid var(--theme-accent); outline-offset: 2px; }
.m-view-actions { display: flex; align-items: center; gap: 6px; }
.m-view-actions .m-pc-view-link { white-space: nowrap; flex: none; }
html[data-sonamu-theme] .m-view-actions .theme-row { margin: 0; padding: 0; }
.theme-logo { position: relative; display: inline-block; }
.theme-logo-dark { display: none !important; position: absolute; top: 0; left: 0; width: 100% !important; height: auto; pointer-events: none; }
/* 로고 아래 긴 구분선은 화이트를 포함한 모든 화면에서 숨긴다. */
.tb-line { display: none; }
/* PC 아이콘 줄은 머리글과 본문 사이에 간결하게 배치한다. */
html[data-sonamu-theme] .tb { padding-bottom: 4px; }
html[data-sonamu-theme] .tb + .tb-line + .theme-row { margin-top: 0; margin-bottom: 0; }
.tb + .tb-line + .theme-row .theme-options button { height: 20px; padding-top: 2px; padding-bottom: 2px; }
@media (max-width: 360px) {
  .m-logo-actions .m-social-icons img { width: 28px; }
  .m-view-actions .m-pc-view-link { padding: 9px 7px; gap: 3px; font-size: 11px; }
}
@media screen {
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]),
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) body {
    background: var(--theme-bg) !important; color: var(--theme-text) !important;
  }
  html[data-sonamu-theme="black"] { color-scheme: dark; }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .tb-line, .rg-wrap, .rg-line, .mobile_divider_2, .section_div,
    .home-search-profile, .id-table th, .id-table td, div[style*="border"]) {
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) a { color: var(--theme-text); }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .nc, .cm-box, .list_search, .sidebar_category, .sidebar_recent, .sidebar_links,
    .tb-phone, .tb-notice, .qm-btn, .qm-qr, .iq-card, .home-profile-card, .home-profile-photo,
    .home-profile-name, .id-table, .item_table, .mobile_search, .locationButton,
    .location_Button, .optionButton, .optionButton2) {
    background: var(--theme-panel) !important; color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .sidebar_title, .list_search_title, .tb-head, .qm-qr-title, .sidebar_qrcode_name,
    .sidebar_link_name2, .item_label, .item_label2, .id-table th) {
    background: var(--theme-soft) !important; color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .section_big, .section_button, .list_sort, .sidebar_category_list, .nc-tag.kind,
    .id-wrap, .id-title, .item_name, .tb-phone-body b, .noticeContent, .home-profile-name) {
    color: var(--theme-text) !important; border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .id-addr, .id-danji, .id-near small, .rs-unit, .rs-sep, .iq-card-sub, .qm-btn small, .qm-qr p) {
    color: var(--theme-muted) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .locationSelect, .rs-group select, .rs-input, .rs-cancel, .searchinput_text,
    input[type="text"], input[type="number"], textarea) {
    background: var(--theme-soft) !important; color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) input.locationCheckbox:not(:checked) {
    background-color: var(--theme-panel); border-color: var(--theme-border);
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .detail_search, .searchName, .mobile_search_title, .section_little, .nc-id b,
    .nc-area em, .id-price, .sort_selected) { color: var(--theme-highlight) !important; }
  html[data-sonamu-theme="black"] :is(.id-table td b[style*="color:#000"], .id-table td b[style*="color: #000"]) {
    color: var(--theme-text) !important;
  }
  html[data-sonamu-theme="black"] :is(a[style*="color:blue"], a[style*="color: blue"]) { color: #97c4ff !important; }
  html[data-sonamu-theme="black"] :is(.iq-card svg, .qm-row svg, .tb-head svg) { fill: #97c4ff; }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(.detail_body, .detail_body *) {
    color: var(--theme-text) !important; background-color: transparent !important;
  }
  /* 아파트·빌라(/apt/)·전월세(/rent/) 모바일 화면의 간편메뉴·상세검색 상자 */
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(.easy-menu-box, .search-box, #danji_info_box) {
    background: var(--theme-panel) !important; color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(.easy-menu-title, .search-box-title) {
    background: var(--theme-soft) !important; color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) .search-row {
    border-color: var(--theme-border) !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) .search-row select {
    background-color: var(--theme-soft) !important; color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
  }
  /* 검색 항목과 대표 사진은 별도의 밝은 상자 없이 전체 바탕에 이어진다. */
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(
    .locationButton, .location_Button, .optionButton, .optionButton2,
    .home-profile-card, .home-profile-photo, .home-profile-name) {
    background: transparent !important;
  }
  html:is([data-sonamu-theme="gray"], [data-sonamu-theme="black"]) :is(.tb-logo img, .m-logo-image) {
    background: transparent;
  }
  html[data-sonamu-theme="black"] .theme-logo-dark {
    display: block !important; clip-path: inset(0 0 0 28%);
    filter: brightness(0) invert(1); background: transparent;
  }
}
@media print { .theme-row { display: none !important; } }
