/* ================================================
   삼가 스타일 — 열람 페이지 (sg-*)
   ================================================ */
:root {
    --sg-primary: #4B3728;
    --sg-accent:  #C8900A;
    --sg-bg:      #FAF6F2;
    --sg-card:    #FFFFFF;
    --sg-border:  #EDE8E3;
}

.sg-wrap {
    max-width: 480px;
    margin: 0 auto;
    background: var(--sg-bg);
    min-height: 100vh;
    padding-bottom: 80px;
}

/* 헤더 */
.sg-header {
    background: var(--sg-primary);
    color: #fff;
    text-align: center;
    padding: 28px 20px 32px;
}
.sg-home-name {
    font-size: .78rem;
    opacity: .75;
    letter-spacing: .06em;
    margin-bottom: 14px;
}
.sg-photo-wrap {
    width: 88px; height: 108px;
    margin: 0 auto 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,.25);
}
.sg-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.sg-announce {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.9;
    word-break: keep-all;
}
.sg-age-gender { font-size: .88em; font-weight: 400; }

/* 약력 */
.sg-biography {
    padding: 9px 16px;
    background: rgba(75,55,40,.06);
    font-size: .82rem;
    color: var(--sg-primary);
}

/* 카드 */
.sg-card {
    background: var(--sg-card);
    margin: 10px 0;
    padding: 16px;
    border-top: 1px solid var(--sg-border);
    border-bottom: 1px solid var(--sg-border);
}
.sg-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.sg-card-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--sg-accent);
    margin-bottom: 10px;
}
.sg-card-head .sg-card-label { margin-bottom: 0; }

/* D-day 뱃지 */
.sg-dday {
    font-size: .72rem;
    background: var(--sg-accent);
    color: #fff;
    padding: 3px 9px;
    border-radius: 20px;
    font-weight: 600;
}
.sg-dday--today { background: #c0392b; }

/* 상주 */
.sg-mourner-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    padding: 4px 0;
}
.sg-relation { color: var(--sg-accent); font-size: .78rem; min-width: 30px; }
.sg-mname   { font-weight: 600; }
.sg-mphone  { font-size: .78rem; color: #999; margin-left: auto; }

/* 상주말씀 */
.sg-message {
    font-size: .88rem;
    line-height: 1.85;
    color: #444;
    word-break: keep-all;
}

/* 장례정보 테이블 */
.sg-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.sg-table th {
    width: 44px;
    color: var(--sg-accent);
    font-weight: 500;
    text-align: left;
    padding: 5px 0;
    vertical-align: top;
}
.sg-table td { padding: 5px 0; }

/* 오시는 길 */
.sg-address { font-size: .84rem; color: #555; margin-bottom: 12px; }
.sg-tel-icon { font-size: 1.1rem; }

.sg-nav-row { display: flex; gap: 8px; margin-top: 12px; }
.sg-nav-btn {
    flex: 1;
    padding: 10px 6px;
    border: 1.5px solid var(--sg-border);
    border-radius: 8px;
    background: #fff;
    font-size: .82rem;
    cursor: pointer;
    color: #333;
    transition: background .15s;
}
.sg-nav-btn:hover { background: var(--sg-bg); }

.sg-info-box {
    margin-top: 10px;
    padding: 12px;
    background: var(--sg-bg);
    border-radius: 8px;
    font-size: .83rem;
    line-height: 1.7;
    color: #444;
}

.sg-findway-btn {
    display: block;
    text-align: center;
    margin-top: 12px;
    padding: 11px;
    background: var(--sg-primary);
    color: #fff;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 500;
    letter-spacing: .02em;
}

/* 하단 고정 바 */
.sg-bottom-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    z-index: 100;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 -2px 12px rgba(0,0,0,.12);
}
.sg-btn-wreath {
    flex: 1;
    padding: 16px 8px;
    background: var(--sg-primary);
    color: #fff;
    border: none;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}
.sg-btn-share {
    flex: 1;
    padding: 16px 8px;
    background: #fff;
    color: var(--sg-primary);
    border: none;
    border-top: 1.5px solid var(--sg-border);
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}

/* 공유 시트 */
.sg-share-sheet {
    position: fixed;
    inset: 0;
    z-index: 200;
}
.sg-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
}
.sg-sheet-body {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px 32px;
    max-width: 480px;
    margin: 0 auto;
}
.sg-sheet-title {
    text-align: center;
    font-weight: 700;
    font-size: .95rem;
    margin-bottom: 20px;
    color: #333;
}
.sg-sheet-btns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.sg-sheet-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: .78rem;
    color: #333;
    padding: 8px 4px;
}
.sg-sheet-icon {
    width: 48px; height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
}
.sg-icon-kakao { background: #FEE500; color: #3C1E1E; font-size: 1rem; }
.sg-icon-copy  { background: #E8F4FD; font-size: 1.2rem; }
.sg-icon-sms   { background: #E8F8F0; font-size: 1.2rem; }
.sg-icon-edit  { background: #F5F5F5; font-size: 1rem; }

/* ================================================
   삼가 스타일 — 작성 페이지
   ================================================ */
.sg-create-page {
    display: flex;
    gap: 40px;
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 60px;
    align-items: flex-start;
}

/* 미리보기 컬럼 */
.sg-create-preview { flex: 0 0 260px; }
.sg-preview-label {
    text-align: center;
    font-size: .78rem;
    color: #999;
    margin-bottom: 10px;
}
.sg-phone-frame {
    width: 240px;
    height: 480px;
    border: 7px solid #222;
    border-radius: 32px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    background: var(--sg-bg);
    margin: 0 auto;
    position: sticky;
    top: 70px;
}
.sg-phone-screen {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.sg-phone-screen::-webkit-scrollbar { display: none; }
/* 카드 템플릿 미리보기: phone-screen 클래스 height 덮어쓰기 */
.sg-phone-screen .phone-screen {
    height: auto !important;
    min-height: 150px;
    flex-shrink: 0;
}

/* 미리보기 내부 */
.prev-header {
    background: #4B3728;
    color: #fff;
    padding: 16px 12px;
    text-align: center;
}
.prev-home { font-size: .65rem; opacity: .75; margin-bottom: 8px; }
.prev-photo-wrap {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 10px;
    border: 2px solid rgba(255,255,255,.45);
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
}
.prev-photo-placeholder {
    font-size: .7rem;
    color: rgba(255,255,255,.65);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.prev-announce {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.75;
    word-break: keep-all;
}
.prev-card {
    background: #fff;
    padding: 10px 12px;
    margin: 8px 0;
    border-top: 1px solid #EDE8E3;
    border-bottom: 1px solid #EDE8E3;
}
.prev-label { font-size: .65rem; font-weight: 700; color: #C8900A; margin-bottom: 5px; }
.prev-row { display: flex; gap: 8px; font-size: .68rem; color: #333; padding: 2px 0; }
.prev-row span:first-child { color: #C8900A; min-width: 22px; }

.sg-preview-mobile-btn {
    display: none;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--sg-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .88rem;
    cursor: pointer;
}

/* 폼 컬럼 */
.sg-create-form { flex: 1; min-width: 0; }
.sg-form-header { margin-bottom: 20px; }
.sg-form-header h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.sg-form-header p  { font-size: .88rem; color: #888; }
.sg-template-badge {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 10px;
    background: #f4f0ec; border-radius: 20px;
    padding: 5px 12px; font-size: .8rem;
}
.sg-template-badge-label { color: #999; }
.sg-template-badge-name  { font-weight: 700; color: #4B3728; }
.sg-template-badge-change {
    color: #C8900A; text-decoration: none; font-size: .76rem;
    border-left: 1px solid #ddd; padding-left: 6px; margin-left: 2px;
}
.sg-template-badge-change:hover { text-decoration: underline; }

.sg-form-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sg-section-title { font-size: 1rem; font-weight: 700; color: #222; margin-bottom: 16px; }
.sg-opt  { font-size: .75rem; font-weight: 400; color: #aaa; margin-left: 4px; }
.sg-unit { font-size: .78rem; color: #aaa; }
.sg-section-desc { font-size: .8rem; color: #aaa; margin-bottom: 12px; margin-top: -10px; }

.sg-field { margin-bottom: 14px; }
.sg-field:last-child { margin-bottom: 0; }
.sg-field label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}
.sg-field input,
.sg-field select,
.sg-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #E0E0E0;
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    color: #222;
    background: #FAFAFA;
    transition: border-color .15s;
    box-sizing: border-box;
}
.sg-field input:focus,
.sg-field select:focus,
.sg-field textarea:focus {
    border-color: var(--sg-primary);
    outline: none;
    background: #fff;
}
.sg-field.required label::after { content: ' *'; color: #e74c3c; }

.sg-field-row { display: flex; gap: 10px; margin-bottom: 14px; }
.sg-field-row .sg-field { margin-bottom: 0; }

.sg-chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.sg-chip {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 14px;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    font-size: .82rem;
    cursor: pointer;
    color: #555;
    transition: all .15s;
    user-select: none;
}
.sg-chip:has(input:checked) {
    border-color: var(--sg-primary);
    background: var(--sg-primary);
    color: #fff;
}
.sg-chip input { display: none; }

.sg-addr-row { display: flex; gap: 8px; }
.sg-addr-row input { flex: 1; }
.sg-addr-btn {
    flex: 0 0 80px;
    padding: 10px 8px;
    background: var(--sg-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .8rem;
    cursor: pointer;
    white-space: nowrap;
}

.sg-rip-text {
    font-size: .84rem;
    color: var(--sg-primary);
    background: rgba(75,55,40,.06);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.sg-char-count { font-size: .78rem; color: #aaa; float: right; margin-top: 4px; }

.sg-photo-upload { display: flex; gap: 16px; align-items: flex-start; }
.sg-photo-box {
    width: 90px; height: 110px;
    border: 2px dashed #ddd;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fafafa;
}
.sg-photo-box img { width: 100%; height: 100%; object-fit: cover; }
.sg-photo-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: .72rem;
    color: #aaa;
}
.sg-photo-controls { display: flex; flex-direction: column; gap: 8px; }
.sg-btn-photo {
    display: inline-block;
    padding: 8px 14px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: .82rem;
    cursor: pointer;
    color: #444;
}
.sg-btn-photo-clear {
    padding: 8px 14px;
    background: none;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: .82rem;
    cursor: pointer;
    color: #888;
}

.sg-add-mourner-btn {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: none;
    border: 1.5px dashed #ccc;
    border-radius: 8px;
    font-size: .84rem;
    color: #777;
    cursor: pointer;
}
.sg-mourner-extra-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.sg-mourner-extra-row input {
    flex: 1;
    min-width: 80px;
    padding: 8px 10px;
    border: 1.5px solid #E0E0E0;
    border-radius: 8px;
    font-size: .85rem;
}
.sg-mourner-extra-row button {
    padding: 8px 12px;
    background: #fff0f0;
    border: 1.5px solid #fcc;
    border-radius: 8px;
    font-size: .8rem;
    color: #e74c3c;
    cursor: pointer;
}

.sg-form-error {
    padding: 12px 16px;
    background: #fff0f0;
    border: 1px solid #fcc;
    border-radius: 8px;
    color: #c0392b;
    font-size: .88rem;
    margin: 12px 0;
}

.sg-form-actions { display: flex; gap: 10px; margin-top: 16px; }
.sg-btn-preview-mobile {
    display: none;
    flex: 0 0 100px;
    padding: 14px;
    background: #f0f0f0;
    border: none;
    border-radius: 10px;
    font-size: .9rem;
    cursor: pointer;
    color: #444;
}
.sg-btn-submit {
    flex: 1;
    padding: 14px;
    background: var(--sg-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .02em;
}
.sg-btn-submit:disabled { opacity: .6; cursor: not-allowed; }

/* 모바일 */
@media (max-width: 768px) {
    .sg-create-page { flex-direction: column; gap: 0; padding: 0 0 60px; }
    .sg-create-preview { display: none; }
    .sg-create-form { width: 100%; }
    .sg-form-section { border-radius: 0; margin-bottom: 8px; }
    .sg-form-header { padding: 20px 16px 0; }
    .sg-form-actions { padding: 0 16px; }
    .sg-btn-preview-mobile { display: block; }
    .sg-preview-mobile-btn { display: block; }
}

/* 인쇄 */
@media print {
    .sg-bottom-bar,
    .sg-share-sheet,
    .sg-nav-btn,
    .sg-findway-btn { display: none !important; }
    .sg-wrap { padding-bottom: 0; }
}
