:root {
  --surface: #e6eaf2;
  --surface-light: #ffffff;
  --surface-dark: #aeb7c9;
  --text: #333a47;
  --text-muted: #6b7386;
  --accent: #c9803d;
  --accent-glow: rgba(201, 128, 61, 0.35);
  --radius-md: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text);
  padding: 24px;
}

.panel {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  height: min(720px, 88vh);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 20px;
}

.panel__title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: inset 3px 3px 6px var(--surface-dark), inset -3px -3px 6px var(--surface-light);
}

.status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s ease;
}
.status__dot[data-state="ready"] { background: #5f9c76; }
.status__dot[data-state="thinking"] { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.status__dot[data-state="idle"] { background: #c0685f; }

.status__label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 6px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-dark) transparent;
}
.log::-webkit-scrollbar { width: 6px; }
.log::-webkit-scrollbar-thumb { background: var(--surface-dark); border-radius: 8px; }

.msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fade-in 0.25s ease;
}
.msg-wrap--user { align-self: flex-end; align-items: flex-end; }
.msg-wrap--assistant { align-self: flex-start; align-items: flex-start; }

.msg-sender {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 6px 6px;
}

.msg {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg--assistant {
  border-top-left-radius: 4px;
  box-shadow: inset 4px 4px 8px var(--surface-dark), inset -4px -4px 8px var(--surface-light);
}
.msg--user {
  border-top-right-radius: 4px;
  box-shadow: 4px 4px 8px var(--surface-dark), -4px -4px 8px var(--surface-light);
}

.msg--thinking { display: flex; gap: 5px; padding: 16px 18px; }
.msg--thinking span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s ease-in-out infinite;
}
.msg--thinking span:nth-child(2) { animation-delay: 0.15s; }
.msg--thinking span:nth-child(3) { animation-delay: 0.3s; }

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

.msg-system {
  align-self: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 14px;
  max-width: 90%;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.composer__input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.92rem;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  max-height: 160px;
  box-shadow: inset 4px 4px 8px var(--surface-dark), inset -4px -4px 8px var(--surface-light);
  transition: box-shadow 0.2s ease;
}
.composer__input:focus {
  box-shadow: inset 4px 4px 8px var(--surface-dark), inset -4px -4px 8px var(--surface-light), 0 0 0 2px var(--accent-glow);
}

.composer__send {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 5px 5px 10px var(--surface-dark), -5px -5px 10px var(--surface-light);
  transition: box-shadow 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.composer__send:hover:not(:disabled) { color: var(--accent); }
.composer__send:active:not(:disabled) {
  box-shadow: inset 3px 3px 6px var(--surface-dark), inset -3px -3px 6px var(--surface-light);
  transform: scale(0.97);
}
.composer__send:disabled { opacity: 0.45; cursor: default; }

.composer__send:focus-visible,
.composer__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  body { padding: 12px; }
  .panel { height: 94vh; }
  .msg-wrap { max-width: 92%; }
}

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