:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #ffd600;
  --panel: #ffffff;
  --text: #111111;
  --muted: #5f5f5f;
  --accent: #ffd600;
  --accent-strong: #e7c300;
  --line: #000000;
  --danger: #d84b4b;
  --assistant: #ffffff;
  --user: #ffd600;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  font-family: "Plus Jakarta Sans", Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
}

.container {
  width: min(1280px, 96vw);
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 14px 18px;
}

.header-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 36px;
  height: 36px;
  flex: none;
  border: 2px solid var(--line);
  background: var(--accent);
}

.header-main h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 2px;
  white-space: nowrap;
}

.subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.settings-toggle {
  width: auto;
  min-width: 96px;
  height: 40px;
  min-height: 40px;
  flex: none;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 700;
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.settings-toggle:hover:not(:disabled) {
  background: #f3f3f3;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 14px;
  margin: 14px 0;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.settings-panel {
  display: grid;
  gap: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-section {
  display: grid;
  gap: 12px;
  align-content: start;
}

.settings-section h2 {
  font-size: 1rem;
  font-weight: 800;
}

.settings-note {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.settings-test-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-actions .btn {
  width: auto;
  min-width: 160px;
  padding-inline: 18px;
}

.settings-status {
  min-height: 1.2em;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.settings-status.error {
  color: var(--danger);
}

.input-group {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.input-group span {
  font-weight: 700;
}

input,
select,
textarea,
button {
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
}

input[type="password"] {
  letter-spacing: 0.04em;
}

input[type="password"]::placeholder {
  letter-spacing: normal;
}

select {
  width: 100%;
  min-width: 0;
  background: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

button {
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

button:hover:not(:disabled) {
  background: #f3f3f3;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  width: 100%;
  font-weight: 700;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-danger {
  background: #ffffff;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
}

.btn-secondary {
  background: #ffffff;
}

.text-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 10px;
  align-items: end;
}

.text-chat-input textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  line-height: 1.5;
}

.chat-container {
  min-height: 400px;
  max-height: 55vh;
  overflow-y: auto;
  background: #ffffff;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: min(80%, 680px);
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 0;
  line-height: 1.6;
  animation: fadeIn 0.2s ease;
  font-size: 0.95rem;
}

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

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
}

.message.system {
  align-self: center;
  max-width: 92%;
  text-align: center;
  color: var(--muted);
  background: #ffffff;
  border-style: dashed;
}

.status-bar {
  display: grid;
  gap: 8px;
  justify-items: center;
  background: var(--accent);
}

#status-text {
  font-weight: 800;
  font-size: 1rem;
}

#status-text.recording {
  color: var(--danger);
  animation: pulse 1s infinite;
}

.proxy-latency-text,
.latency-text {
  color: rgba(0, 0, 0, 0.72);
  font-size: 0.86rem;
  font-weight: 600;
  min-height: 1.2em;
  text-align: center;
}

.realtime-text {
  min-height: 72px;
  background: #ffffff;
  line-height: 1.65;
  font-weight: 600;
  font-size: 0.95rem;
}

.realtime-text:empty {
  display: none;
}

.chat-container::-webkit-scrollbar {
  width: 10px;
}

.chat-container::-webkit-scrollbar-track {
  background: #ffffff;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #111111;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@media (max-width: 980px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .settings-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-actions .btn {
    width: 100%;
  }

  .settings-toggle {
    width: 48px;
    height: 48px;
    min-height: 48px;
  }

  header {
    align-items: flex-start;
  }

  .header-main {
    min-width: 0;
  }

  body {
    padding: 12px;
  }

  header {
    padding: 16px;
    align-items: flex-start;
  }

  header::before {
    width: 40px;
    height: 40px;
  }

  .controls,
  .text-chat {
    grid-template-columns: 1fr;
  }

  .input-group,
  select,
  .btn {
    width: 100%;
  }

  .chat-container {
    max-height: none;
    min-height: 380px;
  }

  .message {
    max-width: 94%;
  }
}
