:root {
  --bg: #f6f8f4;
  --surface: #ffffff;
  --surface-soft: #eef5ef;
  --ink: #17313a;
  --muted: #637174;
  --line: #cbd8d2;
  --teal: #2d6f6b;
  --teal-dark: #1d504d;
  --coral: #c95b4b;
  --gold: #c59d32;
  --danger: #a33131;
  --shadow: 0 18px 50px rgba(23, 49, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
a {
  font: inherit;
}

button,
.call-link {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  gap: 0.55rem;
  justify-content: center;
  min-height: 48px;
  padding: 0.8rem 1rem;
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover,
.call-link:hover {
  border-color: var(--teal);
  box-shadow: 0 8px 24px rgba(45, 111, 107, 0.13);
}

button:active,
.call-link:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.call-link:focus-visible {
  outline: 3px solid rgba(197, 157, 50, 0.55);
  outline-offset: 2px;
}

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

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 1240px;
  width: 100%;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.avatar {
  align-items: center;
  background: var(--teal);
  border: 3px solid #d8ede6;
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  flex: 0 0 auto;
  font-size: 2rem;
  font-weight: 800;
  height: 70px;
  justify-content: center;
  width: 70px;
}

.kicker {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0 0 2px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.status-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--teal-dark);
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  white-space: nowrap;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 340px;
  margin: 0 auto;
  max-width: 1240px;
  width: 100%;
}

.conversation-panel,
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.conversation-panel {
  display: grid;
  gap: 18px;
  grid-template-rows: minmax(180px, 1fr) auto auto auto auto;
  min-height: calc(100vh - 138px);
  padding: 20px;
}

.conversation {
  align-content: start;
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 4px;
}

.message {
  border-radius: 8px;
  line-height: 1.5;
  max-width: min(680px, 100%);
  padding: 1rem 1.1rem;
}

.message.assistant {
  background: var(--surface-soft);
  border: 1px solid #d9e8dc;
  justify-self: start;
}

.message.user {
  background: #f8eee9;
  border: 1px solid #efd3c8;
  justify-self: end;
}

.message-meta {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.voice-stage {
  align-items: center;
  background: #f7fbf8;
  border: 1px solid #dbe8dd;
  border-radius: 8px;
  display: flex;
  gap: 16px;
  min-height: 88px;
  padding: 16px;
}

.voice-mark {
  align-items: end;
  border: 2px solid rgba(45, 111, 107, 0.3);
  border-radius: 50%;
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  height: 56px;
  justify-content: center;
  padding: 14px;
  width: 56px;
}

.voice-mark span {
  background: var(--teal);
  border-radius: 4px;
  display: block;
  height: 12px;
  width: 5px;
}

.voice-mark span:nth-child(2) {
  height: 20px;
}

.voice-mark span:nth-child(3) {
  height: 28px;
}

.voice-mark.listening span {
  animation: voicePulse 840ms ease-in-out infinite;
}

.voice-mark.speaking {
  border-color: rgba(201, 91, 75, 0.35);
}

.voice-mark.speaking span {
  animation: voicePulse 760ms ease-in-out infinite;
  background: var(--coral);
}

.voice-mark.listening span:nth-child(2) {
  animation-delay: 120ms;
}

.voice-mark.listening span:nth-child(3) {
  animation-delay: 240ms;
}

.voice-mark.listening span:nth-child(4) {
  animation-delay: 360ms;
}

@keyframes voicePulse {
  0%,
  100% {
    transform: scaleY(0.6);
  }
  50% {
    transform: scaleY(1.22);
  }
}

.stage-label {
  font-size: 1.35rem;
  font-weight: 800;
}

.stage-copy {
  color: var(--muted);
  margin-top: 4px;
}

.text-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.music-panel {
  background: #fbfdfb;
  border: 1px solid #dbe8dd;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.music-header,
.music-now-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
}

.music-actions,
.music-now-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.music-status {
  background: #f1f7f5;
  border: 1px solid #d7e6df;
  border-radius: 999px;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.music-search-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.music-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.music-quick-row button,
.music-actions button,
.music-now-actions button,
.music-result button {
  min-height: 38px;
  padding: 0.55rem 0.7rem;
}

.music-player-shell {
  aspect-ratio: 16 / 9;
  background: #17313a;
  border: 1px solid #cbd8d2;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.music-player-shell iframe {
  border: 0;
  display: block;
  height: 100%;
  width: 100%;
}

.music-now-row {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.music-now-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-now-row a {
  color: var(--teal-dark);
  flex: 0 0 auto;
  font-weight: 800;
}

.music-results {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.music-result {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dfe8e2;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  min-height: 70px;
  padding: 8px;
}

.music-result img {
  aspect-ratio: 16 / 9;
  background: #e8f0ec;
  border-radius: 6px;
  object-fit: cover;
  width: 72px;
}

.music-result-title {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-result-channel {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input,
select {
  background: #fbfdfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 46px;
  padding: 0.75rem 0.85rem;
  width: 100%;
}

.control-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(150px, 1.4fr) minmax(120px, 1fr) minmax(120px, 1fr);
}

.primary-action {
  background: var(--teal);
  border-color: var(--teal-dark);
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 800;
  min-height: 64px;
}

.button-symbol {
  display: inline-block;
  font-size: 1rem;
  line-height: 1;
  min-width: 1rem;
}

.call-link[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.side-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.panel-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 6px;
}

.split-fields {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.toggle-line {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 8px;
  min-height: 46px;
}

.toggle-line input {
  height: 20px;
  min-height: 20px;
  width: 20px;
}

.voice-provider {
  background: #f1f7f5;
  border: 1px solid #d7e6df;
  border-radius: 8px;
  color: var(--teal-dark);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
  padding: 0.8rem;
}

.memory-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.memory-item {
  background: #fbfdfb;
  border: 1px solid #dde8e0;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.35;
  padding: 0.8rem;
}

.memory-item small {
  color: var(--muted);
  display: block;
  font-weight: 700;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.safety-strip {
  align-self: end;
  background: #fff6f3;
  border: 1px solid #efc9bf;
  border-left: 4px solid var(--coral);
  border-radius: 8px;
  color: #653328;
  display: grid;
  gap: 4px;
  line-height: 1.35;
  padding: 0.85rem;
}

.danger {
  color: var(--danger);
}

@media (max-width: 920px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

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

  .conversation-panel {
    min-height: auto;
  }

}

@media (max-width: 620px) {
  .topbar,
  .brand {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .avatar {
    height: 58px;
    width: 58px;
  }

  .text-row,
  .music-search-row,
  .music-result,
  .control-row,
  .split-fields {
    grid-template-columns: 1fr;
  }

  .music-header,
  .music-now-row {
    align-items: stretch;
    flex-direction: column;
  }

  .music-actions,
  .music-now-actions {
    justify-content: space-between;
    width: 100%;
  }

  .music-result img {
    width: 100%;
  }

  .primary-action {
    min-height: 60px;
  }
}
