:root {
  --bg: #0f1720;
  --panel: #182231;
  --panel-2: #1f2c3d;
  --border: #2a3a4f;
  --text: #e8edf3;
  --text-dim: #93a3b8;
  --accent: #4f8cff;
  --accent-dim: #2c4a7c;
  --buyer-bubble: #24344a;
  --rep-bubble: #2c4a7c;
  --danger: #d9534f;
  --good: #3ba55d;
  --warning: #d9a53d;
}

* { box-sizing: border-box; }

/* ---- Brand logo ---- */
/* The source file has a white background — on this dark theme it reads as
   an intentional light chip (like most dark-themed apps show their logo)
   rather than a stray white rectangle, rounded to match the card style
   used everywhere else. */

.brand-logo {
  display: inline-block;
  border-radius: 8px;
  background: #fff;
  padding: 4px 8px;
}

.login-logo-wrap {
  text-align: center;
  margin-bottom: 8px;
}

.login-logo {
  height: 44px;
}

.header-logo {
  height: 30px;
  flex: 0 0 auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---- Login ---- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.5;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 20px;
}

.dashboard-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
}

.dashboard-link:hover {
  color: var(--accent);
}

.login-card label.mt {
  margin-top: 14px;
}

.flash {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.flash.error {
  background: rgba(217, 83, 79, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.flash.success {
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent);
}

.inline-form {
  margin-top: 12px;
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent);
}

.login-card button,
.send-form button,
.end-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.login-card button {
  width: 100%;
  padding: 12px;
}

.login-card button:hover,
.send-form button:hover {
  filter: brightness(1.1);
}

/* ---- Chat ---- */

.chat-wrap {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.chat-header h1 {
  font-size: 18px;
  margin: 0;
}

.actor-id {
  font-size: 12px;
  color: var(--text-dim);
}

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

.end-btn {
  background: var(--danger);
  white-space: nowrap;
}

.voice-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.voice-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.voice-toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.rep {
  align-self: flex-end;
  background: var(--rep-bubble);
  border-bottom-right-radius: 2px;
}

.msg.buyer {
  align-self: flex-start;
  background: var(--buyer-bubble);
  border-bottom-left-radius: 2px;
}

.msg.system {
  align-self: center;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 13px;
  max-width: 90%;
  text-align: center;
}

.msg.report {
  align-self: stretch;
  max-width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--accent-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.msg.error {
  align-self: center;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
}

.msg.pending {
  align-self: flex-start;
  color: var(--text-dim);
  font-style: italic;
  background: transparent;
}

.send-form {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.send-form input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
}

.send-form input:disabled,
.send-form button:disabled,
.end-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-form .mic-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 44px;
  flex: 0 0 44px;
  font-size: 18px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.mic-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.mic-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --panel-2: #f0f3f7;
    --border: #dde3ea;
    --text: #1a2432;
    --text-dim: #6b7a8f;
    --buyer-bubble: #eef1f5;
    --rep-bubble: #dbe7ff;
    --accent-dim: #cfe0ff;
  }
}
