:root {
  --ink: #10161f;
  --panel: #1a2330;
  --line: #2c3a4d;
  --text: #e8eef6;
  --muted: #93a4b8;
  --amber: #f4b942;
  --amber-dim: #c4841a;
  --mint: #7ddec8;
  --danger: #ff7a7a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  font-family: Outfit, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, #243044 0%, transparent 55%),
    var(--ink);
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 100%;
  padding: 20px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.4rem; letter-spacing: 0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(160deg, var(--amber), #e07a2f);
  box-shadow: 0 0 24px rgba(244, 185, 66, 0.35);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: var(--mint);
}

.ghost, .icon-btn, .send, .chips button, .task-form button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
}

.ghost:hover, .chips button:hover, .icon-btn:hover { border-color: var(--amber); }

#task-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.4rem;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1204;
  font-size: 0.75rem;
  font-weight: 700;
}

.stage {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.companion, .chat-panel {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.companion {
  padding: 28px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.robot-wrap { text-align: center; }
.status {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.robot {
  width: 180px;
  margin: 0 auto;
  position: relative;
}

.antenna {
  height: 22px;
  display: flex;
  justify-content: center;
}
.antenna span {
  width: 6px;
  height: 22px;
  background: #6d7c8e;
  border-radius: 6px;
  position: relative;
}
.antenna span::after {
  content: "";
  position: absolute;
  top: -8px;
  left: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 12px var(--mint);
}

.head {
  background: linear-gradient(180deg, #f7c45a, #e89a28);
  border-radius: 28px 28px 22px 22px;
  padding: 18px 16px 14px;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,0.12);
}

.visor {
  background: #121820;
  border-radius: 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  padding: 0 10px;
}

.eye {
  width: 14px;
  height: 14px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--mint);
  animation: blink 5s infinite;
}

.mouth {
  width: 36px;
  height: 8px;
  margin: 12px auto 0;
  border-radius: 0 0 12px 12px;
  background: #7a4a12;
}

.torso {
  width: 110px;
  height: 70px;
  margin: 8px auto 0;
  background: linear-gradient(180deg, #3b4b60, #243040);
  border-radius: 16px 16px 22px 22px;
  display: grid;
  place-items: center;
}
.core {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff6, var(--amber));
  box-shadow: 0 0 16px var(--amber-dim);
}

.arms {
  position: absolute;
  inset: 86px 8px auto;
  display: flex;
  justify-content: space-between;
}
.arm {
  width: 14px;
  height: 54px;
  background: #314257;
  border-radius: 10px;
  transform-origin: top center;
}

.robot.listening .antenna span::after { background: var(--amber); animation: pulse 1s infinite; }
.robot.thinking .core { animation: spin 1.2s linear infinite; }
.robot.talking .mouth { animation: talk 0.28s ease-in-out infinite; }
.robot.happy .eye { height: 6px; border-radius: 8px; transform: translateY(3px); }

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94% { transform: scaleY(0.1); }
}
@keyframes talk {
  0%, 100% { height: 8px; }
  50% { height: 16px; border-radius: 8px; }
}
@keyframes pulse {
  50% { opacity: 0.4; }
}
@keyframes spin {
  to { transform: rotate(180deg); }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.chips button {
  background: #121820;
  font-size: 0.85rem;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 540px;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.bot {
  align-self: flex-start;
  background: #121820;
  border: 1px solid var(--line);
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(160deg, #f4b942, #e0892a);
  color: #1a1204;
}
.bubble .who {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 4px;
  font-family: "IBM Plex Mono", monospace;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit;
}
.composer input:focus { outline: 2px solid var(--amber); }
.send {
  background: var(--amber);
  color: #1a1204;
  border: 0;
  font-weight: 600;
}
.icon-btn {
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.icon-btn.active {
  background: var(--amber);
  color: #1a1204;
  border-color: var(--amber);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 20;
  padding: 20px;
  overflow: auto;
}
.backdrop {
  position: fixed;
  inset: 0;
  background: #0008;
  z-index: 15;
}
.drawer-head, .task-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.drawer-head { justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 1.15rem; }
.task-form { flex-wrap: wrap; }
.task-form input {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}
.task-form button {
  background: var(--amber);
  color: #1a1204;
  border: 0;
  font-weight: 600;
}

.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.task-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.task-list li.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-when { display: block; color: var(--muted); font-size: 0.8rem; font-family: "IBM Plex Mono", monospace; }
.task-list button.link {
  background: none;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
}

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .chat-panel { min-height: 420px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
