:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-soft: #f6f3f3;
  --ink: #17201d;
  --muted: #63716c;
  --line: #d8e1dd;
  --accent: #a52535;
  --accent-dark: #801c29;
  --gold: #d9a63a;
  --danger: #b3443d;
  --shadow: 0 20px 60px rgba(19, 32, 27, 0.12);
  font-family:
    Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body .info-panel[hidden], [hidden] { display: none !important; }
body .app-shell { grid-template-columns: minmax(0, 1fr); max-width: 1000px; }

body.training-mode .brandbar, body.training-mode .info-panel { display:none; }
body.training-mode .app-shell { display:block; width:100%; margin:0; }
body.training-mode .assistant-panel { height:100dvh; min-height:600px; border-radius:0; }
body.training-mode .topbar { padding:16px; }
body.training-mode .voice-card { padding:16px; }

* {
  box-sizing: border-box;
}

.brandbar { display:flex; align-items:center; justify-content:space-between; gap:24px; padding:20px max(24px, calc((100vw - 1280px) / 2)); background:#fff; border-bottom:1px solid #dedede; }
.brandbar img { display:block; object-fit:contain; max-width:100%; }
.brandbar a { color:#191919; text-decoration:none; font-weight:700; }
.brandbar small { display:block; font-size:12px; color:#686868; font-weight:400; margin-top:5px; }
.brandbar > span { color:#666; font-size:14px; }
body .app-shell { width:min(1280px, calc(100% - 48px)); grid-template-columns:minmax(0, 1fr) 340px; gap:32px; margin:24px auto; min-height:0; }
body .assistant-panel, body .info-panel { box-shadow:none; backdrop-filter:none; border:0; background:#fff; }
body .assistant-panel { height:calc(100dvh - 150px); min-height:620px; }
body .info-panel { height:calc(100dvh - 150px); min-height:620px; border-left:1px solid #e3e3e3; border-radius:0; }
body h1 { font-size:28px; letter-spacing:0; }
body .voice-card { background:#faf7f7; border:0; border-radius:0; }
body .voice-copy h2 { font-size:20px; }
body .mic-button { box-shadow:0 8px 24px rgba(165,37,53,.16); }
body .quick-replies { flex-wrap:nowrap; overflow-x:auto; flex-shrink:0; }
body .quick-replies button { flex-shrink:0; border-radius:6px; }
body .chat { min-height:180px; flex:1; }
body .message { font-size:16px; line-height:1.65; overflow-wrap:anywhere; }
body .message.assistant { background:#f5f5f5; border-color:#e8e8e8; }
body .message.user { background:#a52535; }
body .message a { display:block; color:#a52535; font-size:13px; margin-top:8px; }
body .composer input { min-width:0; }
body .info-panel h2 { font-size:18px; }
summary { cursor:pointer; font-size:14px; color:#666; }
.knowledge-section { padding:4px 0 18px; border-bottom:1px solid #e5e5e5; }
.knowledge-section > summary { font-size:18px; font-weight:600; color:#222; }
.knowledge-section[open] > summary { margin-bottom:16px; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline:3px solid #b79543; outline-offset:3px; }
@media(max-width:800px) {
  .brandbar { padding:16px; gap:12px; flex-wrap:wrap; }
  .brandbar img { width:160px; height:38px; }
  .brandbar > span { display:none; }
  .brandbar a { font-size:14px; }
  body .app-shell { width:100%; margin:0; display:flex; flex-direction:column; gap:0; }
  body .assistant-panel { min-height:580px; height:calc(100dvh - 88px); border-radius:0; }
  body .info-panel { height:auto; min-height:0; border:0; }
  body .topbar { padding:18px 16px; flex-wrap:wrap; gap:10px; }
  body h1 { font-size:24px; }
  body .composer { padding:14px; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.assistant-panel,
.info-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(216, 225, 221, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.assistant-panel {
  display: flex;
  flex-direction: column;
  min-height: 720px;
  border-radius: 8px;
  overflow: hidden;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-radius: 8px;
  padding: 24px;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
  letter-spacing: 0;
}

.status {
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  font-size: 14px;
}

.status.listening {
  border-color: rgba(15, 138, 95, 0.36);
  color: var(--accent-dark);
  background: #e9f8f2;
}

.voice-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 28px 24px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.voice-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.mic-button {
  position: relative;
  width: 96px;
  height: 96px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 34px rgba(15, 138, 95, 0.34);
  cursor: pointer;
}

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

.mic-button.recording {
  animation: pulse 1.2s infinite;
  background: var(--danger);
}

.stop-audio-button {
  min-width: 74px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--danger);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.stop-audio-button:hover:not(:disabled) {
  border-color: var(--danger);
  background: #fff4f4;
}

.stop-audio-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.mic-icon,
.mic-icon::before,
.mic-icon::after {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.mic-icon {
  top: 26px;
  width: 24px;
  height: 38px;
  border: 4px solid currentColor;
  border-radius: 18px;
}

.mic-icon::before {
  content: "";
  top: 34px;
  width: 44px;
  height: 24px;
  border: 4px solid currentColor;
  border-top: 0;
  border-radius: 0 0 24px 24px;
}

.mic-icon::after {
  content: "";
  top: 59px;
  width: 4px;
  height: 16px;
  background: currentColor;
  border-radius: 4px;
}

.voice-copy h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.voice-copy p {
  margin-bottom: 0;
  color: var(--muted);
}

.chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  overflow: auto;
}

.message {
  width: fit-content;
  max-width: min(620px, 88%);
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.45;
}

.message.assistant {
  align-self: flex-start;
  background: #edf4f1;
  border: 1px solid var(--line);
}

.message.user {
  align-self: flex-end;
  color: #fff;
  background: var(--accent);
}

.message .meta {
  display: block;
  margin-bottom: 5px;
  opacity: 0.72;
  font-size: 12px;
  font-weight: 700;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 24px 20px;
}

.quick-replies button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.quick-replies button:hover {
  border-color: rgba(15, 138, 95, 0.45);
  color: var(--accent-dark);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px;
  color: var(--ink);
  background: #fff;
}

.composer input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 138, 95, 0.16);
}

.composer button {
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.diagnostics {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
}

.diagnostic-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.diagnostic-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.diagnostic-actions button:hover {
  border-color: rgba(15, 138, 95, 0.45);
  color: var(--accent-dark);
}

#diagnosticsLog {
  width: 100%;
  min-height: 170px;
  max-height: 300px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #23302c;
  background: #f8fbfa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.data-card strong {
  display: block;
  margin-bottom: 6px;
}

.data-card p {
  margin-bottom: 4px;
  color: var(--muted);
  line-height: 1.38;
}

.feature-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  position: relative;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.35;
}

.feature-list li::before {
  content: "";
  position: absolute;
  top: 0.48em;
  left: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(179, 68, 61, 0.35);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(179, 68, 61, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(179, 68, 61, 0);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .assistant-panel {
    min-height: 680px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin: 10px auto;
  }

  .topbar,
  .voice-card,
  .chat,
  .composer,
  .info-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .voice-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .mic-button {
    width: 70px;
    height: 70px;
  }

  .mic-icon {
    top: 18px;
    width: 18px;
    height: 29px;
    border-width: 3px;
  }

  .mic-icon::before {
    top: 26px;
    width: 34px;
    height: 19px;
    border-width: 3px;
    border-top: 0;
  }

  .mic-icon::after {
    top: 45px;
    width: 3px;
    height: 11px;
  }

  .voice-copy h2 {
    font-size: 19px;
  }

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

  .composer button {
    min-height: 46px;
  }
}

body .app-shell { grid-template-columns: minmax(0, 1fr); }
.topbar, .voice-card, .composer { flex-shrink: 0; }
.topbar > div, .voice-copy { min-width: 0; overflow-wrap: anywhere; }
.composer input { font-size: 16px; }
.stop-audio-button { min-height: 44px; }
body h1 { line-height: 1.15; }
@media (max-width: 800px) {
  .brandbar { padding: 12px 16px; gap: 8px; }
  .brandbar img { width: 140px; height: 34px; }
  .brandbar a { font-size: 13px; }
  .brandbar small { font-size: 10px; }
  body .assistant-panel { height: auto; min-height: calc(100svh - 66px); }
  body .topbar { padding: 10px 16px; flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 10px; }
  body .topbar .eyebrow { display: none; }
  body h1 { font-size: 20px; }
  body .topbar .status { flex-shrink: 0; max-width: 105px; padding: 6px 8px; font-size: 11px; border-radius: 6px; }
  body .voice-card { padding: 20px 16px; }
  body .chat { min-height: 160px; max-height: 45svh; padding: 16px; }
  body .message { max-width: 96%; }
  body .composer { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .status { min-width: 0; max-width: 100%; }
  .quick-replies { padding-left: 16px; padding-right: 16px; }
}
