


* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color: #0f172a;
  background: #f5f7fb;
}


.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px;
}

.chat-window {
  width: 100%;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}


.chat-header {
  background: #0b5f49;
  color: #ffffff;
  padding: 18px 22px;
}

.header-content h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
}

.header-content p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}


.chat-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px;
  min-height: 380px;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  background: #f9fbff;
}


.msg {
  max-width: 78%;
  border-radius: 14px;
  padding: 12px 14px;
  line-height: 1.4;
  font-size: 15px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
  word-wrap: break-word;
}

.msg.assistant {
  align-self: flex-start;
  background: #eaf2ff;
  color: #0f172a;
  border-top-left-radius: 4px;
}

.msg.user {
  align-self: flex-end;
  background: #e8f5ef;
  color: #0f172a;
  border-top-right-radius: 4px;
}


.msg.assistant.human-operator,
.msg.assistant[data-source="human_operator"] {
  align-self: flex-end;
  background: #e8f5ef;
  color: #0f172a;
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}


.policy-card { align-self: stretch; }

.policy-details {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.04);
}

.policy-summary {
  cursor: pointer;
  font-weight: 700;
  color: #0b5f49;
  list-style: none;
}

.policy-summary::-webkit-details-marker { display: none; }

.policy-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transform: translateY(-1px);
}

.policy-details[open] .policy-summary::before { content: "▾"; }

.policy-desc {
  margin: 8px 0 0 22px;
  color: #334155;
  font-size: 14px;
  line-height: 1.4;
}

.policy-desc strong { font-weight: 600; }


.chat-form {
  border-top: 1px solid #e6eaf0;
  background: #ffffff;
  padding: 14px;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  resize: vertical;
  border: 1px solid #dfe3ea;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  background: #fff;
}

#user-input:focus {
  border-color: #0b5f49;
  box-shadow: 0 0 0 3px rgba(11,95,73,0.12);
}


.btn {
  flex: 0 0 auto;
  height: 44px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}


#send-btn {
  width: 44px;
  background: #0b5f49;
  color: #fff;
}
#send-btn:hover { filter: brightness(1.05); }

#send-btn svg {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}


.takeover-panel {
  padding: 12px 22px;
  border-bottom: 1px solid #e6eaf0;
  background: #ffffff;
}

.takeover-status {
  border-left: 4px solid #0b5f49;
  background: #f3f8f6;
  border-radius: 8px;
  padding: 10px 12px;
  color: #334155;
}

.takeover-status strong {
  display: block;
  color: #0f172a;
  margin-bottom: 3px;
}

.takeover-status.error {
  border-left-color: #b91c1c;
  background: #fff5f5;
  color: #991b1b;
}

.takeover-claim {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.takeover-claim input {
  min-height: 44px;
  border: 1px solid #dfe3ea;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.takeover-claim .btn,
.takeover-actions .btn {
  padding: 0 16px;
  background: #0b5f49;
  color: #ffffff;
}

.takeover-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 14px 14px;
  background: #ffffff;
}

.takeover-actions .danger { background: #b91c1c; }

[hidden] { display: none !important; }


#rec-btn {
  width: 44px;
  background: #0f172a;
  color: #fff;
  position: relative;
}
#rec-btn:hover { filter: brightness(1.05); }

#rec-btn.recording { background: #b91c1c; }

#rec-btn.recording::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  position: absolute;
  top: 6px;
  right: 6px;
  animation: recPulse 1.05s ease-in-out infinite;
}

@keyframes recPulse {
  0%   { transform: scale(1);   opacity: 1; }
  50%  { transform: scale(1.5); opacity: .35; }
  100% { transform: scale(1);   opacity: 1; }
}


.audio-panel {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e6eaf0;
  border-radius: 12px;
  background: #fafcff;
}
.audio-panel[hidden] { display: none; }

.audio-panel .audio-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#audio-status {
  font-size: 13px;
  color: #334155;
}

#audio-preview {
  width: 100%;
  max-width: 520px;
}


.rec-live {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rec-live-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 13px;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #b91c1c;
  box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.4);
  animation: recPulseDot 1.1s ease-in-out infinite;
}

@keyframes recPulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.35); }
  70%  { box-shadow: 0 0 0 10px rgba(185, 28, 28, 0.0); }
  100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.0); }
}

.rec-elapsed {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 44px;
}

.rec-live-label { opacity: 0.9; }

.rec-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}

.rec-progress::-webkit-progress-bar {
  background: #e2e8f0;
  border-radius: 999px;
}
.rec-progress::-webkit-progress-value {
  background: #0b5f49;
  border-radius: 999px;
}
.rec-progress::-moz-progress-bar {
  background: #0b5f49;
  border-radius: 999px;
}

#audio-cancel-btn {
  background: #e2e8f0;
  color: #0f172a;
  padding: 0 12px;
}
#audio-cancel-btn:hover { filter: brightness(0.98); }

#audio-send-btn {
  background: #0b5f49;
  color: #fff;
  padding: 0 12px;
}
#audio-send-btn:hover { filter: brightness(1.05); }


.audio-panel.tour-demo {
  border-color: rgba(11,95,73,0.35);
  box-shadow: 0 0 0 3px rgba(11,95,73,0.12);
}


.chat-form.pending textarea,
.chat-form.pending button {
  opacity: .7;
  cursor: wait;
}

.chat-window.ended .chat-form { background: #fafafa; }

.chat-window.ended #user-input {
  background: #f2f2f2;
  color: #9a9a9a;
  border-color: #ddd;
  cursor: not-allowed;
}

.chat-window.ended #send-btn,
.chat-window.ended #rec-btn,
.chat-window.ended #audio-send-btn,
.chat-window.ended #audio-cancel-btn {
  background: #cfcfcf;
  cursor: not-allowed;
  pointer-events: none;
}


footer {
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
  color: #475569;
}
footer a { color: #0b5f49; text-decoration: none; }
footer a:hover { text-decoration: underline; }


@media (max-width: 480px) {
  .msg { max-width: 88%; }
  .chat-box { max-height: none; }

  .audio-panel {
    flex-direction: column;
    align-items: stretch;
  }

  #audio-preview { max-width: 100%; }

  .takeover-claim { grid-template-columns: 1fr; }
  .takeover-claim .btn { width: 100%; }
}


.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(6px);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 9999;
  max-width: min(560px, calc(100vw - 24px));
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


.tour-overlay[hidden] { display: none; }

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: auto;
}

.tour-dim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.tour-focus {
  position: fixed;
  border-radius: 16px;
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.95),
    0 0 0 9999px rgba(15,23,42,0.35);
  pointer-events: none;
  transition: all 180ms ease;
}

.tour-tip {
  position: fixed;
  width: min(420px, calc(100vw - 24px));
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 12px 12px 10px 12px;
  transform-origin: center;
  animation: tourPop 180ms ease;
  --tour-arrow-x: 32px;
}

@keyframes tourPop {
  from { transform: translateY(6px); opacity: 0.6; }
  to   { transform: translateY(0); opacity: 1; }
}

.tour-tip.above::after,
.tour-tip.below::after {
  content: "";
  position: absolute;
  left: var(--tour-arrow-x);
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-left: 1px solid rgba(15, 23, 42, 0.08);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  transform: rotate(45deg);
}

.tour-tip.above::after {
  bottom: -7px;
  border-left: none;
  border-top: none;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.tour-tip.below::after { top: -7px; }

.tour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tour-badge {
  font-size: 12px;
  font-weight: 700;
  color: #0b5f49;
  background: rgba(11, 95, 73, 0.10);
  padding: 4px 8px;
  border-radius: 999px;
}

.tour-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 10px;
  color: #0f172a;
}
.tour-close:hover { background: rgba(15,23,42,0.06); }

.tour-title {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 6px;
  color: #0f172a;
}

.tour-text {
  font-size: 14px;
  line-height: 1.45;
  color: #334155;
}

.tour-foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tour-progress {
  font-size: 12px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.tour-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 700;
  border: 1px solid rgba(15,23,42,0.12);
  cursor: pointer;
}

.tour-btn.secondary {
  background: #ffffff;
  color: #0f172a;
}
.tour-btn.secondary:hover { background: rgba(15,23,42,0.04); }

.tour-btn.primary {
  background: #0b5f49;
  border-color: #0b5f49;
  color: #ffffff;
}
.tour-btn.primary:hover { filter: brightness(1.05); }

.tour-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


.tour-replay-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,0.14);
  background: rgba(255,255,255,0.95);
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  z-index: 9000;
}

.tour-replay-btn:hover { filter: brightness(1.02); }
.tour-replay-btn:active { transform: translateY(1px); }
