:root {
  color-scheme: light;
  --ink: #13283a;
  --muted: #647483;
  --line: #dce4e9;
  --canvas: #f3f6f7;
  --surface: #ffffff;
  --navy: #12304a;
  --navy-soft: #eaf1f6;
  --teal: #0f806f;
  --teal-soft: #e8f7f3;
  --amber: #a96614;
  --amber-soft: #fff4df;
  --shadow: 0 10px 28px rgba(18, 48, 74, 0.06);
  font-family: Inter, Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 90% 0%, rgba(85, 151, 163, 0.09), transparent 28rem),
    var(--canvas);
}

button, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.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;
}

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 20px 22px;
  color: #dce8ef;
  background: var(--navy);
  box-shadow: 8px 0 30px rgba(12, 35, 53, 0.08);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  padding: 0;
  color: #fff;
  text-decoration: none;
}

.brand-logo-surface {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 4px 8px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(5, 23, 36, 0.16);
}

.brand-logo-full { display: block; width: 181px; height: 47px; object-fit: contain; }
.brand-logo-small { display: none; width: 48px; height: 47px; object-fit: contain; }

.primary-nav {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 52px;
  -ms-overflow-style: none;
  overflow-y: auto;
  scrollbar-width: none;
}

.primary-nav::-webkit-scrollbar { display: none; }

.nav-label {
  margin: 0 12px 10px;
  color: #94aaba;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.nav-label-spaced { margin-top: 34px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 13px;
  border-radius: 10px;
  color: #bed0dc;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.nav-item + .nav-item { margin-top: 4px; }

.nav-item svg,
.ghost-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.07); transform: translateX(2px); }
.nav-item.is-active { color: #fff; background: rgba(255, 255, 255, 0.12); }
.nav-item.is-active::before { content: ""; position: absolute; left: 0; width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: #6bd0c0; }

.sidebar-foot {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.privacy-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #c9fff5;
  background: rgba(65, 187, 166, 0.2);
  font-size: 12px;
  font-weight: 900;
}

.sidebar-foot p { margin: 0; color: #8fa7b7; font-size: 11px; line-height: 1.55; }
.sidebar-foot strong { color: #c5d5df; font-size: 12px; }

.workspace { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 38px;
  border-bottom: 1px solid rgba(211, 222, 228, 0.85);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.breadcrumb { margin: 0; color: #778692; font-size: 13px; }
.breadcrumb span { margin: 0 8px; color: #b0bbc3; }
.mobile-brand { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #526574;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.ghost-button svg { width: 16px; height: 16px; }
.ghost-button:hover { border-color: #9aabb7; color: var(--ink); }

.workspace-content {
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.hero h1 { margin: 0; font-size: clamp(30px, 3.6vw, 40px); letter-spacing: -0.04em; line-height: 1.2; }
.hero-copy { margin: 10px 0 0; color: #566b79; font-size: 15px; font-weight: 500; }

.online-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #cde8df;
  border-radius: 999px;
  color: #3d6d62;
  background: #f3fbf8;
  font-size: 11px;
  font-weight: 750;
}

.online-pill i { width: 7px; height: 7px; border-radius: 50%; background: #27a889; box-shadow: 0 0 0 4px rgba(39, 168, 137, 0.12); }

.assistant-panel {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.conversation {
  display: none;
  flex-direction: column;
  gap: 18px;
  max-height: min(52vh, 560px);
  padding: 3px 3px 18px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.has-conversation .conversation { display: flex; min-height: 220px; }

.message-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #fff;
  background: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.message { display: flex; align-items: flex-start; gap: 11px; }
.message-user { flex-direction: row-reverse; }
.message-user .message-avatar { color: #476170; background: #e7edf1; }

.message-bubble {
  max-width: min(790px, 82%);
  padding: 14px 17px;
  border: 1px solid #e0e7eb;
  border-radius: 5px 16px 16px 16px;
  background: #f8fafb;
  font-size: 14px;
  line-height: 1.72;
}

.message-user .message-bubble {
  border-color: #1d506f;
  border-radius: 16px 5px 16px 16px;
  color: #fff;
  background: #1d506f;
}

.message-content { overflow-wrap: anywhere; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p { margin: 0.65em 0; }
.message-content ul, .message-content ol { margin: 0.6em 0; padding-left: 1.5em; }
.message-content li { margin: 0.25em 0; }
.message-content strong { color: #173f59; font-weight: 800; }
.message-content h1, .message-content h2, .message-content h3 { margin: 1em 0 0.5em; font-size: 16px; }
.message-content blockquote { margin: 0.8em 0; padding: 3px 11px; border-left: 3px solid #9db0bd; color: #586c79; }
.message-content a { color: #17678f; }
.message-plain { margin: 0; white-space: pre-wrap; }

.message-sources {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #dfe6ea;
}

.source-image-results { display: grid; gap: 8px; }

.source-section-title {
  color: #314f61;
  font-size: 12px;
  font-weight: 850;
}

.source-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 9px;
}

.source-image-card {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #ccd8df;
  border-radius: 11px;
  color: #526875;
  background: #fff;
  text-decoration: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.source-image-card img {
  display: block;
  width: 100%;
  height: 112px;
  object-fit: cover;
  background: #edf2f4;
}

.source-image-caption {
  display: grid;
  gap: 2px;
  padding: 7px 9px 8px;
  line-height: 1.35;
}

.source-image-caption strong {
  overflow: hidden;
  color: #29495c;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-image-caption small { color: #718590; font-size: 9px; }

.source-image-card:hover {
  border-color: #8299a8;
  box-shadow: 0 5px 14px rgba(29, 67, 91, 0.1);
  color: var(--ink);
  transform: translateY(-1px);
}

.source-reference-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}

.source-reference-label {
  color: #647985;
  font-size: 10px;
  font-weight: 800;
}

.message-images {
  display: flex;
  gap: 7px;
  margin-bottom: 9px;
  overflow-x: auto;
}

.message-images img {
  width: 112px;
  height: 84px;
  flex: 0 0 auto;
  border-radius: 9px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #ccd8df;
  border-radius: 7px;
  color: #526875;
  background: #fff;
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
}

.source-pill:hover { border-color: #8299a8; color: var(--ink); }

.loading-bubble { display: flex; gap: 5px; min-width: 64px; }
.loading-bubble i { width: 7px; height: 7px; border-radius: 50%; background: #8298a5; animation: bounce 1.1s infinite ease-in-out; }
.loading-bubble i:nth-child(2) { animation-delay: 120ms; }
.loading-bubble i:nth-child(3) { animation-delay: 240ms; }

@keyframes bounce {
  0%, 65%, 100% { transform: translateY(0); opacity: 0.45; }
  32% { transform: translateY(-5px); opacity: 1; }
}

.suggestion-row {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 13px 3px 1px;
  overflow-x: auto;
  scrollbar-width: none;
}
.suggestion-row::-webkit-scrollbar { display: none; }

.suggestion-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #d7e1e6;
  border-radius: 999px;
  color: #4e6573;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.suggestion-chip:hover { border-color: #8fa5b2; color: var(--ink); background: #f8fafb; }

.composer {
  flex: 0 0 auto;
  padding: 16px 17px 14px;
  border: 1px solid #9fb3bf;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 5px 20px rgba(18, 48, 74, 0.06);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer:focus-within { border-color: #25698a; box-shadow: 0 0 0 3px rgba(37, 105, 138, 0.14); }
.composer.is-dragging { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15, 128, 111, 0.16); }

.image-preview-strip {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
  padding: 2px;
  overflow-x: auto;
}

.image-preview {
  position: relative;
  flex: 0 0 auto;
  width: 68px;
  height: 58px;
  margin: 0;
}

.image-preview img {
  width: 100%;
  height: 100%;
  border: 1px solid #cbd8df;
  border-radius: 9px;
  object-fit: cover;
  background: #eef3f5;
}

.image-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  padding: 0 0 2px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: #334e60;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.document-preview-chip {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 148px);
  align-items: center;
  flex: 0 0 auto;
  min-height: 58px;
  padding: 7px 28px 7px 8px;
  border: 1px solid #cbd8df;
  border-radius: 9px;
  color: #37566a;
  background: #f6f9fa;
}

.document-preview-chip strong {
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.document-preview-chip span {
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-preview-remove {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 20px;
  height: 20px;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #566f7e;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.message-document-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.message-document-list span {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-result-card {
  display: grid;
  gap: 10px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid #dbe4e9;
}

.document-result-card > strong {
  color: #264d63;
  font-size: 12px;
  font-weight: 850;
}

.document-preview-details {
  overflow: hidden;
  border: 1px solid #d5e0e5;
  border-radius: 10px;
  background: #fff;
}

.document-preview-details summary {
  padding: 8px 10px;
  color: #426174;
  background: #f5f8f9;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.document-preview-content {
  max-height: 310px;
  padding: 11px 13px;
  overflow: auto;
  font-size: 12px;
}

.document-preview-content > :first-child { margin-top: 0; }
.document-preview-content > :last-child { margin-bottom: 0; }

.document-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.document-result-actions form { margin: 0; }

.document-result-actions a,
.document-result-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #1d607f;
  border-radius: 8px;
  color: #fff;
  background: #1d607f;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.document-result-actions a.is-secondary,
.document-result-actions button.is-secondary {
  color: #27566d;
  background: #fff;
}

.cad-gui-status {
  margin: 6px 0 0;
  color: #5c7382;
  font-size: 11px;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  max-height: 130px;
  padding: 3px 4px;
  resize: none;
  overflow-y: hidden;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
}

.composer textarea::placeholder { color: #718591; opacity: 1; }
.composer textarea:disabled { cursor: wait; opacity: 0.62; }

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 7px;
}

.composer-meta {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.model-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.image-upload-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid #c9d8df;
  border-radius: 8px;
  color: #31576b;
  background: #f7fafb;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.image-upload-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.image-upload-button:hover { border-color: #7d9aa9; background: #eef5f7; }
.image-upload-button:disabled { cursor: wait; opacity: .55; }

.thinking-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid #c9d8df;
  border-radius: 8px;
  color: #476371;
  background: #f7fafb;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  user-select: none;
}

.thinking-control input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #176f80;
}

.thinking-control:has(input:checked) {
  border-color: #16808c;
  color: #0e5b67;
  background: #e7f5f5;
  box-shadow: 0 0 0 2px rgba(22, 128, 140, 0.1);
}

.thinking-control:has(input:disabled) { cursor: wait; opacity: .55; }

.model-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #607581;
  font-size: 10.5px;
  font-weight: 750;
}

.model-field select {
  min-height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid #d3dee4;
  border-radius: 8px;
  color: #29485c;
  background: #f7fafb;
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
}

.model-field select:disabled { cursor: wait; opacity: .6; }

.personality-field select { max-width: 150px; }

#preview-status { color: #627684; font-size: 11.5px; font-weight: 500; }

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--navy);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.send-button svg { width: 17px; height: 17px; }
.send-button:hover { background: #1b4969; transform: translateY(-1px); }
.send-button:disabled { cursor: wait; opacity: 0.6; transform: none; }
.send-button.is-stopping { background: #b84d45; }
.send-button.is-stopping:hover { background: #9f3f38; }

a:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 3px solid #e49b36;
  outline-offset: 3px;
}

@media (min-width: 681px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100vh; min-height: 0; }
  .workspace {
    display: grid;
    grid-template-rows: 72px minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }
  .workspace-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-top: clamp(16px, 2.5vh, 24px);
    padding-bottom: clamp(22px, 4vh, 42px);
    overflow: hidden;
  }
  .hero { flex: 0 0 auto; }
  .has-conversation .assistant-panel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }
  .has-conversation .conversation {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding: 24px 14px 20px; }
  .brand { justify-content: center; padding: 0; }
  .brand-logo-surface { width: 52px; min-height: 52px; padding: 2px; }
  .brand-logo-full { display: none; }
  .brand-logo-small { display: block; width: 45px; height: 44px; }
  .nav-label, .nav-item span, .sidebar-foot p { display: none; }
  .primary-nav { margin-top: 42px; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item.is-active::before { position: absolute; left: 0; margin: 0; }
  .sidebar-foot { justify-content: center; padding: 16px 0 0; }
  .workspace-content { width: min(100% - 44px, 960px); }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 12px 16px;
  }
  .brand-logo-surface { width: 40px; min-height: 40px; border-radius: 10px; }
  .brand-logo-small { width: 36px; height: 35px; }
  .primary-nav {
    display: flex;
    flex: 1 1 auto;
    gap: 4px;
    min-width: 0;
    margin: 0 0 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .nav-item { width: 40px; min-height: 40px; }
  .nav-label, .sidebar-foot { display: none; }
  .nav-item.is-active::before { display: none; }
  .topbar { min-height: 58px; padding: 0 18px; }
  .breadcrumb { display: none; }
  .mobile-brand { display: block; color: #476171; font-size: 11px; font-weight: 850; letter-spacing: 0.12em; }
  .ghost-button span { display: none; }
  .ghost-button { width: 40px; padding: 0; }
  .workspace-content { width: calc(100% - 28px); padding: 20px 0 40px; }
  .hero { display: block; }
  .hero h1 { font-size: 28px; }
  .hero-copy { font-size: 13.5px; line-height: 1.6; }
  .assistant-panel { padding: 14px; border-radius: 15px; }
  .conversation { max-height: 55vh; }
  .has-conversation .conversation { min-height: 190px; }
  .message-avatar { width: 34px; height: 34px; border-radius: 10px; }
  .message { gap: 8px; }
  .message-bubble { max-width: 88%; padding: 12px 14px; font-size: 13px; }
  .composer-bottom { align-items: flex-end; }
  .composer-meta { align-items: flex-start; flex-direction: column; gap: 7px; }
  .model-controls { max-width: 100%; }
  .model-field > span { display: none; }
  .model-field select { max-width: 150px; }
  .personality-field select { max-width: 125px; }
  .image-upload-button span { display: none; }
  .image-upload-button { width: 34px; justify-content: center; padding: 0; }
  #preview-status { max-width: 155px; line-height: 1.4; }
  .send-button span { display: none; }
  .send-button { width: 48px; padding: 0; }
}

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