:root {
  color-scheme: dark;
  --bg: #05070d;
  --surface: rgba(12, 16, 28, 0.86);
  --surface-strong: rgba(18, 24, 42, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(121, 146, 191, 0.18);
  --line-strong: rgba(73, 119, 214, 0.38);
  --text: #f5f7fb;
  --muted: #93a0b8;
  --faint: #64708a;
  --blue: #164eae;
  --blue-bright: #2f7cff;
  --cyan: #6fe8ff;
  --good: #7cf7c0;
  --danger: #ff8f98;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(22, 78, 174, 0.42), transparent 30%),
    radial-gradient(circle at 88% 16%, rgba(111, 232, 255, 0.14), transparent 28%),
    linear-gradient(145deg, #02040a 0%, #07101f 45%, #030711 100%);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at center, rgba(0,0,0,0.72), transparent 72%);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  height: 100vh;
  padding: 18px;
}

.conversation-card,
.insight-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.conversation-card {
  display: flex;
  flex-direction: column;
  border-radius: 30px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.055), transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 124px;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 30px rgba(47, 124, 255, 0.28));
}

.brand-title {
  font-size: clamp(18px, 2.1vw, 30px);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.brand-subtitle {
  margin-left: -6px;
  padding: 6px 10px;
  border: 1px solid rgba(47, 124, 255, 0.24);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(47, 124, 255, 0.08);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
}

.chat-log {
  flex: 1;
  overflow: auto;
  padding: 36px clamp(20px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chat-log:empty::before {
  content: "PPFT Demo";
  margin: auto;
  color: rgba(245, 247, 251, 0.12);
  font-size: clamp(48px, 11vw, 132px);
  font-weight: 820;
  letter-spacing: -0.08em;
}

.message { display: flex; }
.message.user { justify-content: flex-end; }
.bubble {
  max-width: min(820px, 86%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.user .bubble {
  color: white;
  background: #164eae;
  border-color: transparent;
  box-shadow: 0 16px 45px rgba(22, 78, 174, 0.34);
}
.assistant .bubble {
  background: rgba(255,255,255,0.055);
}
.error .bubble {
  color: var(--danger);
  border-color: rgba(255, 143, 152, 0.4);
  background: rgba(255, 143, 152, 0.08);
}

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

textarea {
  width: 100%;
  min-height: 56px;
  max-height: 180px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 18px;
  color: var(--text);
  background: rgba(255,255,255,0.055);
  outline: none;
  font: inherit;
  line-height: 1.5;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(47, 124, 255, 0.12);
  background: rgba(255,255,255,0.07);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 54px;
  border: 0;
  border-radius: 18px;
  padding: 0 22px;
  color: white;
  background: linear-gradient(135deg, #0e3a86, #1d67d8 55%, #25b8ff);
  font-weight: 820;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(22, 78, 174, 0.34);
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
button:hover { transform: translateY(-1px); filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: wait; transform: none; }
button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.insight-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-radius: 28px;
  padding: 22px;
  overflow: auto;
}
.insight-header {
  padding: 4px 2px 10px;
}
.overline {
  margin: 0 0 9px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h2, h3 { margin: 0; }
h2 {
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: -0.045em;
}
.signal-panel {
  position: relative;
  flex: 1;
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.026));
  overflow: hidden;
}
.signal-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--blue-bright), var(--cyan), transparent);
  opacity: .8;
}
.panel-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-index {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: var(--cyan);
  background: rgba(111, 232, 255, 0.1);
  font-size: 12px;
  font-weight: 850;
}
h3 {
  color: #e7eefc;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.panel-note {
  margin: -4px 0 10px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8e2f4;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}
.primary-signal pre {
  color: #a9d8ff;
}
.attack-signal pre {
  min-height: 140px;
  color: #eef4ff;
}

@media (max-width: 1040px) {
  body { overflow: auto; }
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }
  .insight-card { max-height: none; }
}

@media (max-width: 640px) {
  .app-shell { padding: 10px; }
  .topbar { padding: 16px; align-items: flex-start; }
  .brand { gap: 10px; flex-direction: column; align-items: flex-start; }
  .brand-logo { width: 104px; }
  .composer { grid-template-columns: 1fr; }
  button { width: 100%; }
  .bubble { max-width: 94%; }
}
