:root {
    --public-chat-viewport-height: 100dvh;
    --public-chat-ink: #172033;
    --public-chat-muted: #697386;
    --public-chat-line: #dce3ee;
    --public-chat-surface: #ffffff;
    --public-chat-canvas: #f3f6fb;
    --public-chat-accent: #e96d24;
    --public-chat-accent-dark: #c84e12;
}

* { box-sizing: border-box; }

html, .public-chat-body { margin: 0; min-height: 100%; background: var(--public-chat-canvas); }

.public-chat-body {
    overflow: hidden;
    color: var(--public-chat-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
    overscroll-behavior-y: none;
}

.public-chat-app {
    display: grid;
    width: 100%;
    height: 100vh;
    height: 100svh;
    height: var(--public-chat-viewport-height);
    min-height: 320px;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    background: var(--public-chat-canvas);
}

.public-chat-header {
    display: flex;
    min-height: 60px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
    border-bottom: 1px solid rgba(220, 227, 238, .9);
    background: rgba(255,255,255,.94);
}

.public-chat-brand { color: var(--public-chat-ink); font-size: 18px; font-weight: 900; letter-spacing: -.04em; text-decoration: none; }
.public-chat-brand:focus-visible, .public-chat-composer button:focus-visible, .public-chat-input-wrap:focus-within { outline: 3px solid rgba(233,109,36,.28); outline-offset: 2px; }

.public-chat-status { display: grid; min-width: 0; gap: 2px; text-align: right; }
.public-chat-status strong { color: #263149; font-size: 13px; }
.public-chat-status span { color: var(--public-chat-muted); font-size: 11px; white-space: nowrap; }

.public-chat-panel {
    display: grid;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    background: var(--public-chat-surface);
}

.public-chat-panel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 18px max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left));
    border-bottom: 1px solid #eef1f6;
}

.public-chat-panel-head p { max-width: 180px; margin: 0; color: var(--public-chat-muted); font-size: 12px; line-height: 1.45; text-align: right; }
.public-chat-eyebrow { margin: 0 0 3px; color: var(--public-chat-accent-dark); font-size: 12px; font-weight: 800; }
.public-chat-panel-head h1 { margin: 0; font-size: 21px; letter-spacing: -.04em; }

.public-chat-messages {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px max(18px, env(safe-area-inset-right)) 24px max(18px, env(safe-area-inset-left));
    background: linear-gradient(180deg, #f8fafd 0%, #f2f5fa 100%);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.public-chat-welcome {
    display: grid;
    max-width: 480px;
    gap: 7px;
    margin: 18px auto;
    padding: 20px;
    border: 1px solid #e2e8f1;
    border-radius: 18px;
    background: rgba(255,255,255,.86);
    color: #4d5b70;
    box-shadow: 0 7px 24px rgba(32,48,77,.06);
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
}

.public-chat-welcome strong { color: #263149; font-size: 16px; }

.public-chat-message {
    display: grid;
    width: min(82%, 620px);
    margin: 0 0 16px;
    gap: 4px;
}

.public-chat-message.is-user { justify-self: end; margin-left: auto; }
.public-chat-message.is-office { justify-self: start; margin-right: auto; }
.public-chat-message-label { color: var(--public-chat-muted); font-size: 11px; font-weight: 800; }
.public-chat-message.is-user .public-chat-message-label, .public-chat-message.is-user .public-chat-message-meta { text-align: right; }

.public-chat-message-bubble {
    margin: 0;
    padding: 11px 13px;
    border: 1px solid #e1e7ef;
    border-radius: 16px 16px 16px 5px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(32,48,77,.05);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.public-chat-message.is-user .public-chat-message-bubble {
    border-color: var(--public-chat-accent);
    border-radius: 16px 16px 5px 16px;
    background: linear-gradient(135deg, #f47b34, var(--public-chat-accent-dark));
    color: #fff;
    box-shadow: 0 5px 16px rgba(200,78,18,.18);
}

.public-chat-message-meta { color: #8a95a6; font-size: 10px; }
.public-chat-message.is-user .public-chat-message-meta { color: #b27f65; }

.public-chat-composer {
    padding: 9px max(12px, env(safe-area-inset-right)) calc(11px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid var(--public-chat-line);
    background: rgba(255,255,255,.98);
    box-shadow: 0 -7px 22px rgba(32,48,77,.06);
}

.public-chat-form-status { min-height: 0; margin: 0 5px 5px; color: #18733b; font-size: 11px; font-weight: 700; }
.public-chat-form-status:empty { display: none; }
.public-chat-form-status.is-error { color: #bd2727; }

.public-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 7px 7px 7px 12px;
    border: 1px solid #cad4e2;
    border-radius: 19px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.public-chat-input-wrap:focus-within { border-color: var(--public-chat-accent); box-shadow: 0 0 0 3px rgba(233,109,36,.14); }
.public-chat-input-wrap textarea {
    display: block;
    width: 100%;
    min-height: 46px;
    max-height: 120px;
    margin: 0;
    padding: 11px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--public-chat-ink);
    font: inherit;
    font-size: 16px;
    line-height: 1.45;
    resize: none;
}

.public-chat-input-wrap textarea::placeholder { color: #9aa6b7; }
.public-chat-composer button {
    flex: 0 0 auto;
    min-width: 58px;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 13px;
    background: var(--public-chat-accent-dark);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.public-chat-composer button:disabled { opacity: .55; cursor: wait; }
.public-chat-notice { margin: 7px 5px 0; color: #8a95a6; font-size: 10px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 700px) {
    .public-chat-app { max-width: 900px; margin: 0 auto; border-right: 1px solid var(--public-chat-line); border-left: 1px solid var(--public-chat-line); }
    .public-chat-panel-head { padding-right: 28px; padding-left: 28px; }
    .public-chat-messages { padding-right: 28px; padding-left: 28px; }
    .public-chat-composer { padding-right: 22px; padding-left: 22px; }
}

@media (max-width: 420px) {
    .public-chat-status span { display: none; }
    .public-chat-panel-head p { max-width: 130px; font-size: 11px; }
    .public-chat-message { width: min(88%, 620px); }
}

@media (prefers-reduced-motion: reduce) {
    .public-chat-messages { scroll-behavior: auto; }
    .public-chat-input-wrap { transition: none; }
}
