:root {
  color-scheme: light;
  font-family: "DM Sans", "Noto Sans KR", sans-serif;
  color: #25263a;
  background: #f7f8fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ink: #25263a;
  --muted: #858796;
  --line: #e9eaf0;
  --accent: #6658d9;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; min-height: 100vh; }
button, textarea { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 72px;
  padding: 0 40px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: 0;
  background: transparent;
}
.brand { justify-self: start; display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.brand-name { font-weight: 700; letter-spacing: -.055em; font-size: 18px; }
.brand-small { color: var(--accent); font-size: .7em; font-weight: 700; vertical-align: middle; }
.new-chat-button { justify-self: end; display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border: 1px solid #e5e6ec; border-radius: 11px; background: #fff; color: #5d5e6e; font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.new-chat-button:hover { border-color: #c9c5f0; background: #fbfaff; transform: translateY(-1px); }
.new-chat-button svg { width: 16px; height: 16px; }

.main-area { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.conversation { position: relative; flex: 1; min-height: 0; width: 100%; max-width: 920px; margin: 0 auto; padding: 0 44px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #d9d9e2 transparent; }
.welcome { min-height: calc(100vh - 245px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 0 30px; text-align: center; }
.welcome[hidden] { display: none; }
.welcome h1 { margin: 0; color: #28293d; font-size: clamp(27px, 4vw, 35px); line-height: 1.35; letter-spacing: -.055em; font-weight: 600; }
.welcome h1 span { color: #827d9e; font-weight: 500; }
.main-area:not(.chat-started) .conversation { position: static; flex: 0 0 0; height: 0; min-height: 0; padding: 0; overflow: visible; }
.main-area:not(.chat-started) .welcome { position: absolute; top: calc(50% - 145px); right: 0; left: 0; min-height: 0; padding: 0; }
.main-area:not(.chat-started) .composer-area { position: absolute; top: calc(50% - 36px); right: 0; left: 0; transform: translateY(-50%); padding: 12px 24px 17px; background: transparent; }

.messages { display: none; padding: 35px 0 20px; }
.messages.active { display: block; }
.message-row { display: flex; gap: 12px; width: 100%; margin: 0 0 25px; animation: arrive .2s ease-out; }
.message-row.user { justify-content: flex-end; }
.message-avatar { flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #e7e5f7; border-radius: 10px; color: #6255cf; background: #f0eeff; }
.message-avatar svg { width: 19px; height: 19px; }
.message-body { min-width: 0; max-width: min(680px, calc(100% - 46px)); padding: 3px 0; }
.user .message-body { max-width: min(620px, 84%); padding: 12px 16px; border: 1px solid #e9e7f7; border-radius: 17px 17px 5px 17px; background: #f0eff8; color: #38394d; }
.assistant .message-body { flex: 1; }
.message-label { margin: 0 0 6px; color: #696b7b; font-size: 11px; font-weight: 700; }
.message-content { color: #393a4b; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.message-content p { margin: 0 0 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 5px 0 12px; padding-left: 23px; }
.message-content li { padding: 2px 0; }
.message-content h1, .message-content h2, .message-content h3 { margin: 13px 0 7px; color: #2d2e40; font-size: 15px; }
.message-content h1:first-child, .message-content h2:first-child, .message-content h3:first-child { margin-top: 0; }
.message-content code { padding: 2px 5px; border-radius: 5px; color: #6c4a8c; background: #f1eef5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .91em; }
.message-content pre { overflow-x: auto; margin: 10px 0; padding: 12px 14px; border: 1px solid #e9eaf0; border-radius: 10px; background: #fff; }
.message-content pre code { padding: 0; color: #444556; background: transparent; }
.sources { margin-top: 13px; padding-top: 10px; border-top: 1px solid #eeeff3; }
.sources-title { margin: 0 0 8px; color: #828392; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.source-list { display: flex; flex-wrap: wrap; gap: 7px; }
.source-link { max-width: 100%; display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; overflow: hidden; border: 1px solid #eaebef; border-radius: 9px; color: #606273; background: #fff; font-size: 11px; text-decoration: none; transition: border-color .15s, color .15s; }
.source-link:hover { border-color: #cfcaf2; color: #5c50c6; }
.source-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-link .source-number { flex: 0 0 auto; color: #6a5ed2; font-size: 10px; font-weight: 700; }
.source-favicon { width: 14px; height: 14px; flex: 0 0 14px; border-radius: 3px; object-fit: contain; }
.external-icon { color: #9c9dac; font-size: 10px; }
.thinking { display: inline-flex; align-items: center; gap: 5px; height: 19px; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: #9891dc; animation: pulse 1s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
.inline-error { margin-top: 8px; padding: 9px 11px; border: 1px solid #f1d3d4; border-radius: 9px; color: #ad5055; background: #fff8f8; font-size: 12px; line-height: 1.6; }

.composer-area { width: 100%; padding: 12px 24px 17px; background: linear-gradient(180deg, rgba(247, 248, 250, .32), #f7f8fa 26%); }
.composer { width: min(100%, 760px); margin: 0 auto; padding: 12px 13px 10px 18px; border: 1px solid #e4e5eb; border-radius: 19px; background: #fff; box-shadow: 0 7px 28px rgba(32, 34, 55, .065), 0 1px 2px rgba(32, 34, 55, .03); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #c9c3f0; box-shadow: 0 8px 30px rgba(63, 55, 135, .09), 0 1px 2px rgba(32, 34, 55, .03); }
.composer textarea { display: block; width: 100%; min-height: 29px; max-height: 170px; padding: 3px 2px 7px; resize: none; border: 0; outline: 0; color: #323346; background: transparent; font-size: 14px; line-height: 1.6; }
.composer textarea::placeholder { color: #aaaab5; }
.composer-bottom { display: flex; align-items: center; justify-content: flex-end; min-height: 30px; }
.send-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 11px; color: #fff; background: #6658d9; cursor: pointer; transition: opacity .15s, transform .15s, background .15s; }
.send-button:hover:not(:disabled) { transform: translateY(-1px); background: #594acb; }
.send-button:disabled { color: #aeb0bd; background: #ececf1; cursor: default; }
.send-button svg { width: 18px; height: 18px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes arrive { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 640px) {
  .topbar { height: 62px; padding: 0 16px; grid-template-columns: 1fr 1fr; }
  .brand-name { font-size: 17px; }
  .conversation { padding: 0 18px; }
  .welcome { min-height: calc(100vh - 216px); padding: 32px 0 22px; }
  .welcome h1 { font-size: 27px; }
  .welcome h1 span { display: block; }
  .main-area:not(.chat-started) .welcome { top: calc(50% - 145px); padding: 0; }
  .main-area:not(.chat-started) .composer-area { padding: 9px 12px 12px; }
  .message-row { gap: 9px; margin-bottom: 21px; }
  .message-avatar { flex-basis: 28px; width: 28px; height: 28px; }
  .message-body { max-width: calc(100% - 37px); }
  .user .message-body { max-width: 87%; }
  .message-content { font-size: 13px; }
  .composer-area { padding: 9px 12px 12px; }
  .composer { padding: 10px 10px 8px 14px; border-radius: 16px; }
  .composer textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
