:root {
  --ink: #17231f;
  --muted: #65736d;
  --line: rgba(23, 35, 31, 0.12);
  --surface: rgba(255, 255, 255, 0.84);
  --mint: #3ee8bf;
  --lime: #b8ff5f;
  --blue: #4aa8ff;
  --coral: #ff775c;
  --shadow: 0 18px 55px rgba(22, 47, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(62, 232, 191, 0.28), transparent 34rem),
    radial-gradient(circle at 82% 0%, rgba(74, 168, 255, 0.2), transparent 32rem),
    linear-gradient(135deg, #f8fff5 0%, #f7fbff 46%, #fff8f2 100%);
}

button,
textarea,
a {
  font: inherit;
}

.shell {
  width: min(1420px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.profile,
.chat-card,
.sources {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.profile {
  border-radius: 28px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: calc(100vh - 68px);
  overflow-y: auto;
}

.identity {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.identity img {
  width: 92px;
  height: 92px;
  aspect-ratio: 1;
  align-self: center;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 28%;
  display: block;
  border: 3px solid var(--mint);
  box-shadow: 0 10px 28px rgba(62, 232, 191, 0.25);
}

.eyebrow {
  margin: 0 0 8px;
  color: #008978;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 38px;
  line-height: 1.06;
}

h2 {
  font-size: 22px;
}

.intro {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.links a,
.question-group button,
.composer button {
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.links a {
  padding: 11px 13px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.links a:hover,
.links a:focus-visible {
  border-color: rgba(0, 137, 120, 0.45);
  background: rgba(62, 232, 191, 0.14);
  outline: none;
}

.cache-note {
  margin: 0;
  padding-left: 11px;
  border-left: 3px solid #00a990;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.cache-note strong {
  color: var(--ink);
  font-weight: 900;
}

.question-menu {
  display: grid;
  gap: 8px;
}

.question-group {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.question-group summary {
  position: relative;
  padding: 10px 28px 10px 2px;
  color: #008978;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  cursor: pointer;
  list-style: none;
}

.question-group summary::-webkit-details-marker {
  display: none;
}

.question-group summary::after {
  position: absolute;
  right: 3px;
  top: 8px;
  content: "+";
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.question-group[open] summary::after {
  content: "−";
}

.question-group button {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 11px 13px;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  font-weight: 850;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.question-group button:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 137, 120, 0.45);
  background: rgba(184, 255, 95, 0.32);
}

.question-group button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.question-group.featured {
  padding: 8px 10px 14px;
  border: 1px solid rgba(0, 137, 120, 0.18);
  border-radius: 8px;
  background: rgba(62, 232, 191, 0.08);
}

.question-group button:focus-visible {
  border-color: rgba(0, 137, 120, 0.35);
  background: rgba(184, 255, 95, 0.28);
  outline: 2px solid rgba(0, 137, 120, 0.2);
  outline-offset: 2px;
}

.notice {
  margin: auto 0 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 119, 92, 0.34);
  background: rgba(255, 119, 92, 0.09);
  color: #684037;
  font-size: 12px;
  line-height: 1.6;
}

.chat-card {
  min-height: calc(100vh - 68px);
  border-radius: 30px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chat-head,
.source-head {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.status {
  min-width: 74px;
  padding: 8px 11px;
  border-radius: 999px;
  color: #006e63;
  background: rgba(62, 232, 191, 0.18);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.status.error {
  color: #9b2c1b;
  background: rgba(255, 119, 92, 0.15);
}

.messages {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.message {
  width: min(720px, 92%);
  border-radius: 20px;
  padding: 16px 18px;
  line-height: 1.7;
  font-size: 15px;
  border: 1px solid var(--line);
}

.message p {
  margin: 0;
  white-space: pre-wrap;
}

.message.assistant {
  background: rgba(255, 255, 255, 0.86);
}

.message.user {
  align-self: flex-end;
  border-color: rgba(74, 168, 255, 0.28);
  background: linear-gradient(135deg, rgba(74, 168, 255, 0.2), rgba(62, 232, 191, 0.18));
}

.message.loading {
  color: var(--muted);
}

.composer {
  padding: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  background: rgba(255, 255, 255, 0.55);
}

.composer textarea {
  width: 100%;
  max-height: 150px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 15px 16px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  outline: none;
  line-height: 1.5;
}

.composer textarea:focus {
  border-color: rgba(0, 137, 120, 0.48);
}

.composer button {
  height: 52px;
  padding: 0 22px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.sources {
  border-radius: 28px;
  overflow: hidden;
}

.sources .source-head {
  display: block;
}

.source-list {
  padding: 18px;
  display: grid;
  gap: 12px;
}

@media (min-width: 1121px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    min-height: 0;
  }

  .shell {
    height: 100dvh;
    min-height: 0;
  }

  .profile,
  .chat-card,
  .sources {
    height: 100%;
    min-height: 0;
  }

  .profile {
    max-height: none;
  }

  .messages {
    min-height: 0;
    overscroll-behavior: contain;
  }

  .sources {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .source-list {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.source {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.source strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.source span {
  color: #008978;
  font-size: 12px;
  font-weight: 800;
}

.source p,
.empty {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .sources {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 24px, 680px);
    grid-template-columns: 1fr;
    padding: 12px 0;
  }

  .profile,
  .chat-card,
  .sources {
    border-radius: 22px;
  }

  .profile {
    max-height: none;
  }

  .chat-card {
    min-height: 68vh;
  }

  .identity {
    grid-template-columns: 78px minmax(0, 1fr);
    align-items: center;
  }

  .identity img {
    width: 78px;
    height: 78px;
  }

  h1 {
    font-size: 30px;
  }

  .links {
    grid-template-columns: 1fr 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}
