
:root {
  font-family: Inter, 'Noto Sans KR', system-ui, sans-serif;
  color: #f5f7ff;
  background: #080a12;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --panel: rgba(16, 19, 31, 0.72);
  --panel-strong: rgba(19, 23, 39, 0.92);
  --stroke: rgba(255, 255, 255, 0.09);
  --muted: #9ea5bd;
  --accent: #9d8cff;
  --accent-2: #65d7ff;
}

* { box-sizing: border-box; }

html, body, #root { min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100vh; overflow-x: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: 24px clamp(18px, 3vw, 44px) 18px;
  background:
    radial-gradient(circle at 15% 15%, rgba(102, 77, 255, 0.14), transparent 34%),
    radial-gradient(circle at 85% 70%, rgba(50, 184, 255, 0.11), transparent 30%),
    linear-gradient(145deg, #080a12 0%, #0c0f1a 45%, #080b14 100%);
}

.ambient {
  position: absolute;
  width: 32vw;
  height: 32vw;
  border-radius: 999px;
  filter: blur(90px);
  opacity: 0.14;
  pointer-events: none;
}
.ambient-one { left: -15vw; top: 10vh; background: #7968ff; }
.ambient-two { right: -18vw; bottom: 4vh; background: #42c8ff; }

.topbar {
  position: relative;
  z-index: 5;
  max-width: 1460px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  background: linear-gradient(145deg, rgba(157,140,255,.24), rgba(101,215,255,.08));
  box-shadow: inset 0 1px rgba(255,255,255,.08), 0 12px 40px rgba(0,0,0,.2);
}
.brand-title { font-weight: 800; font-size: 13px; letter-spacing: .16em; }
.brand-subtitle { margin-top: 3px; color: #7f879f; font-size: 10px; letter-spacing: .09em; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: #abb1c4;
  background: rgba(10, 13, 23, .66);
  backdrop-filter: blur(16px);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .11em;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #f0b35e; box-shadow: 0 0 12px currentColor; }
.status-pill.ready .status-dot { background: #70e7a8; }
.status-pill.error .status-dot { background: #ff707d; }

.content-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(320px, .78fr);
  gap: 18px;
  max-width: 1460px;
  min-height: min(760px, calc(100vh - 138px));
  margin: 0 auto;
  align-items: start;
}

.stage-card, .chat-card {
  border: 1px solid var(--stroke);
  border-radius: 25px;
  background: var(--panel);
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.025);
}

.stage-card {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  background:
    radial-gradient(circle at 50% 42%, rgba(133, 119, 255, .12), transparent 30%),
    linear-gradient(180deg, rgba(19,23,38,.9), rgba(11,14,24,.8));
}
.stage-card::after {
  content: '';
  position: absolute;
  inset: auto 8% 2% 8%;
  height: 20%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(116, 102, 255, .13), transparent 68%);
  filter: blur(15px);
  pointer-events: none;
}
.stage-grid {
  position: absolute;
  inset: 0;
  opacity: .20;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 85%, transparent 100%);
}
.stage-label {
  position: absolute;
  z-index: 5;
  top: 22px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
}
.stage-label span { color: #858ca4; font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.stage-label strong { font-size: 12px; letter-spacing: .02em; }

.live2d-host { position: absolute; inset: 0; z-index: 2; }
.live2d-canvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }

.chat-card {
  min-height: 0;
  height: min(500px, calc(100vh - 180px));
  max-height: 500px;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: var(--panel-strong);
}
.chat-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 2px 2px 12px; }
.chat-header p { margin: 0 0 5px; color: #838ba3; font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.chat-header h1 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.chat-controls { display: flex; align-items: center; gap: 7px; }
.mode-badge { padding: 7px 9px; border: 1px solid rgba(157,140,255,.25); border-radius: 9px; color: #b9afff; background: rgba(157,140,255,.08); font-size: 9px; font-weight: 800; letter-spacing: .12em; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px 3px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.13) transparent;
}
.message-row { display: flex; align-items: flex-end; gap: 8px; margin: 7px 0; }
.message-row.user { justify-content: flex-end; }
.avatar-dot {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #8978ef, #4d90b6);
  color: white;
  font-size: 8px;
  font-weight: 800;
}
.message-bubble {
  max-width: 82%;
  padding: 9px 11px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 15px 15px 15px 5px;
  background: rgba(255,255,255,.045);
  color: #e5e8f3;
  font-size: 13px;
  line-height: 1.55;
}
.message-row.user .message-bubble {
  border-color: rgba(157,140,255,.2);
  border-radius: 15px 15px 5px 15px;
  background: linear-gradient(145deg, rgba(121,104,255,.28), rgba(105,119,209,.18));
}


.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 7px 7px 13px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 16px;
  background: rgba(5,7,13,.56);
  box-shadow: inset 0 1px 10px rgba(0,0,0,.16);
}
.chat-input:focus-within { border-color: rgba(157,140,255,.36); box-shadow: 0 0 0 3px rgba(157,140,255,.06), inset 0 1px 10px rgba(0,0,0,.16); }
.chat-input input { flex: 1; min-width: 0; border: 0; outline: 0; color: #f2f3fa; background: transparent; font-size: 12px; }
.chat-input input::placeholder { color: #656d84; }
.chat-input button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, #8070ee, #5c7fe0);
  box-shadow: 0 7px 22px rgba(92,93,220,.22);
  cursor: pointer;
}
.chat-input button:disabled { opacity: .34; cursor: default; box-shadow: none; }
.chat-input svg { width: 17px; height: 17px; fill: white; }


@media (max-width: 900px) {
  .app-shell { padding: 16px 12px 16px; }
  .topbar { margin-bottom: 12px; }
  .brand-subtitle { display: none; }
  .content-grid { grid-template-columns: 1fr; min-height: auto; }
  .stage-card { min-height: 58vh; max-height: 680px; }
  .chat-card { height: 400px; max-height: 400px; min-height: 0; }
}

@media (max-width: 520px) {
  .brand-title { font-size: 11px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .status-pill { padding: 8px 9px; font-size: 8px; }
  .content-grid { gap: 10px; }
  .stage-card, .chat-card { border-radius: 20px; }
  .stage-card { min-height: 54vh; }
  .stage-label { top: 17px; left: 18px; }
  .chat-card { padding: 14px; height: 330px; max-height: 330px; min-height: 0; }
  .message-bubble { max-width: 88%; font-size: 12px; line-height: 1.45; }
  .chat-header { padding-bottom: 8px; }
  .chat-header h1 { font-size: 18px; }
}

/* v0.2 AI states */
.mode-badge.thinking {
  opacity: .78;
}

.thinking-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 58px;
}

.thinking-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: .4;
  animation: thinkingDot 1.05s infinite ease-in-out;
}

.thinking-bubble span:nth-child(2) { animation-delay: .14s; }
.thinking-bubble span:nth-child(3) { animation-delay: .28s; }

.message-bubble.error {
  border-color: rgba(255, 130, 130, .35);
}

@keyframes thinkingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-4px); opacity: 1; }
}
