/* ==========================================================
   오른쪽 광고 영역 2열: 위 = 단위 환산(2칸 합침), 아래 = 바로가기(1칸)
   색: 에메랄드 + 샴페인 골드 / 아이보리 (보라·청록 계열과 겹치지 않게)
   ========================================================== */

/* ---------- 단위 환산 (units.js) : 입력칸 2개, 어느 쪽에 넣어도 반대쪽이 계산됨 ---------- */
.ad-grid .unit-widget {
    grid-column: 2;
    grid-row: 1 / span 2;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 7px 8px 6px;
    overflow: hidden;
    background:
        radial-gradient(120% 70% at 100% 0%, rgba(216, 192, 138, 0.18), transparent 60%),
        linear-gradient(160deg, #10372f 0%, #1b5245 58%, #286654 100%);
    border: 1px solid #0d2f28;
    color: #f3ead4;
    font-size: 0.8rem;
    box-shadow: inset 0 0 0 1px rgba(216, 192, 138, 0.22);
}

.uc-title {
    margin: 0 0 1px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.04em;
    text-align: center;
    color: #f3ead4;
}

.uc-select {
    width: 100%;
    min-width: 0;
    height: 24px;
    padding: 0 22px 0 7px;
    border: 1px solid rgba(216, 192, 138, 0.5);
    border-radius: 6px;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d8c08a' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 7px center / 9px 6px,
        rgba(0, 0, 0, 0.22);
    color: #f3ead4;
    font: inherit;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.uc-select:focus { outline: none; border-color: #d8c08a; }
.uc-select option { color: #1b2b26; background: #faf6ee; }

/* 하얀(아이보리) 입력칸 2개 */
.uc-in {
    display: flex;
    align-items: stretch;
    height: 26px;
    border-radius: 6px;
    background: #f7f1e1;
    overflow: hidden;
}
.uc-in input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 6px;
    border: 0;
    background: transparent;
    color: #17312a;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
}
.uc-in input:focus { outline: none; }
.uc-in:focus-within { box-shadow: 0 0 0 2px rgba(216, 192, 138, 0.85); }
.uc-unit {
    flex: none;
    display: grid;
    place-items: center;
    padding: 0 6px;
    background: #ece2c8;
    color: #5f4e30;
    font-size: 0.66rem;
    font-weight: 600;
    white-space: nowrap;
}

/* 두 칸 사이 작은 ⇅ 표시 */
.uc-link {
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #d8c08a;
}
.uc-link::before,
.uc-link::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: rgba(216, 192, 138, 0.3);
}
.uc-link svg { width: 10px; height: 10px; flex: none; }

.uc-hint {
    margin-top: auto;
    font-size: 0.6rem;
    text-align: center;
    color: rgba(243, 234, 212, 0.62);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "크게 보기 ›" 링크 (2026-11-15, units.js가 제목 줄 오른쪽에 붙여요 → 단위 환산 페이지 units.html) */
.unit-widget.has-more .uc-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    text-align: left;
    padding-left: 2px;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.uc-more {
    flex: none;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid rgba(216, 192, 138, 0.45);
    color: #d8c08a;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.uc-more:hover,
.uc-more:focus-visible { background: #d8c08a; color: #10372f; outline: none; }

/* ---------- 게임 입구 (2026-11-12, 폰에서만 보임 — 아래 폰 부분) ---------- */
.ad-grid .game-widget { display: none; }
.ad-grid .tools-widget { display: none; }   /* 생활 도구 (2026-11-15, 폰에서만) */

/* ---------- 바로가기 (구글 · 네이버 · 유튜브 · 빙) ---------- */
.ad-grid .quick-links {
    grid-column: 2;
    grid-row: 3;
    height: auto;
    min-height: 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px 6px;
    background: linear-gradient(180deg, #fbf8f1 0%, #f1e9d9 100%);
    border: 1px solid #d9c9a8;
    color: #5b4636;
    font-size: 0.8rem;
}

.ql-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.32em;
    text-indent: 0.32em;     /* 글자 간격 때문에 생기는 오른쪽 쏠림 보정 */
    color: #6d5641;
    white-space: nowrap;
}
.ql-title::before,
.ql-title::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c6ab78);
}
.ql-title::after { background: linear-gradient(90deg, #c6ab78, transparent); }

.ql-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 38px));
    justify-content: space-evenly;
    gap: 6px;
}

.ql-item {
    position: relative;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 9px;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(60, 40, 20, 0.18), 0 2px 6px rgba(60, 40, 20, 0.10);
    transition: transform 0.15s, box-shadow 0.15s;
}
.ql-item:hover,
.ql-item:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 3px 5px rgba(60, 40, 20, 0.22), 0 6px 12px rgba(60, 40, 20, 0.14);
    outline: none;
}
.ql-item span {
    font-family: Arial, sans-serif;
    font-weight: 900;
    line-height: 1;
}

/* 구글: 흰 바탕 + 한 가지 색 G (2026-11-09 네 가지 색 로고 느낌 → 단색으로) */
.ql-google { background: #fff; border: 1px solid #e3e3e3; }
.ql-google span {
    font-size: 1.45rem;
    color: #3b6fd8;
}

/* 네이버: 슬레이트 바탕 + 민트 N (예전 칸과 같은 모양) */
.ql-naver { background: #576574; }
.ql-naver span { font-size: 1.3rem; color: #00d2d3; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); }

/* 유튜브: 검정 바탕 + 빨간 재생 표시 (2026-11-09 넷플릭스→유튜브) */
.ql-youtube { background: #141414; }
.ql-youtube svg { width: 52%; height: 52%; }

/* 빙: 직접 그린 아이콘 (돋보기 + 반짝임) */
.ql-bing { background: none; }
.ql-bing svg { width: 100%; height: 100%; display: block; }

/* ==========================================================
   모바일: 오른쪽 광고 영역은 원래 숨겨지지만,
   바로가기 → 단위 환산 순서로 맨 끝(뉴스 줄 아래)에 보이게 해요. (2026-11-09)
   ========================================================== */
@media screen and (max-width: 768px), screen and (hover: none) and (pointer: coarse) and (max-width: 1000px) {
    .page-layout .ad-sidebar {
        display: block;
        margin-top: 14px;
    }
    .ad-sidebar .ad-grid {
        height: auto;
        grid-template-columns: 1fr;
        grid-template-rows: none;
        gap: 14px;
    }
    /* 졸라맨·주식은 모바일에서 숨김 (2026-11-15: 주식 대신 환율이 보임, 2026-11-18: 우편번호도 보임) */
    .ad-sidebar .ad-grid > :not(.unit-widget):not(.quick-links):not(.game-widget):not(.tools-widget):not(.fx-widget):not(.pst-col) { display: none; }

    .ad-grid .unit-widget,
    .ad-grid .quick-links {
        grid-column: 1;
        grid-row: auto;
        border-radius: 8px;
    }
    /* 폰에서는 바로가기 → 단위 환산 순서 */
    .ad-grid .quick-links { order: 1; }
    .ad-grid .unit-widget { order: 2; }

    .ad-grid .unit-widget { gap: 7px; padding: 12px 14px 10px; }
    .uc-title  { font-size: 1.05rem; }
    .uc-select { height: 38px; font-size: 0.95rem; padding-left: 10px; }
    .uc-in     { height: 44px; border-radius: 8px; }
    .uc-in input { font-size: 16px; padding: 0 10px; }   /* 16px 미만이면 아이폰이 확대해 버려요 */
    .uc-unit   { font-size: 0.85rem; padding: 0 12px; min-width: 96px; }
    .uc-link   { height: 14px; }
    .uc-link svg { width: 13px; height: 13px; }
    .uc-hint   { font-size: 0.75rem; margin-top: 2px; }
    .uc-more   { font-size: 0.8rem; padding: 3px 11px; }

    .ad-grid .quick-links { gap: 9px; padding: 10px 14px 14px; }
    .ql-title  { font-size: 0.75rem; }
    .ql-row    { grid-template-columns: repeat(4, minmax(0, 56px)); }
    .ql-item   { border-radius: 12px; }
    .ql-google span { font-size: 2rem; }
    .ql-naver span  { font-size: 1.8rem; }

    /* 환율: 단위 환산 아래 (2026-11-15 폰에서 주식시장 대신). 외화 8개를 2줄씩 (4행 × 2열) */
    .ad-grid .fx-widget {
        order: 3;
        grid-column: 1;
        grid-row: auto;
        height: auto;
        padding: 12px 14px 10px;
        border-radius: 8px;
    }
    .fx-title { font-size: 1.05rem; margin-bottom: 8px; }
    .fx-title small { font-size: 0.78rem; }
    .fx-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
    .fx-list li { padding: 9px 2px; gap: 7px; border-top: 1px solid rgba(255, 255, 255, 0.22); }
    .fx-list li:nth-child(2) { border-top: 0; }
    .fx-flag { width: 26px; height: 18px; }
    .fx-name { font-size: 0.86rem; }
    .fx-val  { font-size: 0.95rem; }
    .fx-foot { font-size: 0.7rem; gap: 3px; margin-top: 8px; }

    /* 생활 도구 (2026-11-15): 주식시장 아래, 게임 위. 모양은 게임 칸과 같고 카드만 에메랄드 */
    .ad-grid .tools-widget {
        order: 4;
        grid-column: 1;
        grid-row: auto;
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 9px;
        padding: 10px 14px 14px;
        border-radius: 8px;
        background: linear-gradient(180deg, #fbf8f1 0%, #f1e9d9 100%);
        border: 1px solid #d9c9a8;
        color: #5b4636;
    }
    .ad-grid .tools-widget .tw-item { background: #e3efe8; border-color: #b9d3c4; color: #10372f; }
    .ad-grid .tools-widget .tw-item small,
    .ad-grid .tools-widget .tw-item .gw-go { color: #2c6a58; }

    /* 게임 입구: 생활 도구 아래, 위 칸들과 같은 간격(14px) */
    .ad-grid .game-widget {
        order: 5;
        grid-column: 1;
        grid-row: auto;
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 9px;
        padding: 10px 14px 14px;
        border-radius: 8px;
        background: linear-gradient(180deg, #fbf8f1 0%, #f1e9d9 100%);
        border: 1px solid #d9c9a8;
        color: #5b4636;
    }
    .gw-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px 10px 10px;
        border-radius: 12px;
        background: #DAD9FF;
        border: 1px solid #c3c1f0;
        color: #36347a;
        text-decoration: none;
        box-shadow: 0 1px 2px rgba(60, 40, 20, 0.18), 0 2px 6px rgba(60, 40, 20, 0.10);
    }
    .gw-item:active { transform: translateY(1px); }
    .gw-board { width: 46px; height: 46px; flex: none; border-radius: 8px; box-shadow: 0 1px 3px rgba(70, 40, 10, 0.3); }
    .gw-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    .gw-text b { font-size: 1.05rem; }
    .gw-text small { font-size: 0.8rem; color: #5a57b5; }
    .gw-go { font-size: 1.6rem; line-height: 1; color: #5a57b5; }
}

/* ===== 폰 홈 간격 정리 1단계 (2026-11-17): 모든 칸 사이 14px로 통일, 배너와 제목 사이 8px =====
   PC는 그대로. 숫자를 바꾸려면 --m-gap 하나만 */
@media screen and (max-width: 768px), screen and (hover: none) and (pointer: coarse) and (max-width: 1000px) {
    html body { --m-gap: 14px; }
    html body .site-header { margin-top: 8px; margin-bottom: var(--m-gap); }
    html body .dc-mobile { margin-bottom: var(--m-gap); }
    html body .windows-logo-layout { gap: var(--m-gap); }
    html body .news-bar { margin-top: var(--m-gap); }
    html body .ad-sidebar { margin-top: var(--m-gap); }
    html body .site-footer { margin-top: calc(var(--m-gap) + 6px); }
}

/* ===== 폰 홈 정리 2단계 (2026-11-17): 위쪽 칸들도 아래 칸들처럼 모서리 둥글게(8px), 단위 환산 제목 가운데 =====
   PC는 그대로 */
@media screen and (max-width: 768px), screen and (hover: none) and (pointer: coarse) and (max-width: 1000px) {
    html body .center-panel .calculator,
    html body .center-panel .square.top-right,
    html body .center-panel .square.bottom-left,
    html body .center-panel .square.bottom-right,
    html body .news-bar { border-radius: 8px; overflow: hidden; }
    html body .dc-mobile .dc-note { border-radius: 8px; }
    /* 단위 환산 제목: 날씨·환율처럼 가운데, "크게 보기 ›"는 오른쪽 끝 그대로 */
    html body .unit-widget.has-more .uc-title { position: relative; display: block; text-align: center; padding: 0 84px; }
    html body .unit-widget.has-more .uc-more { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
}

/* 2026-11-17: 홈 "게임" 막대의 3·4번째 칸(영단어·지뢰찾기)이 진짜 링크가 됨 →
   위 칸과의 3px 틈에서도 마우스가 끊기지 않게 투명 칸 (예전엔 .ib-empty::after가 해 주던 일) */
.info-bar .ib-pop3:not(.ib-empty)::after,
.info-bar .ib-pop4:not(.ib-empty)::after,
.info-bar .ib-pop5:not(.ib-empty)::after { content: ""; position: absolute; left: 0; top: -4px; width: 100%; height: 4px; }

/* ===== 2026-11-18: 폰에서도 우편번호 검색 보이기 (환율 아래) + 생활 도구 카드 색을 도구마다 다르게 =====
   폰 맨 끝 순서: 바로가기 → 단위 환산 → 환율 → 우편번호 → 생활 도구 → 게임 */
@media screen and (max-width: 768px), screen and (hover: none) and (pointer: coarse) and (max-width: 1000px) {
    html body .ad-sidebar .ad-grid > .pst-col { display: block; order: 4; grid-column: 1; grid-row: auto; }
    html body .ad-grid .pst-col .spare-widget { display: none; }
    html body .ad-grid .tools-widget { order: 5; }
    html body .ad-grid .game-widget { order: 6; }
    html body .ad-grid .postal-widget { padding: 12px 14px 10px; border-radius: 8px; font-size: 0.95rem; }
    html body .postal-widget .pst-title { font-size: 1.05rem; margin-bottom: 10px; }
    html body .postal-widget .pst-btn { padding: 11px 0; font-size: 1rem; border-radius: 8px; }
    html body .postal-widget .pst-zip { max-width: 260px; margin: 0 auto; gap: 6px; }
    html body .postal-widget .pst-d { font-size: 1.5rem; }
    html body .postal-widget .pst-addr { font-size: 0.85rem; margin-top: 6px; }
    html body .postal-widget .pst-copy,
    html body .postal-widget .pst-reset { font-size: 0.82rem; padding: 6px 14px; }
    html body .postal-widget .pst-msg { font-size: 0.75rem; }

    /* 생활 도구 카드: 도구 페이지 색과 같게 */
    html body .tools-widget .tw-item[href^="units"]     { background: #e3efe8; border-color: #b9d3c4; color: #10372f; }
    html body .tools-widget .tw-item[href^="age"]       { background: #e1f1f1; border-color: #a9d2d2; color: #0e3a44; }
    html body .tools-widget .tw-item[href^="severance"] { background: #f6ecdc; border-color: #dcc39b; color: #3a2412; }
    html body .tools-widget .tw-item[href^="charcount"] { background: #e6eefa; border-color: #b3c8ea; color: #13254a; }
    html body .tools-widget .tw-item[href^="loan"]      { background: #f8e8f0; border-color: #e3b7cb; color: #3a1430; }
    html body .tools-widget .tw-item[href^="tools"]     { background: #ecebfb; border-color: #c4c2ef; color: #22205a; }
    html body .tools-widget .tw-item[href^="age"] small,       html body .tools-widget .tw-item[href^="age"] .gw-go       { color: #1d5f6b; }
    html body .tools-widget .tw-item[href^="severance"] small, html body .tools-widget .tw-item[href^="severance"] .gw-go { color: #8a5a1c; }
    html body .tools-widget .tw-item[href^="charcount"] small, html body .tools-widget .tw-item[href^="charcount"] .gw-go { color: #2f5f9a; }
    html body .tools-widget .tw-item[href^="loan"] small,      html body .tools-widget .tw-item[href^="loan"] .gw-go      { color: #a33b6b; }
    html body .tools-widget .tw-item[href^="tools"] small,     html body .tools-widget .tw-item[href^="tools"] .gw-go     { color: #5a57b5; }
}

/* ===== 2026-11-18: 도구 창에서 홈으로 왔을 때 "생활 도구로 돌아가기" 버튼 (index.html 맨 아래 스크립트가 붙여요) ===== */
.back-to-tools {
    position: fixed; left: 14px; top: 14px; z-index: 2147482000;
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px 9px 11px;
    border-radius: 999px; background: linear-gradient(180deg, #4d4aa6, #36347a); color: #fff;
    font: 700 0.92rem/1 "Noto Sans KR", "Malgun Gothic", sans-serif; text-decoration: none;
    box-shadow: 0 6px 18px rgba(30, 28, 80, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.back-to-tools svg { width: 16px; height: 16px; }
.back-to-tools:hover { background: linear-gradient(180deg, #5a57b5, #3f3c8c); }
@media screen and (max-width: 768px) { .back-to-tools { left: 10px; top: auto; bottom: 14px; font-size: 0.95rem; padding: 11px 18px 11px 13px; } }
