:root {
    --support-dialog-viewport-height: 100dvh;
}

[data-support-open] {
    position: relative;
}

.support-unread-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    display: inline-flex;
    min-width: 19px;
    height: 19px;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    box-sizing: border-box;
}

.support-unread-badge[hidden] { display: none; }

body.support-dialog-open { overflow: hidden; }

.support-dialog[hidden] { display: none; }

.support-dialog {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: grid;
    place-items: center;
    padding: 20px;
    font-family: inherit;
}

.support-dialog-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(15, 23, 42, .62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.support-dialog-card {
    position: relative;
    display: flex;
    width: min(700px, 100%);
    max-height: min(860px, calc(100vh - 40px));
    height: min(800px, calc(100vh - 40px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 30px 90px rgba(15, 23, 42, .34), 0 3px 12px rgba(15, 23, 42, .12);
    animation: support-dialog-in .2s ease-out both;
}

.support-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid #fed7aa;
    background: linear-gradient(135deg, #fff7ed 0%, #fff 60%, #fffbeb 100%);
}

.support-dialog-head h2 { margin: 0; color: #111827; font-size: 24px; letter-spacing: -.035em; }
.support-dialog-head p { margin: 6px 0 0; color: #6b7280; font-size: 13px; line-height: 1.5; }
.support-dialog-close { min-width: 42px; min-height: 38px; padding: 0 12px; border: 1px solid #fed7aa; border-radius: 999px; background: rgba(255,255,255,.86); color: #9a3412; font-weight: 900; cursor: pointer; box-shadow: 0 1px 3px rgba(124,45,18,.08); }
.support-dialog-close:hover { background: #fff7ed; border-color: #fb923c; }
.support-dialog-close:focus-visible { outline: 3px solid rgba(249,115,22,.25); outline-offset: 2px; }

.support-conversation {
    flex: 1 1 auto;
    min-height: 240px;
    max-height: none;
    overflow: auto;
    padding: 20px 24px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    overscroll-behavior: contain;
}

.support-empty { margin: 18px 0; padding: 28px 16px; border: 1px dashed #cbd5e1; border-radius: 16px; background: rgba(255,255,255,.68); color: #64748b; text-align: center; font-size: 13px; }
.support-empty::before { content: ""; display: block; width: 34px; height: 24px; margin: 0 auto 12px; border: 2px solid #fb923c; border-radius: 12px; background: #fff7ed; box-shadow: 8px 7px 0 -4px #fed7aa; }
.support-message-row { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 14px; }
.support-message-row.is-user { justify-content: flex-end; }
.support-message-row::before, .support-message-row.is-user::after { display: inline-flex; flex: 0 0 30px; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 50%; font-size: 10px; font-weight: 900; }
.support-message-row.is-office::before { content: "LS"; background: #fff; color: #ea580c; box-shadow: 0 2px 8px rgba(15,23,42,.1); }
.support-message-row.is-user::before { display: none; }
.support-message-row.is-user::after { content: "나"; background: #ffedd5; color: #9a3412; }
.support-message-bubble { max-width: 82%; min-width: 0; padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 16px 16px 16px 5px; background: #fff; color: #1f2937; box-shadow: 0 4px 14px rgba(15,23,42,.06); }
.support-message-row.is-user .support-message-bubble { border-color: #ea580c; border-radius: 16px 16px 5px 16px; background: linear-gradient(135deg, #f97316, #ea580c); color: #fff; box-shadow: 0 7px 18px rgba(234,88,12,.18); }
.support-message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; line-height: 1.5; }
.support-message-meta { display: block; margin-top: 6px; color: #64748b; font-size: 11px; }
.support-message-row.is-user .support-message-meta { color: rgba(255,255,255,.78); }
.support-attachment-list { margin: 8px 0 0; padding: 0; list-style: none; }
.support-attachment-list a { display: block; max-width: 100%; overflow-wrap: anywhere; color: inherit; font-size: 12px; text-decoration: underline; }

.support-form { flex: 0 0 auto; padding: 10px 16px 14px; border-top: 1px solid #e5e7eb; background: #fff; box-shadow: 0 -8px 24px rgba(15,23,42,.05); }
.support-field { display: block; margin: 0; }
.support-field > span, .support-channel legend { display: block; margin-bottom: 8px; color: #374151; font-size: 13px; font-weight: 900; letter-spacing: -.01em; }
.support-field small { color: #6b7280; font-weight: 500; }
.support-field textarea, .support-field input[type="email"], .support-field input[type="tel"] { width: 100%; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 13px; background: #fbfdff; color: #111827; font: inherit; box-sizing: border-box; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
.support-body-field { position: relative; }
.support-body-field > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.support-body-field textarea { min-height: 56px; max-height: 120px; padding: 7px 8px; resize: vertical; border: 0; border-radius: 0; background: transparent; line-height: 1.5; box-shadow: none; }
.support-field textarea:focus, .support-field input:focus { outline: 3px solid rgba(234,88,12,.18); border-color: #ea580c; }
.support-field input:focus { background: #fff; box-shadow: 0 5px 15px rgba(234,88,12,.07); }
.support-body-field textarea:focus { outline: 0; box-shadow: none; }
.support-composer { padding: 6px 8px 7px; border: 1px solid #cbd5e1; border-radius: 18px; background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.05); transition: border-color .15s ease, box-shadow .15s ease; }
.support-composer:focus-within { border-color: #ea580c; box-shadow: 0 0 0 3px rgba(234,88,12,.13), 0 5px 15px rgba(234,88,12,.07); }
.support-file-button { display: inline-flex; min-height: 34px; align-items: center; padding: 0 11px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; color: #475569; cursor: pointer; font-size: 12px; font-weight: 900; transition: background .15s ease, transform .15s ease; }
.support-file-button:hover { background: #f1f5f9; transform: translateY(-1px); }
.support-file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.support-file-list { margin: 1px 0 6px; padding: 6px 10px 5px 26px; border-radius: 9px; background: #f8fafc; color: #4b5563; font-size: 12px; }
.support-file-list:empty { display: none; }
.support-file-list li { overflow-wrap: anywhere; }
.support-channel { margin: 0 0 8px; padding: 0; border: 0; }
.support-channel > legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.support-channel-line { display: flex; align-items: center; gap: 10px; }
.support-channel-label { flex: 0 0 auto; color: #64748b; font-size: 12px; font-weight: 900; }
.support-channel-options { display: flex; flex-wrap: wrap; gap: 5px; }
.support-channel-options label { display: inline-flex; min-height: 30px; align-items: center; justify-content: center; gap: 5px; padding: 0 9px; border: 1px solid #e2e8f0; border-radius: 999px; background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 800; cursor: pointer; transition: all .15s ease; }
.support-channel-options label:has(input:checked) { border-color: #fb923c; background: #fff7ed; color: #9a3412; box-shadow: 0 0 0 2px rgba(251,146,60,.12); }
.support-channel-options input { width: 12px; height: 12px; margin: 0; accent-color: #ea580c; }
.support-channel-detail { margin-top: 7px; }
.support-channel-detail > span { margin-bottom: 5px; font-size: 12px; }
.support-channel-detail input[type="email"], .support-channel-detail input[type="tel"] { min-height: 38px; padding: 8px 11px; }
.support-form-message { margin: 0 0 7px; padding: 7px 9px; border-radius: 9px; background: #f0fdf4; color: #166534; font-size: 12px; font-weight: 700; }
.support-form-message:empty { display: none; }
.support-form-message.is-error { color: #b91c1c; }
.support-form-message.is-error { background: #fef2f2; }
.support-actions { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.support-file-hint { flex: 1 1 auto; min-width: 0; color: #94a3b8; font-size: 11px; overflow-wrap: anywhere; }
.support-actions .button { min-width: 76px; min-height: 36px; padding: 0 16px; border-radius: 10px; font-weight: 900; }
.support-actions .primary { border-color: #ea580c; background: linear-gradient(135deg, #f97316, #ea580c); box-shadow: 0 8px 18px rgba(234,88,12,.2); }
.support-actions .primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(234,88,12,.26); }
.support-form.is-submitting { opacity: .72; }

@keyframes support-dialog-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
    .support-dialog {
        inset: 0 auto auto 0;
        width: 100%;
        height: var(--support-dialog-viewport-height);
        min-height: 320px;
        padding: 0;
        place-items: end stretch;
    }
    .support-dialog-card {
        width: 100%;
        height: 94%;
        max-height: 94%;
        border-width: 1px 0 0;
        border-radius: 22px 22px 0 0;
    }
    .support-dialog-head { padding-left: 16px; padding-right: 16px; }
    .support-form { padding: 9px 10px calc(10px + env(safe-area-inset-bottom)); }
    .support-conversation { min-height: 180px; padding-left: 14px; padding-right: 14px; }
    .support-channel-line { gap: 7px; }
    .support-channel-options { flex-wrap: nowrap; gap: 4px; }
    .support-channel-options label { min-height: 29px; padding: 0 7px; font-size: 11px; }
    .support-file-hint { font-size: 10px; }

    .support-dialog.is-keyboard-open .support-dialog-card {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .support-dialog.is-keyboard-open .support-dialog-head {
        min-height: 52px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .support-dialog.is-keyboard-open .support-dialog-head p,
    .support-dialog.is-keyboard-open .support-channel,
    .support-dialog.is-keyboard-open .support-file-list,
    .support-dialog.is-keyboard-open .support-file-button,
    .support-dialog.is-keyboard-open .support-file-hint {
        display: none;
    }
    .support-dialog.is-keyboard-open .support-conversation {
        min-height: 0;
    }
    .support-dialog.is-keyboard-open .support-form {
        padding-top: 7px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    .support-dialog.is-keyboard-open .support-body-field textarea {
        min-height: 44px;
        max-height: 82px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .support-dialog-card { animation: none; }
    .support-file-button, .support-actions .primary { transition: none; }
}
