:root {
  --bg-1: #031423;
  --bg-2: #0a233a;
  --panel: rgba(8, 25, 44, 0.72);
  --line: rgba(127, 183, 255, 0.32);
  --text-main: #d7e7ff;
  --text-sub: #8ba9cf;
  --accent: #31d7ff;
  --accent-2: #66ffb3;
  --danger: #ff7b8a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Pretendard", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 18% 18%, #123b5f 0%, transparent 30%),
    radial-gradient(circle at 82% 8%, #1e3f4f 0%, transparent 22%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 18px;
}

.holo-panel,
.chat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 22px 48px rgba(0, 10, 24, 0.42);
  backdrop-filter: blur(8px);
}

.holo-panel {
  padding: 24px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #031423;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  font-weight: 700;
  margin-bottom: 8px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
}

h1 {
  font-size: 30px;
}

.subtitle {
  color: var(--text-sub);
  margin: 8px 0 18px;
  line-height: 1.5;
  font-size: 14px;
}

.hologram-stage {
  margin-top: 14px;
  height: 220px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: radial-gradient(circle at center, #0f3358 0%, #08192f 60%, #051325 100%);
  position: relative;
  overflow: hidden;
}

.hologram-stage.has-live2d .core-ring,
.hologram-stage.has-live2d .core-orb {
  opacity: 0.2;
}

#live2dCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

.core-ring {
  position: absolute;
  width: 158px;
  height: 158px;
  border: 2px solid rgba(49, 215, 255, 0.48);
  border-radius: 50%;
  top: 28px;
  left: calc(50% - 79px);
  box-shadow: 0 0 22px rgba(49, 215, 255, 0.48), inset 0 0 22px rgba(49, 215, 255, 0.2);
  animation: spin 9s linear infinite;
}

.core-orb {
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  top: 70px;
  left: calc(50% - 37px);
  background: radial-gradient(circle at 30% 28%, #d6f8ff, #31d7ff 45%, #10688b 100%);
  box-shadow: 0 0 30px rgba(49, 215, 255, 0.66);
  animation: float 3.2s ease-in-out infinite;
}

.voice-bars {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.voice-bars span {
  width: 8px;
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(to top, #0eb6f2, #8ef8ff);
  transform-origin: bottom;
  animation: idlebar 1.1s ease-in-out infinite;
  opacity: 0.5;
}

.voice-bars span:nth-child(2) { animation-delay: 0.1s; }
.voice-bars span:nth-child(3) { animation-delay: 0.2s; }
.voice-bars span:nth-child(4) { animation-delay: 0.3s; }
.voice-bars span:nth-child(5) { animation-delay: 0.4s; }

.hologram-stage.speaking .voice-bars span,
.hologram-stage.listening .voice-bars span {
  opacity: 1;
  animation-duration: 0.35s;
}

.hologram-stage.thinking .core-ring {
  animation-duration: 1.3s;
}

.state-dot {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8ba9cf;
}

.state-dot.online { background: #66ffb3; box-shadow: 0 0 12px rgba(102, 255, 179, 0.8); }
.state-dot.busy { background: #31d7ff; box-shadow: 0 0 12px rgba(49, 215, 255, 0.8); }
.state-dot.error { background: var(--danger); box-shadow: 0 0 12px rgba(255, 123, 138, 0.8); }

.state-text {
  margin-top: 10px;
  color: var(--text-sub);
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-sub);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(114, 171, 255, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-main);
  background: rgba(9, 25, 45, 0.78);
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  color: #04152b;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.btn-secondary {
  color: var(--text-main);
  background: rgba(31, 58, 93, 0.9);
}

.btn-accent {
  color: #051b31;
  background: linear-gradient(120deg, #9df5ff, #31d7ff);
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  color: var(--text-sub);
  font-size: 13px;
}

.toggle input {
  width: auto;
}

.vision-panel {
  margin-top: 14px;
  border: 1px solid rgba(121, 187, 255, 0.25);
  background: rgba(7, 21, 38, 0.55);
  border-radius: 12px;
  padding: 12px;
}

.vision-panel h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.vision-actions {
  margin-top: 10px;
}

.vision-preview {
  display: none;
  width: 100%;
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid rgba(121, 187, 255, 0.35);
  max-height: 160px;
  object-fit: cover;
}

.vision-preview.show {
  display: block;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 680px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

#presence {
  font-size: 12px;
  color: var(--text-sub);
}

.chat-log {
  flex: 1;
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  color: #07203b;
  background: linear-gradient(120deg, #8fe8ff, #6effc5);
}

.msg.assistant {
  align-self: flex-start;
  border: 1px solid rgba(121, 187, 255, 0.35);
  background: rgba(11, 35, 63, 0.86);
}

.msg.system {
  align-self: center;
  color: #a7bfdc;
  font-size: 12px;
  border: 1px dashed rgba(121, 187, 255, 0.32);
  background: rgba(7, 21, 38, 0.7);
}

.composer {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(4, 16, 31, 0.66);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 520px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes idlebar {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1); }
}
