:root {
  --bg: #212121;
  --bg-soft: #171717;
  --panel: #1f1f1f;
  --panel-strong: #181818;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #ececec;
  --muted: #a9a9a9;
  --muted-strong: #c7c7c7;
  --accent: #10a37f;
  --accent-soft: rgba(16, 163, 127, 0.18);
  --user: #2f2f2f;
  --bot: #212121;
  --danger: #dc6f6f;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Noto Sans KR", "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

.sidebar-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
}

.brand-block,
.sidebar-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
}

.brand-block {
  padding: 18px;
}

.brand-kicker,
.header-kicker,
.welcome-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.brand-block h1,
.chat-header h2,
.welcome-copy h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: 1.35rem;
}

.brand-copy,
.sidebar-copy,
.header-note,
.composer-hint {
  color: var(--muted);
}

.brand-copy {
  margin: 10px 0 0;
  line-height: 1.55;
}

.sidebar-primary,
.send-btn {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.sidebar-primary {
  padding: 14px 16px;
}

.sidebar-primary:hover,
.send-btn:hover,
.suggestion-chip:hover {
  transform: translateY(-1px);
}

.sidebar-card {
  padding: 16px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.status-pill,
.history-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  padding: 12px;
  border-radius: 14px;
  background: #232323;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 6px;
}

.metric-card strong {
  font-size: 1rem;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-ghost {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: #242424;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.sidebar-ghost:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: #2a2a2a;
}

.history-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
}

.history-item {
  padding: 12px;
  border-radius: 14px;
  background: #232323;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-question,
.history-answer {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.92rem;
}

.history-question {
  color: var(--muted-strong);
  margin-bottom: 8px;
}

.history-answer {
  color: var(--muted);
}

.chat-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.04), transparent 28%),
    linear-gradient(180deg, #212121 0%, #1d1d1d 100%);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px 14px;
}

.chat-header h2 {
  font-size: 1.6rem;
}

.header-note {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
}

.welcome-panel {
  margin: 0 auto;
  width: min(860px, calc(100% - 40px));
  padding: 24px 0 16px;
}

.welcome-copy h3 {
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.22;
  max-width: 18ch;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.suggestion-chip {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: #242424;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.suggestion-chip:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: #2b2b2b;
}

.chat-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 168px;
}

.bubble {
  width: min(860px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
}

.bubble + .bubble {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bubble-meta {
  margin-bottom: 10px;
}

.bubble-role {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-strong);
  font-weight: 700;
  font-size: 0.92rem;
}

.bubble-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 1rem;
}

.bubble-user .bubble-text {
  color: #ffffff;
}

.bubble-bot .bubble-text {
  color: #e7e7e7;
}

.composer {
  position: fixed;
  left: 328px;
  right: 28px;
  bottom: 24px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: auto;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: rgba(33, 33, 33, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

#messageInput {
  width: 100%;
  min-height: 32px;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  line-height: 1.6;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.send-btn {
  padding: 10px 18px;
}

.send-btn:disabled,
.sidebar-primary:disabled,
.sidebar-ghost:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hidden,
.sr-only {
  display: none !important;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .sidebar-shell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

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

  .composer {
    position: sticky;
    left: auto;
    right: auto;
    bottom: 0;
    width: min(860px, calc(100% - 20px));
    margin: 0 auto 16px;
  }

  .chat-stream {
    padding-bottom: 24px;
  }
}

@media (max-width: 680px) {
  .chat-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 20px 10px;
  }

  .suggestion-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .bubble,
  .welcome-panel {
    width: calc(100% - 24px);
  }

  .composer {
    width: calc(100% - 24px);
    padding: 14px;
  }
}
