:root {
  color-scheme: light;
  --chat-ink: #213449;
  --chat-navy: #112c47;
  --chat-muted: #596b7c;
  --chat-line: #dde4eb;
  --chat-gold: #c4a271;
  font: 400 1rem/1.6 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--chat-ink); background: #f0f3f6; }
a { color: inherit; text-underline-offset: 4px; }
button, textarea, input { font: inherit; }
:focus-visible { outline: 2px solid #8a632b; outline-offset: 2px; }

.chat-window {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: #fff;
  overflow: hidden;
  border-top: 3px solid var(--chat-gold);
}

.chat-standalone .chat-window { width: min(100%, 480px); margin-inline: auto; }
.chat-top {
  min-height: 63px;
  display: grid;
  grid-template-columns: minmax(70px, 1fr) auto minmax(70px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--chat-line);
}

.chat-new, .chat-close {
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  text-decoration: none;
  color: var(--chat-navy);
}
.chat-new { justify-self: start; border: 1px solid var(--chat-line); border-radius: 7px; padding: 4px 10px; font-size: .8rem; font-weight: 600; }
.chat-close { justify-self: end; width: 36px; border-radius: 7px; font: 1.65rem/1 system-ui, sans-serif; }
.chat-close:hover, .chat-new:hover { background: #eef3f7; }
.chat-brand, .chat-sender { display: flex; align-items: center; gap: 8px; }
.chat-brand h1 { margin: 0; color: var(--chat-navy); font-size: .96rem; letter-spacing: -.035em; white-space: nowrap; }
.chat-brand > span, .chat-sender > span {
  display: grid;
  place-items: center;
  color: #f7e9d1;
  background: var(--chat-navy);
  border-radius: 7px;
  font: 1rem Georgia, serif;
  width: 29px;
  height: 29px;
  flex: none;
}

.chat-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 16px;
  background: #edf3f7;
  color: #3b5166;
  border-bottom: 1px solid #e0e8ef;
  font-size: .8rem;
  word-break: keep-all;
}
.chat-notice > span {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--chat-navy);
  background: #fff;
  font: 700 .94rem Georgia, serif;
}
.chat-notice strong { color: var(--chat-navy); }
.chat-notice p { margin: 3px 0 0; }
.chat-content { min-height: 0; padding: 15px 17px 22px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.chat-intake { display: grid; gap: 6px; }
.chat-intake h2 { margin: 2px 0 0; color: var(--chat-navy); font-size: 1.25rem; }
.chat-intake > p { margin: 0; color: var(--chat-muted); font-size: .88rem; }
.chat-intake > label { margin-top: 9px; font-size: .88rem; font-weight: 650; }
.chat-intake > input, .chat-intake select { width: 100%; min-height: 43px; padding: 8px 10px; font: inherit; background: white; color: var(--chat-ink); border: 1px solid #acbbc5; border-radius: 7px; }
.chat-intake .chat-privacy { margin: 14px 0 8px; font-size: .81rem; }
.chat-intake > button { min-height: 44px; color: white; background: var(--chat-navy); border: 0; border-radius: 7px; font-weight: 700; cursor: pointer; }
.chat-intake > button:disabled { opacity: .65; }
.chat-date { margin: 6px 0 18px; text-align: center; color: var(--chat-muted); font-size: .77rem; }
.chat-greeting { max-width: 94%; padding: 0 0 8px; }
.chat-sender { color: var(--chat-navy); font-size: .86rem; }
.chat-greeting > p {
  margin: 8px 0 4px;
  padding: 12px 14px;
  color: var(--chat-ink);
  background: #f1f5f8;
  border: 1px solid #e1e8ee;
  border-radius: 3px 12px 12px;
  font-size: .92rem;
  word-break: keep-all;
}
.chat-greeting small { color: var(--chat-muted); font-size: .72rem; }
.chat-thread-links { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 15px; color: var(--chat-muted); font-size: .76rem; }
.chat-log { display: flex; flex-direction: column; gap: 13px; margin-top: 7px; }
.chat-log .support-bubble {
  width: fit-content;
  max-width: 91%;
  padding: 9px 12px;
  border: 1px solid #e0e7ee;
  border-radius: 3px 12px 12px;
  background: #f1f5f8;
}
.chat-log .support-bubble.visitor {
  align-self: flex-end;
  box-shadow: none;
  border-color: #e9dcca;
  border-radius: 12px 3px 12px 12px;
  background: #faf3e8;
}
.chat-log .support-bubble header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 9px; font-size: .76rem; }
.chat-log .support-bubble time { color: var(--chat-muted); font-size: .71rem; }
.chat-log .support-bubble p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.chat-history h2 { margin: 0 0 12px; font-size: 1rem; }
.chat-history p { color: var(--chat-muted); font-size: .88rem; }
.chat-history ul { margin: 0; padding: 0; list-style: none; }
.chat-history li + li { margin-top: 7px; }
.chat-history li a { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--chat-line); border-radius: 8px; text-decoration: none; font-size: .85rem; }
.chat-history li a:hover { background: #eef3f7; }
.chat-history li a span { color: var(--chat-muted); font-size: .76rem; }

.chat-composer { position: relative; padding: 10px 12px max(11px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--chat-line); }
.chat-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: end; padding: 6px; background: #f6f8fa; border: 1px solid #d5dfe8; border-radius: 10px; }
.chat-input-row:focus-within { border-color: #7690a9; }
.chat-input-row textarea { display: block; background: transparent; min-height: 41px; max-height: min(110px, 20dvh); field-sizing: content; resize: none; width: 100%; padding: 9px 4px 7px 8px; border: 0; outline: none; color: var(--chat-ink); font-size: .9rem; scrollbar-width: thin; }
.chat-input-row textarea::placeholder { color: #596b7c; }
.chat-input-row button { display: grid; place-items: center; width: 39px; height: 39px; padding: 0; border: 0; border-radius: 8px; color: #fff; background: var(--chat-navy); font: 700 1.35rem/1 system-ui, sans-serif; cursor: pointer; }
.chat-input-row button:disabled { background: #627489; cursor: default; }
.chat-privacy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 9px; margin: 0 2px 7px; color: var(--chat-muted); font-size: .73rem; }
.chat-privacy label { display: inline-flex; align-items: center; gap: 5px; }
.chat-privacy input { accent-color: var(--chat-navy); margin: 0; }
.chat-privacy summary { cursor: pointer; text-decoration: underline; }
.chat-privacy details[open] { flex-basis: 100%; }
.chat-privacy details p { margin: 6px 0 0; }
.chat-submit-status { color: #8a4027; font-size: .76rem; margin: 6px 0 0; }
.chat-submit-status[data-success="true"] { color: #286047; }
.chat-trap { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }

@media (min-width: 560px) {
  .chat-standalone .chat-window { height: min(850px, calc(100dvh - 32px)); margin-block: 16px; border-radius: 12px; box-shadow: 0 12px 38px #11243a25; }
}
@media (max-width: 340px) {
  .chat-top { grid-template-columns: minmax(63px, 1fr) auto minmax(40px, 1fr); gap: 4px; padding-inline: 10px; }
  .chat-new { padding-inline: 6px; }
  .chat-brand { gap: 5px; }
  .chat-brand h1 { font-size: .86rem; }
}
