:root {
  color: #172033;
  background: #eef2f7;
  font-family: "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
}

button,
textarea {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.consent-layer {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 31, 49, 0.62);
}

.consent-card {
  width: min(100%, 560px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 30px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(6, 18, 37, 0.3);
}

.consent-badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  color: #145fbd;
  background: #e8f2ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.consent-card h2 {
  margin: 14px 0 12px;
  font-size: 24px;
}

.consent-card > p {
  margin: 0;
  color: #59677c;
  line-height: 1.65;
  font-size: 14px;
}

.consent-terms {
  margin: 20px 0;
  padding: 17px 18px 17px 36px;
  border: 1px solid #dce5f0;
  border-radius: 12px;
  color: #35445a;
  background: #f8fafc;
  line-height: 1.6;
  font-size: 13px;
}

.consent-terms li + li {
  margin-top: 8px;
}

.consent-confirm {
  color: #26364e !important;
  font-weight: 600;
}

.consent-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

.consent-button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

.consent-button.secondary {
  color: #4c5b70;
  background: #e9edf3;
}

.consent-button.primary {
  color: #fff;
  background: #1868d5;
}

.consent-close-guide {
  margin-top: 16px !important;
  color: #a12828 !important;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 980px);
  height: 100%;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 28px rgba(26, 41, 67, 0.1);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #dfe5ed;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
}

.app-header p {
  margin: 6px 0 0;
  color: #637086;
  font-size: 13px;
}

.connection-state {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  color: #526078;
  background: #edf1f6;
  font-size: 12px;
}

.connection-state.ready {
  color: #12663c;
  background: #e1f5e9;
}

.connection-state.error {
  color: #a12828;
  background: #fde8e8;
}

.messages {
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  margin: 0 0 18px;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(78%, 720px);
  padding: 13px 15px;
  border-radius: 14px;
  background: #f0f3f8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
  font-size: 14px;
}

.message.user .bubble {
  color: #fff;
  background: #1868d5;
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  border-bottom-left-radius: 4px;
}

.message.pending .bubble {
  color: #526176;
  background: #eef3f9;
}

.message.pending .bubble::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #4387df;
  content: "";
  animation: working-pulse 1.2s ease-in-out infinite;
}

@keyframes working-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.message.error .bubble {
  color: #8e2020;
  background: #fff0f0;
}

.bubble a {
  color: #075bbb;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.composer {
  padding: 14px 18px 18px;
  border-top: 1px solid #dfe5ed;
  background: #fff;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 180px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid #bdc8d8;
  border-radius: 10px;
  outline: none;
  line-height: 1.5;
}

.composer textarea:focus {
  border-color: #1868d5;
  box-shadow: 0 0 0 3px rgba(24, 104, 213, 0.12);
}

.composer textarea:disabled {
  color: #8994a6;
  background: #f4f6f9;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
}

#promptCount {
  color: #78859a;
  font-size: 12px;
}

#sendButton {
  min-width: 92px;
  padding: 10px 18px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: #1868d5;
  cursor: pointer;
}

#sendButton:disabled {
  background: #aeb8c7;
  cursor: default;
}

.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 (max-width: 640px) {
  .consent-layer {
    padding: 14px;
  }

  .consent-card {
    max-height: calc(100vh - 28px);
    padding: 22px 18px;
    border-radius: 14px;
  }

  .app-header,
  .messages {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app-header p {
    display: none;
  }

  .bubble {
    max-width: 90%;
  }
}
