:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.88);
  --ink: #17212b;
  --muted: #667085;
  --line: #d8e0e7;
  --primary: #1262a3;
  --primary-dark: #0b4779;
  --danger: #b42318;
  --danger-dark: #7a271a;
  --positive: #16803c;
  --warning-bg: #fff4d6;
  --warning-line: #e5b744;
  --shadow: 0 18px 50px rgba(22, 33, 43, 0.16);
}

:root[data-theme="dark"] {
  --bg: #0d1218;
  --surface: #151d26;
  --surface-soft: rgba(21, 29, 38, 0.9);
  --ink: #eef4f8;
  --muted: #9daab8;
  --line: #2c3947;
  --primary: #38a3ff;
  --primary-dark: #1f7fcc;
  --danger: #ff675d;
  --danger-dark: #d64238;
  --positive: #58d17a;
  --warning-bg: #312816;
  --warning-line: #ba8b2d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 20%, rgba(18, 98, 163, 0.14), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: Arial, "Noto Sans TC", sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

button,
textarea {
  font: inherit;
}

.voice-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.ambient-topbar,
.panel-heading,
.dashboard,
.actions,
.modal-header,
.modal-actions,
.order-summary {
  display: flex;
  align-items: center;
}

.ambient-topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
}

h2 {
  font-size: 20px;
}

.market-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

.theme-toggle {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.metric,
.order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric {
  flex: 1;
  min-height: 86px;
  padding: 16px;
}

.metric span,
.order-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 21px;
}

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

.voice-stage {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.assistant-orb {
  width: 188px;
  height: 188px;
  position: relative;
  display: grid;
  place-items: center;
}

.orb-core {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1262a3, #18a0a8);
  box-shadow: 0 22px 60px rgba(18, 98, 163, 0.28);
}

.orb-ring {
  position: absolute;
  inset: 18px;
  border: 2px solid rgba(18, 98, 163, 0.22);
  border-radius: 50%;
}

.assistant-orb.listening .orb-ring,
.assistant-orb.thinking .orb-ring {
  animation: pulse 1.5s ease-in-out infinite;
}

.assistant-orb.thinking .orb-core {
  background: linear-gradient(145deg, #7a4b00, #d68a00);
}

.assistant-orb.confirming .orb-core {
  background: linear-gradient(145deg, #b42318, #e35b4f);
}

@keyframes pulse {
  0% {
    transform: scale(0.88);
    opacity: 0.85;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

.voice-state {
  margin: 0;
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 800;
}

.voice-hint {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.talk-button {
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  padding: 0 26px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

.talk-button.listening {
  background: var(--danger);
}

.conversation-card,
.fallback-panel,
.quiet-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  backdrop-filter: blur(12px);
}

.conversation-card {
  padding: 18px;
  min-height: 150px;
}

.fallback-panel {
  margin-top: 14px;
  padding: 0;
}

.fallback-panel summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--muted);
  font-weight: 700;
}

.fallback-body {
  padding: 0 16px 16px;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.icon-button {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.18s ease, transform 0.18s ease;
}

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

.icon-button.listening {
  background: var(--danger);
  transform: scale(1.04);
}

.mic-dot {
  width: 18px;
  height: 24px;
  border: 3px solid #fff;
  border-radius: 12px;
  position: relative;
}

.mic-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 18px;
  height: 3px;
  background: #fff;
  transform: translateX(-50%);
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 98, 163, 0.12);
}

.actions,
.modal-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

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

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

.message-stack {
  display: grid;
  gap: 12px;
}

.message,
.empty-state,
.activity-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  line-height: 1.55;
}

.message.user {
  border-color: rgba(18, 98, 163, 0.28);
  background: #f3f8fc;
}

.message.ai {
  border-color: rgba(22, 128, 60, 0.24);
  background: #f5fbf7;
}

:root[data-theme="dark"] .message,
:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .activity-row {
  background: #101820;
}

:root[data-theme="dark"] .message.user {
  background: #102234;
}

:root[data-theme="dark"] .message.ai {
  background: #10251a;
}

.empty-state,
.muted {
  color: var(--muted);
}

.quiet-status {
  margin-top: 14px;
  display: flex;
  justify-content: space-around;
  gap: 12px;
  padding: 14px 16px;
}

.quiet-status div {
  min-width: 0;
}

.quiet-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 43, 0.52);
}

.hidden {
  display: none;
}

.order-card {
  width: min(560px, 100%);
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.order-summary {
  gap: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.side-badge {
  min-width: 72px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  text-align: center;
  font-weight: 800;
}

.side-badge.sell {
  background: var(--positive);
}

.order-summary p {
  margin: 5px 0 0;
  color: var(--muted);
}

.order-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.order-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.order-grid strong {
  font-size: 18px;
}

.risk-box {
  border: 1px solid var(--warning-line);
  border-radius: 8px;
  padding: 12px;
  background: var(--warning-bg);
  line-height: 1.5;
}

@media (max-width: 820px) {
  .ambient-topbar,
  .top-actions,
  .quiet-status {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric {
    width: 100%;
  }

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

  .voice-stage {
    min-height: 360px;
  }

  .assistant-orb {
    width: 160px;
    height: 160px;
  }
}
