:root {
  --bg: #030303;
  --panel: #080808;
  --surface: #0c0c0d;
  --surface-2: #121112;
  --surface-3: #181516;
  --ink: #f3eeee;
  --muted: #9a9090;
  --soft: #6d6464;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.17);
  --accent: #c92f36;
  --accent-deep: #3a090d;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  letter-spacing: 0;
  background: var(--bg);
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  overflow: hidden;
}

.debug-only {
  display: none !important;
}

body.debug-mode .nav-item.debug-only {
  display: grid !important;
}

body.debug-mode .readout.debug-only,
body.debug-mode .rules.debug-only,
body.debug-mode .classify-message.debug-only {
  display: block !important;
}

button,
textarea {
  font: inherit;
}

.panel {
  min-height: 100vh;
  background: #070707;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.rail-nav {
  padding: 24px 18px 18px;
  display: grid;
  gap: 2px;
}

.nav-item {
  min-height: 38px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  color: #cfc5c5;
  font-size: 13px;
  font-weight: 650;
}

.nav-icon {
  width: 8px;
  height: 8px;
  background: #5b5353;
  display: block;
}

.nav-item.active .nav-icon {
  background: var(--accent);
  box-shadow: 0 0 18px rgba(201, 47, 54, 0.55);
}

.prompt-card {
  display: none;
  padding: 54px 24px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.has-response .prompt-card {
  display: block;
}

.eyebrow,
.label,
.side-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
  margin: 0 0 8px;
}

h1 {
  min-height: 220px;
  margin: 0;
  color: #f6eeee;
  font-size: 38px;
  line-height: 1.12;
  font-weight: 820;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.readout {
  margin: auto 22px 18px;
  border-top: 1px solid var(--line);
}

.readout div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  color: #f1eaea;
  text-align: right;
  font-weight: 780;
}

.rules {
  margin: 0 22px 22px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: #b6abab;
  font-size: 12px;
}

summary {
  cursor: pointer;
}

.rulebox {
  height: 150px;
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.34);
  padding: 13px;
}

.rulebox p {
  margin: 0 0 10px;
  line-height: 1.45;
}

.stage {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: #cfc4c4;
  font-size: 13px;
  background: rgba(3, 3, 3, 0.88);
  backdrop-filter: blur(16px);
}

.live-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  background: var(--accent);
  margin-right: 10px;
  box-shadow: 0 0 16px rgba(201, 47, 54, 0.68);
}

.conversation {
  min-width: 0;
  min-height: 0;
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 30px 28px 24px;
  display: grid;
  grid-template-columns: minmax(500px, 1fr) minmax(360px, 420px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
}

.empty-state {
  grid-column: 1;
  grid-row: 1;
  padding: 26px 0 8px;
}

.empty-state p,
.empty-state h2 {
  margin: 0;
}

.empty-state p {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.empty-state h2 {
  max-width: 900px;
  margin-top: 10px;
  color: #efe8e8;
  font-size: clamp(40px, 4.4vw, 64px);
  line-height: 1.06;
  font-weight: 800;
  word-break: keep-all;
}

.has-response .empty-state {
  display: none;
}

.thread {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.message {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 10, 11, 0.84);
  padding: 17px 18px;
}

.message::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 0;
  width: 3px;
  background: transparent;
}

.user-message::before {
  background: rgba(255, 255, 255, 0.22);
}

.bot-message::before,
.classify-message::before {
  background: var(--accent);
}

.user-message,
.classify-message {
  display: block;
  padding-right: 128px;
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.original {
  margin: 0;
  color: #e9e2e2;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.32;
  font-weight: 690;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.bot-output {
  margin: 8px 0 0;
  max-width: 880px;
  color: #f6eeee;
  font-size: clamp(26px, 2.8vw, 44px);
  line-height: 1.14;
  font-weight: 780;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips span {
  border: 1px solid rgba(201, 47, 54, 0.46);
  border-radius: 3px;
  background: rgba(201, 47, 54, 0.11);
  color: #f0c6c6;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 740;
}

.side-label {
  position: absolute;
  top: 17px;
  right: 18px;
  color: #746a6b;
  text-align: right;
  padding-top: 0;
}

.message-head .side-label {
  position: static;
}

.log-wrap {
  grid-column: 2;
  grid-row: 1 / 4;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(6, 6, 6, 0.86);
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr);
  overflow: hidden;
}

.log-header {
  min-width: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 7px 0 16px;
}

.log-header h2 {
  margin: 0;
  color: #d8cece;
  font-size: 13px;
  font-weight: 820;
}

.projector-link {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  color: #a79d9d;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
}

.projector-link:hover,
.projector-link:focus-visible {
  border-color: rgba(201, 47, 54, 0.76);
  color: #f1e7e7;
  outline: none;
}

.log {
  min-height: 0;
  overflow: auto;
  padding: 8px 14px 18px;
  font-size: 13px;
  line-height: 1.48;
}

.comment-thread {
  position: relative;
  padding: 7px 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.comment-thread:last-child {
  border-bottom: 0;
}

.log-entry {
  position: relative;
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 8px;
  padding: 8px 0 9px;
}

.log-entry::before {
  content: "";
  width: 3px;
  height: calc(100% - 14px);
  background: rgba(201, 47, 54, 0.78);
  grid-column: 1;
  grid-row: 1 / span 2;
  margin-top: 3px;
}

.log-entry.viewer-entry::before {
  background: rgba(255, 255, 255, 0.34);
}

.reply-stack {
  position: relative;
  margin: 2px 0 0 15px;
  padding-left: 18px;
}

.reply-stack::before {
  content: "";
  position: absolute;
  top: -4px;
  bottom: 8px;
  left: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.16);
}

.reply-stack .log-entry::after {
  content: "";
  display: block;
  position: absolute;
  top: 18px;
  left: -18px;
  width: 14px;
  height: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0 0 0 8px;
}

.log-entry.burst-entry {
  padding-left: 0;
}

.log-entry.burst-entry::before {
  background: rgba(201, 47, 54, 0.68);
}

.log-entry.viewer-entry::after {
  display: none;
}

.log-entry p {
  grid-column: 2;
  margin: 0 0 5px;
  color: #e8dfdf;
}

.log-entry p:first-child {
  color: #9f9696;
  font-size: 11px;
}

.log-entry p:first-child strong {
  color: #f2ebeb;
  font-size: 12px;
  font-weight: 790;
}

.log-entry.viewer-entry p:first-child strong {
  color: #d8d0d0;
}

.log-entry.viewer-entry p:last-child {
  color: #cfc6c6;
}

.log-entry.burst-entry p:first-child,
.log-entry.burst-entry p:last-child {
  color: #ded4d4;
}

.log-entry p:last-child {
  font-size: 14px;
  line-height: 1.46;
}

.composer {
  grid-column: 1;
  grid-row: 3;
  width: min(100%, 980px);
  justify-self: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #080808;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  box-shadow: 0 18px 80px rgba(0, 0, 0, 0.38);
}

textarea {
  width: 100%;
  height: 78px;
  border: 0;
  border-radius: 4px;
  background: #111112;
  color: var(--ink);
  padding: 15px;
  resize: none;
  outline: none;
  line-height: 1.45;
  font-size: 16px;
}

textarea::placeholder {
  color: #7e7475;
}

textarea:focus {
  box-shadow: inset 0 0 0 1px rgba(201, 47, 54, 0.72);
}

.composer div {
  display: grid;
  align-content: space-between;
  gap: 8px;
}

#submitState {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

button {
  border: 1px solid rgba(201, 47, 54, 0.62);
  border-radius: 4px;
  background: var(--accent-deep);
  color: #f6eeee;
  min-width: 98px;
  height: 40px;
  padding: 0 12px;
  font-weight: 820;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

#cameraProbe,
#presenceCanvas {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -10px;
  top: -10px;
}

@media (max-width: 1240px) {
  body {
    grid-template-columns: 260px minmax(0, 1fr);
    background: var(--bg);
    overflow: auto;
  }

  .panel {
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .stage {
    height: auto;
    min-height: 100vh;
  }

  .conversation {
    min-height: calc(100vh - 52px);
    padding: 34px 24px 24px;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(320px, 480px) auto;
  }

  .empty-state {
    grid-column: 1;
    grid-row: 1;
  }

  .thread {
    grid-column: 1;
    grid-row: 2;
  }

  .log-wrap {
    grid-column: 1;
    grid-row: 3;
    min-height: 320px;
  }

  .composer {
    grid-column: 1;
    grid-row: 4;
  }
}

@media (max-width: 760px) {
  body {
    display: block;
    overflow: auto;
  }

  .panel {
    position: static;
    height: auto;
    min-height: auto;
  }

  .stage {
    height: auto;
  }

  .conversation {
    min-height: 720px;
    padding: 26px 16px;
  }

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

  .side-label {
    display: none;
  }
}
