:root {
  color-scheme: light;
  --charcoal: #18110e;
  --charcoal-2: #24130f;
  --charcoal-3: #2f1a14;
  --ink: #171717;
  --ink-soft: #3f3f46;
  --muted: #6b7280;
  --subtle: #9ca3af;
  --canvas: #f4f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --safety: #f97316;
  --safety-strong: #c2410c;
  --safety-soft: #fff4e8;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --amber: #f59e0b;
  --green: #16a34a;
  --blue: #1d4ed8;
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(24, 17, 14, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(249, 115, 22, 0.24);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

svg {
  display: block;
}

.kicker {
  color: var(--safety);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.brand-row strong {
  display: block;
  color: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.brand-symbol {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: var(--safety);
  color: #1d0f0b;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(249, 115, 22, 0.28);
}

.brand-symbol.compact {
  width: 42px;
  height: 42px;
  font-size: 13px;
}

/* Login */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 520px);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
  overflow: auto;
  padding: clamp(24px, 5vw, 62px);
  background:
    linear-gradient(115deg, rgba(24, 17, 14, 0.98), rgba(36, 19, 15, 0.96) 46%, rgba(87, 30, 13, 0.92)),
    var(--charcoal);
  color: var(--white);
}

.login-showcase {
  display: grid;
  gap: 34px;
  max-width: 780px;
}

.login-showcase .brand-row {
  color: rgba(255, 255, 255, 0.92);
}

.hero-copy {
  display: grid;
  gap: 18px;
}

.hero-copy h1 {
  max-width: 760px;
  color: var(--white);
  font-size: clamp(42px, 6vw, 78px);
  font-weight: 760;
  line-height: 1.02;
}

.hero-copy > p:last-child {
  max-width: 630px;
  color: rgba(255, 245, 238, 0.72);
  font-size: 17px;
  line-height: 1.75;
}

.showcase-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 660px;
}

.showcase-metrics div {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.showcase-metrics span {
  display: block;
  color: rgba(255, 255, 255, 0.54);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.showcase-metrics strong {
  display: block;
  margin-top: 9px;
  color: #fff6ee;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 780;
}

.risk-board {
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.risk-board div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.risk-board p {
  color: rgba(255, 245, 238, 0.72);
  font-size: 13px;
  line-height: 1.5;
}

.risk-code {
  display: inline-grid;
  min-width: 72px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  color: var(--white);
  font-size: 11px;
  font-weight: 900;
}

.risk-code.stop {
  background: var(--danger);
}

.risk-code.hold {
  background: var(--amber);
  color: #1f1303;
}

.risk-code.review {
  background: var(--blue);
}

.login-panel {
  display: grid;
  gap: 18px;
  width: 100%;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: var(--shadow);
}

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

.panel-chip {
  width: fit-content;
  padding: 6px 9px;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  background: var(--safety-soft);
  color: var(--safety-strong);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-heading h2 {
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  line-height: 1.25;
}

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

.demo-notice {
  padding: 13px 14px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #8a3b0a;
  font-size: 13px;
  line-height: 1.6;
}

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

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

.login-field input:focus {
  border-color: var(--safety);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.12);
}

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

.login-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 18px 0 20px;
  border: 0;
  border-radius: 8px;
  background: var(--charcoal);
  color: var(--white);
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(24, 17, 14, 0.18);
}

.login-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--safety);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.login-button:hover {
  background: var(--charcoal-3);
  transform: translateY(-1px);
}

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

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

/* Application */

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

.scenario-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 24px 22px;
  background:
    linear-gradient(180deg, rgba(24, 17, 14, 0.99), rgba(36, 19, 15, 0.99) 52%, rgba(47, 26, 20, 0.99)),
    var(--charcoal);
  color: var(--white);
  scrollbar-color: rgba(249, 115, 22, 0.4) transparent;
}

.sidebar-brand {
  min-height: 46px;
}

.sidebar-brand .kicker {
  color: rgba(251, 146, 60, 0.86);
}

.demo-chip {
  margin-left: auto;
  padding: 5px 7px;
  border: 1px solid rgba(251, 146, 60, 0.28);
  border-radius: 6px;
  color: rgba(253, 186, 116, 0.88);
  font-size: 10px;
  font-weight: 900;
}

.workspace-title {
  display: grid;
  gap: 11px;
  margin-top: 34px;
}

.workspace-title h1 {
  color: #fff8f1;
  font-size: 25px;
  font-weight: 720;
  line-height: 1.22;
}

.status-card {
  display: grid;
  gap: 13px;
  margin-top: 24px;
  padding: 18px;
  border: 1px solid rgba(251, 146, 60, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.status-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-card-head > span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 245, 238, 0.76);
  font-size: 12px;
  font-weight: 800;
}

.status-card-head b {
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(249, 115, 22, 0.14);
  color: #fdba74;
  font-size: 10px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.18);
}

.status-card h2 {
  color: #fff8f1;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.35;
}

.status-card > p {
  color: rgba(255, 245, 238, 0.58);
  font-size: 12px;
  line-height: 1.65;
}

.data-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.data-metrics div {
  display: grid;
  gap: 4px;
  padding: 0 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.data-metrics div:first-child {
  padding-left: 0;
  text-align: left;
}

.data-metrics div:last-child {
  padding-right: 0;
  border-right: 0;
  text-align: right;
}

.data-metrics strong {
  color: #fff8f1;
  font-size: 18px;
  font-weight: 760;
}

.data-metrics span {
  color: rgba(255, 245, 238, 0.42);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.question-section {
  min-height: 0;
  margin-top: 28px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading > div {
  display: grid;
  gap: 4px;
}

.section-heading span {
  color: rgba(255, 245, 238, 0.42);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.section-heading strong {
  color: rgba(255, 248, 241, 0.92);
  font-size: 13px;
  font-weight: 800;
}

#reloadScenarios {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 245, 238, 0.66);
  cursor: pointer;
}

#reloadScenarios svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

#reloadScenarios:hover {
  border-color: rgba(251, 146, 60, 0.38);
  background: rgba(249, 115, 22, 0.14);
  color: #fdba74;
}

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

.scenario-button {
  position: relative;
  width: 100%;
  min-height: 54px;
  padding: 12px 34px 12px 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 245, 238, 0.68);
  text-align: left;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  counter-increment: scenario;
}

.scenario-button::before {
  content: counter(scenario, decimal-leading-zero);
  position: absolute;
  top: 13px;
  left: 12px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  background: rgba(249, 115, 22, 0.13);
  color: #fdba74;
  font-size: 10px;
  font-weight: 900;
}

.scenario-button::after {
  content: "";
  position: absolute;
  top: 21px;
  right: 13px;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  opacity: 0.36;
  transform: rotate(45deg);
}

.scenario-button:hover {
  border-color: rgba(251, 146, 60, 0.22);
  background: rgba(255, 255, 255, 0.065);
  color: #fff8f1;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer span {
  color: rgba(253, 186, 116, 0.82);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.sidebar-footer p {
  margin-top: 7px;
  color: rgba(255, 245, 238, 0.5);
  font-size: 12px;
  line-height: 1.6;
}

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

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

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

.chat-title .kicker {
  color: var(--safety-strong);
}

.chat-title h2 {
  color: var(--ink);
  font-size: 24px;
  font-weight: 820;
  line-height: 1.18;
}

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

.model-badge {
  display: grid;
  min-width: 168px;
  max-width: 240px;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
}

.model-badge span {
  color: var(--safety-strong);
  font-size: 9px;
  font-weight: 900;
}

.model-badge strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 820;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.agent-badge.muted-badge {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--ink-soft);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px clamp(18px, 4vw, 48px);
  background:
    linear-gradient(180deg, rgba(255, 247, 237, 0.55), rgba(248, 250, 252, 0.76) 42%, #ffffff),
    var(--white);
}

.conversation-intro {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 980px;
}

.conversation-intro div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.conversation-intro span {
  display: block;
  color: var(--safety-strong);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.conversation-intro strong {
  display: block;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 930px;
  min-width: 0;
  line-height: 1.65;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.agent,
.message.loading {
  align-self: flex-start;
}

.message-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--charcoal);
  color: var(--white);
  font-size: 12px;
  font-weight: 900;
}

.message.user .message-avatar {
  background: var(--safety);
  color: #23120b;
}

.message-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.message.user .message-body {
  justify-items: end;
}

.message-label {
  color: var(--subtle);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.message-content {
  max-width: min(760px, calc(100vw - 480px));
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.06);
}

.message.user .message-content {
  border-color: #ea580c;
  background: var(--safety);
  color: #1d0f0b;
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.18);
}

.message.loading .message-content {
  display: grid;
  gap: 12px;
  width: min(440px, calc(100vw - 480px));
  color: var(--muted);
}

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

.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--danger), var(--safety), var(--amber));
  animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-115%);
  }
  55% {
    width: 66%;
  }
  100% {
    transform: translateX(240%);
  }
}

.meta {
  margin-top: 10px;
  color: var(--subtle);
  font-size: 12px;
  white-space: normal;
}

.message.user .meta {
  color: rgba(29, 15, 11, 0.64);
}

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

.references-title {
  color: var(--safety-strong);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.reference {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--safety);
  border-radius: 8px;
  background: var(--panel-soft);
  white-space: normal;
}

.reference strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

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

.reference small {
  color: var(--subtle);
  font-size: 11px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  padding: 16px clamp(18px, 4vw, 48px) 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

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

textarea:focus {
  border-color: var(--safety);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}

textarea:disabled {
  background: #f3f4f6;
}

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

#sendButton svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

#sendButton:hover {
  background: var(--charcoal-3);
  transform: translateY(-1px);
}

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

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

#sendButton:disabled {
  transform: none;
}

.app-shell.is-answering .chat-header {
  border-bottom-color: #fed7aa;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: minmax(310px, 350px) minmax(0, 1fr);
  }

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

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

  .login-screen {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    font-size: clamp(36px, 10vw, 58px);
  }

  .login-panel {
    max-width: 560px;
  }

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

  .scenario-panel {
    overflow: visible;
    padding: 20px;
  }

  .workspace-title {
    margin-top: 22px;
  }

  .scenario-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .scenario-button {
    width: min(320px, 82vw);
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .sidebar-footer {
    display: none;
  }

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

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

  .messages {
    min-height: 52vh;
    max-height: 68vh;
    padding: 18px;
  }

  .message-content,
  .message.loading .message-content {
    max-width: calc(100vw - 88px);
    width: auto;
  }

  .composer {
    position: sticky;
    bottom: 0;
    padding: 12px 18px 18px;
  }
}

@media (max-width: 620px) {
  .login-screen {
    padding: 18px;
  }

  .showcase-metrics {
    grid-template-columns: 1fr;
  }

  .risk-board div {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 22px;
  }

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

  .model-badge {
    min-width: min(210px, 100%);
    max-width: 100%;
  }

  .data-metrics strong {
    font-size: 16px;
  }

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

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

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