:root {
  --bg-0: #080a0f;
  --bg-1: #0b0e14;
  --bg-2: #121722;
  --bg-3: #171d29;
  --border: #232b3a;
  --text: #e8ecf3;
  --text-dim: #9aa4b6;
  --text-faint: #6b7688;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --amber: #f5b24a;
  --green: #34d399;
  --red: #f87171;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #16202f 0%, transparent 60%),
    radial-gradient(900px 600px at 85% 110%, #101a24 0%, transparent 55%),
    var(--bg-0);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- header ---------- */
.topbar {
  text-align: center;
}

.brand {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ---------- device / ring ---------- */
.device {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 12px 0 4px;
}

.ring {
  position: relative;
  width: 176px;
  height: 176px;
  display: grid;
  place-items: center;
}

.ring__core {
  position: relative;
  z-index: 2;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #2b3649 0%, #141b28 68%);
  border: 1px solid #2b3547;
  box-shadow:
    inset 0 2px 14px rgba(0, 0, 0, 0.55),
    0 0 34px rgba(59, 130, 246, 0.14);
  transition: box-shadow 0.5s ease, border-color 0.5s ease;
}

.ring__pulse,
.ring__halo {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ring__pulse {
  inset: 0;
  border: 2px solid transparent;
  transition: border-color 0.4s ease;
}

.ring__halo {
  inset: 22px;
  border: 1px solid rgba(120, 140, 170, 0.12);
  transition: border-color 0.4s ease;
}

.ring[data-state="idle"] .ring__core {
  animation: idle-breathe 5s ease-in-out infinite;
}

.ring[data-state="listening"] .ring__core {
  border-color: rgba(59, 130, 246, 0.85);
  box-shadow:
    inset 0 2px 14px rgba(0, 0, 0, 0.55),
    0 0 46px rgba(59, 130, 246, 0.55);
  animation: breathe-blue 1.4s ease-in-out infinite;
}

.ring[data-state="listening"] .ring__pulse {
  border-color: rgba(59, 130, 246, 0.45);
  animation: ripple-blue 1.8s ease-out infinite;
}

.ring[data-state="speaking"] .ring__core {
  border-color: rgba(34, 211, 238, 0.85);
  box-shadow:
    inset 0 2px 14px rgba(0, 0, 0, 0.55),
    0 0 46px rgba(34, 211, 238, 0.5);
  animation: breathe-cyan 1.1s ease-in-out infinite;
}

.ring[data-state="speaking"] .ring__pulse {
  border-color: rgba(34, 211, 238, 0.4);
  animation: ripple-cyan 1.5s ease-out infinite;
}

.ring[data-state="thinking"] .ring__core {
  border-color: rgba(245, 178, 74, 0.85);
  box-shadow:
    inset 0 2px 14px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(245, 178, 74, 0.45);
  animation: breathe-amber 0.9s ease-in-out infinite;
}

.ring[data-state="thinking"] .ring__pulse {
  border-color: rgba(245, 178, 74, 0.4);
  animation: ripple-amber 1.3s ease-out infinite;
}

@keyframes idle-breathe {
  0%, 100% { box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 24px rgba(59, 130, 246, 0.1); }
  50% { box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 40px rgba(59, 130, 246, 0.22); }
}

@keyframes breathe-blue {
  0%, 100% { transform: scale(1); box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 30px rgba(59, 130, 246, 0.4); }
  50% { transform: scale(1.06); box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 60px rgba(59, 130, 246, 0.7); }
}

@keyframes breathe-cyan {
  0%, 100% { transform: scale(1); box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 28px rgba(34, 211, 238, 0.35); }
  50% { transform: scale(1.06); box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 58px rgba(34, 211, 238, 0.65); }
}

@keyframes breathe-amber {
  0%, 100% { transform: scale(1); box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 26px rgba(245, 178, 74, 0.3); }
  50% { transform: scale(1.05); box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.55), 0 0 52px rgba(245, 178, 74, 0.6); }
}

@keyframes ripple-blue {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes ripple-cyan {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes ripple-amber {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

.transcript {
  margin: 0;
  max-width: 34rem;
  text-align: center;
  font-size: clamp(1.25rem, 4.5vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  min-height: 3.4em;
  color: var(--text);
}

/* ---------- input ---------- */
.input {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 36rem;
  width: 100%;
  margin: 0 auto;
}

.input input[type="text"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input input[type="text"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.input input[type="text"]::placeholder {
  color: var(--text-faint);
}

.icon-button {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--text);
}

.icon-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

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

.icon-button--send {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.icon-button--send:hover:not(:disabled) {
  background: #2f6fe0;
  border-color: #2f6fe0;
  color: #fff;
}

.icon-button--active {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* ---------- chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.06);
}

.chip:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ---------- results ---------- */
.results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
}

.card-badge {
  flex: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.card-badge--high { color: var(--red); border-color: rgba(248, 113, 113, 0.4); }
.card-badge--medium { color: var(--amber); border-color: rgba(245, 178, 74, 0.4); }
.card-badge--low { color: var(--green); border-color: rgba(52, 211, 153, 0.4); }
.card-badge--none { display: none; }

.card-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-faint);
}

.card-source {
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-date::before {
  content: "\00B7";
  margin-right: 10px;
  color: var(--text-faint);
}

.card-field {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.card-field strong {
  color: var(--text);
  font-weight: 600;
}

.card-link {
  align-self: flex-start;
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.card-link:hover {
  border-color: var(--blue);
}

.empty-state {
  margin: 8px auto;
  max-width: 34rem;
  text-align: center;
  color: var(--text-dim);
  grid-column: 1 / -1;
  padding: 8px 16px;
}

.empty-state--error {
  color: var(--red);
}

/* ---------- MCP log ---------- */
.log {
  max-width: 36rem;
  width: 100%;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-1);
  overflow: hidden;
}

.log summary {
  cursor: pointer;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  user-select: none;
}

.log summary:hover {
  color: var(--text);
}

.log[open] summary {
  border-bottom: 1px solid var(--border);
}

.log__entries {
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.log-entry {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 16px;
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-method {
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.log-time {
  flex: none;
  color: var(--text-faint);
}

/* ---------- footer ---------- */
.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
  max-width: 42rem;
  margin: 0 auto;
  padding-top: 8px;
}

/* ---------- responsive ---------- */
@media (min-width: 720px) {
  .results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1080px) {
  .results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ring__core,
  .ring__pulse {
    animation: none !important;
  }
  .ring__core,
  .card,
  .icon-button,
  .chip,
  .input input[type="text"] {
    transition: none !important;
  }
}
