:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #182033;
  --muted: #63708a;
  --line: #dce3ef;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --accent: #00a383;
  --danger: #d14343;
  --shadow: 0 20px 60px rgba(31, 45, 78, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 32rem),
    linear-gradient(135deg, #f8fbff 0%, var(--bg) 52%, #edf6f3 100%);
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 24px;
  align-items: stretch;
}

.robot-panel,
.chat-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(220, 227, 239, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.robot-panel {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}

.robot-avatar {
  width: 156px;
  height: 178px;
  margin: 0 auto;
  position: relative;
}

.antenna {
  width: 4px;
  height: 30px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 999px;
  position: relative;
}

.antenna::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
}

.robot-head {
  height: 132px;
  margin-top: 10px;
  border: 4px solid var(--text);
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.88), rgba(226, 235, 255, 0.8)),
    #e9efff;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  position: relative;
}

.eye {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 7px rgba(37, 99, 235, 0.12);
}

.mouth {
  width: 56px;
  height: 10px;
  border-radius: 999px;
  background: var(--text);
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
}

.title-group {
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-text {
  min-height: 1.5em;
  margin-bottom: 0;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 0.55fr 0.55fr;
  gap: 10px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  color: #ffffff;
  background: var(--brand);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  color: var(--text);
  background: #eef3fb;
  border: 1px solid var(--line);
}

.secondary-button.active {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.voice-picker {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 46px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.chat-panel {
  min-height: 640px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.thinking-badge {
  color: var(--brand-dark);
  background: rgba(37, 99, 235, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.83rem;
  font-weight: 800;
}

.hidden {
  display: none;
}

.chat-log {
  flex: 1;
  min-height: 0;
  padding: 18px 2px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message {
  width: min(88%, 560px);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.5;
}

.message p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.message-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
}

.user-message {
  align-self: flex-end;
  color: #ffffff;
  background: var(--brand);
}

.user-message .message-label {
  color: rgba(255, 255, 255, 0.78);
}

.ai-message {
  align-self: flex-start;
  background: #eef3fb;
  border: 1px solid var(--line);
}

.error-message {
  align-self: center;
  width: 100%;
  color: #7a1f1f;
  background: #fff1f1;
  border: 1px solid #ffd4d4;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 620px);
    min-height: auto;
    padding: 24px 0;
    grid-template-columns: 1fr;
  }

  .robot-panel {
    padding: 24px;
  }

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

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

  .message {
    width: 96%;
  }
}
