:root {
  color-scheme: light;
  --bg: #eef2f7;
  --shell: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f5f7fb;
  --ink: #131720;
  --ink-soft: #2c3442;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #dde4ee;
  --line-strong: #c7d2e1;
  --sidebar: #12151c;
  --sidebar-soft: #1a202b;
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --accent: #0f66d0;
  --accent-strong: #064ea8;
  --accent-cyan: #0ea5c6;
  --accent-soft: #e8f2ff;
  --success: #16a34a;
  --warn: #b76e00;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(19, 23, 32, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  letter-spacing: 0;
}

button,
input,
textarea {
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease,
    opacity 0.16s ease;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(14, 165, 198, 0.28);
  outline-offset: 2px;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

h1,
h2,
p {
  margin: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow-y: auto;
  background:
    linear-gradient(135deg, rgba(15, 102, 208, 0.08), transparent 38%),
    linear-gradient(180deg, #f7f9fc 0%, #e8edf5 100%);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 440px);
  gap: 20px;
  width: min(1160px, 100%);
  min-height: 640px;
}

.login-showcase {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    var(--sidebar);
  background-size: 36px 36px, 36px 36px, auto;
  box-shadow: var(--shadow);
  color: #fff;
}

.login-showcase::after {
  position: absolute;
  right: 30px;
  bottom: 28px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(14, 165, 198, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(14, 165, 198, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(14, 165, 198, 0.16) 1px, transparent 1px);
  background-size: 18px 18px;
  content: "";
}

.agency-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agency-brand {
  position: relative;
  z-index: 1;
}

.brand-symbol {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-cyan));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.agency-brand p,
.sidebar-brand p {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 800;
}

.agency-brand h1,
.sidebar-brand h1 {
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.28;
}

.showcase-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-width: 680px;
  margin-top: auto;
}

.showcase-kicker {
  color: #7dd3fc;
  font-size: 13px;
  font-weight: 900;
}

.showcase-copy strong {
  max-width: 640px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.04;
}

.showcase-copy span {
  max-width: 560px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  line-height: 1.65;
}

.showcase-metrics {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.metric-tile span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  font-weight: 800;
}

.metric-tile strong {
  font-size: 28px;
  line-height: 1;
}

.quality-flow {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: var(--sidebar-line);
}

.quality-flow div {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
  background: rgba(18, 21, 28, 0.92);
}

.quality-flow span {
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 900;
}

.quality-flow strong {
  font-size: 15px;
}

.quality-flow p,
.showcase-footer {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  line-height: 1.45;
}

.showcase-footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
}

.login-panel {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: grid;
  gap: 8px;
}

.panel-badge {
  width: fit-content;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.panel-heading h2 {
  font-size: 28px;
  line-height: 1.2;
}

.panel-heading p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.demo-notice {
  padding: 12px;
  border: 1px solid #f0d69b;
  border-radius: 8px;
  background: #fff8e8;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.55;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 900;
}

.login-field input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 102, 208, 0.12);
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  padding: 0 15px 0 18px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.login-button:hover {
  background: #05070b;
  transform: translateY(-1px);
}

body.authenticated .login-screen {
  display: none;
}

body.locked .app-shell {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 380px) minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  min-width: 0;
  overflow: hidden;
  background: var(--shell);
}

.scenario-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--sidebar);
  background-size: 28px 28px, auto;
  color: #fff;
}

.sidebar-brand {
  padding-bottom: 2px;
}

.status-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #86efac;
  font-size: 12px;
  font-weight: 900;
}

.status-card strong {
  font-size: 14px;
  line-height: 1.45;
}

.status-card p {
  color: rgba(255, 255, 255, 0.64);
  font-size: 13px;
  line-height: 1.55;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16);
}

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

.data-metrics div {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: var(--sidebar-soft);
}

.data-metrics span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 900;
}

.data-metrics strong {
  color: #f8fafc;
  font-size: 27px;
  line-height: 1;
}

.data-metrics p {
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 800;
}

.question-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 900;
}

#reloadScenarios {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
}

#reloadScenarios:hover {
  border-color: rgba(125, 211, 252, 0.42);
  background: rgba(14, 165, 198, 0.14);
  color: #fff;
}

.scenario-list {
  display: grid;
  gap: 8px;
}

.scenario-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.82);
  text-align: left;
  cursor: pointer;
}

.scenario-button:hover {
  border-color: rgba(125, 211, 252, 0.36);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}

.scenario-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: rgba(14, 165, 198, 0.18);
  color: #7dd3fc;
  font-size: 11px;
  font-weight: 900;
}

.scenario-text {
  align-self: center;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.42;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}

.sidebar-footer span {
  color: #7dd3fc;
  font-size: 11px;
  font-weight: 900;
}

.sidebar-footer p {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
  line-height: 1.5;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--shell);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 96px;
  padding: 18px clamp(20px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.chat-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.chat-title h2 {
  color: var(--ink);
  font-size: 23px;
  line-height: 1.22;
}

.chat-title span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.agent-badge {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.muted-badge {
  color: var(--ink-soft);
}

.conversation-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(15, 102, 208, 0.045), rgba(255, 255, 255, 0) 220px),
    var(--shell);
}

.conversation-intro {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px clamp(20px, 3vw, 34px) 0;
}

.conversation-intro div {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.conversation-intro span {
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 900;
}

.conversation-intro strong {
  color: var(--ink);
  font-size: 15px;
}

.conversation-intro p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px clamp(20px, 3vw, 34px) 28px;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  width: min(880px, 100%);
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 38px;
  align-self: flex-end;
}

.message.user .message-avatar {
  order: 2;
  background: var(--accent);
}

.message.user .message-content {
  order: 1;
  justify-self: end;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.message-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.message-content {
  display: grid;
  gap: 8px;
  max-width: min(760px, 100%);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 30px rgba(19, 23, 32, 0.06);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.message-label {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
}

.message.user .message-label {
  color: rgba(255, 255, 255, 0.72);
}

.message-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.68;
}

.message.loading .message-content {
  min-width: min(100%, 380px);
}

.progress-wrap {
  display: grid;
  gap: 10px;
}

.progress-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.progress-track {
  position: relative;
  width: 300px;
  max-width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e4f3;
}

.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 44%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-cyan));
  animation: progress-slide 1.05s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }
  55% {
    width: 64%;
  }
  100% {
    transform: translateX(235%);
  }
}

.meta {
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.45;
}

.message.user .meta {
  color: rgba(255, 255, 255, 0.72);
}

.references {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.reference {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-cyan);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.reference strong {
  font-size: 12px;
  line-height: 1.35;
}

.reference span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.composer {
  display: grid;
  gap: 8px;
  padding: 14px clamp(20px, 3vw, 34px) 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
}

textarea {
  width: 100%;
  min-height: 58px;
  max-height: 170px;
  resize: none;
  padding: 14px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--ink);
  line-height: 1.5;
}

textarea::placeholder {
  color: #8b95a5;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 102, 208, 0.1);
}

#sendButton {
  display: grid;
  width: 48px;
  height: 48px;
  align-self: end;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

#sendButton:hover {
  background: #05070b;
  transform: translateY(-1px);
}

.composer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--subtle);
  font-size: 12px;
}

#reloadScenarios:disabled,
.scenario-button:disabled,
#sendButton:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.54;
  transform: none;
}

.scenario-button:disabled:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.045);
}

textarea:disabled {
  background: #edf1f7;
}

@media (max-width: 1100px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-showcase {
    min-height: 520px;
  }

  .app-shell {
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  }

  .conversation-intro {
    grid-template-columns: 1fr;
  }
}

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

  .login-screen {
    position: static;
    min-height: 100vh;
    padding: 16px;
  }

  .login-showcase {
    min-height: auto;
    padding: 22px;
  }

  .showcase-copy strong {
    font-size: 32px;
  }

  .showcase-metrics,
  .quality-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .question-section {
    flex: none;
    overflow: visible;
    padding-right: 0;
  }

  .sidebar-footer {
    display: none;
  }

  .chat-panel {
    height: auto;
    min-height: 72vh;
    overflow: visible;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-actions {
    justify-content: flex-start;
  }

  .conversation-stage {
    overflow: visible;
  }

  .messages {
    max-height: 64vh;
  }
}

@media (max-width: 560px) {
  .showcase-metrics,
  .quality-flow,
  .data-metrics {
    grid-template-columns: 1fr;
  }

  .login-panel,
  .login-showcase,
  .scenario-panel {
    padding: 18px;
  }

  .panel-heading h2 {
    font-size: 24px;
  }

  .chat-title h2 {
    font-size: 20px;
  }

  .conversation-intro,
  .messages,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message,
  .message.user {
    grid-template-columns: 1fr;
  }

  .message-avatar {
    display: none;
  }

  .message.user .message-content {
    justify-self: stretch;
  }

  .composer-box {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  #sendButton {
    width: 44px;
    height: 44px;
  }
}

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