:root {
  color: #17201e;
  background: #f3f6f5;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --line: #dce4e1;
  --text: #17201e;
  --muted: #67736f;
  --accent: #16856b;
  --accent-soft: #e2f2ec;
  --live: #e75a4a;
  --warning: #b66a17;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  height: 100dvh;
}

.auth-screen {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
  padding: 28px 18px;
  background:
    linear-gradient(90deg, #eef4f1 0 34%, #f7f9f8 34% 100%);
}

.auth-panel {
  width: min(400px, 100%);
  padding: 34px 32px 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(27, 44, 39, 0.12);
}

.auth-brand {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-panel h1 {
  margin: 8px 0 6px;
  font-size: 23px;
  line-height: 1.35;
}

.auth-subtitle {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 9px;
}

.auth-form label {
  margin-top: 5px;
  color: #3f4d49;
  font-size: 12px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #aebbb7;
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
  letter-spacing: 0;
}

.auth-form input:focus {
  outline: 3px solid rgba(22, 133, 107, 0.16);
  border-color: var(--accent);
}

.auth-form input:disabled {
  background: #f1f4f3;
  cursor: not-allowed;
}

.sms-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.primary-button,
.secondary-button {
  height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  margin-top: 12px;
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover:not(:disabled) {
  background: #0e715a;
}

.secondary-button {
  border: 1px solid #aebbb7;
  color: #31403c;
  background: #eef4f1;
}

.secondary-button:hover:not(:disabled) {
  background: #dfeae6;
}

.primary-button:disabled,
.secondary-button:disabled {
  border-color: var(--line);
  color: #8f9996;
  background: #e6ebe9;
  cursor: not-allowed;
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.auth-message.error {
  color: #b83c31;
}

.auth-message.success {
  color: #0f765e;
}

button {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button:focus-visible {
  outline: 3px solid rgba(22, 133, 107, 0.24);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(420px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: #eef4f1;
}

.brand-row {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 8px 20px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: #4c5b56;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover,
.nav-item.active {
  color: #0f6f59;
  background: #dcebe5;
}

.sidebar-meta {
  margin-top: auto;
  padding: 14px 10px 2px;
  border-top: 1px solid #d5e0dc;
}

.meta-label {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.credential-row,
.connection-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #43514d;
  font-size: 12px;
}

.meta-detail {
  min-height: 18px;
  margin: 6px 0 0 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ba7a3;
}

.status-dot.ready {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 133, 107, 0.12);
}

.status-dot.live {
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(231, 90, 74, 0.14);
}

.status-dot.error {
  background: var(--warning);
}

.conversation {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 220px;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

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

.title-block h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.title-block .connection-label {
  margin-top: 5px;
}

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

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-muted);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.messages {
  position: relative;
  height: 100%;
  min-height: 0;
  padding: 26px clamp(20px, 5vw, 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: #fbfcfc;
}

.empty-state {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 100%;
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

.empty-state h2 {
  margin: 0 0 7px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  width: min(760px, 100%);
  margin: 0 auto 18px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.message-content {
  min-width: 0;
  max-width: min(620px, 100%);
}

.message-meta {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
}

.user .message-meta {
  text-align: right;
}

.message-bubble {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.user .message-bubble {
  border-color: #bcded1;
  background: var(--accent-soft);
}

.system-message {
  width: fit-content;
  max-width: 90%;
  margin: 10px auto 18px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 11px;
  text-align: center;
}

.voice-dock {
  display: grid;
  grid-template-rows: 42px 50px 66px 18px;
  gap: 3px;
  align-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 10px 24px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.text-composer {
  display: flex;
  gap: 8px;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 1px;
}

.text-composer input {
  min-width: 0;
  flex: 1 1 auto;
  height: 40px;
  padding: 0 13px;
  border: 1px solid #aebbb7;
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0;
}

.text-composer input:focus {
  outline: 3px solid rgba(22, 133, 107, 0.16);
  border-color: var(--accent);
}

.text-composer input:disabled {
  color: #8f9996;
  background: #f1f4f3;
  cursor: not-allowed;
}

.text-composer input::placeholder {
  color: #6f7c78;
  opacity: 1;
}

.send-button {
  width: 40px;
  height: 40px;
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.send-button:hover:not(:disabled) {
  background: #0e715a;
}

.send-button:disabled {
  border-color: var(--line);
  color: #8f9996;
  background: #e0e6e4;
  cursor: not-allowed;
}

#waveform {
  width: 100%;
  height: 50px;
}

.voice-controls {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  align-items: center;
}

.timer {
  justify-self: end;
  margin-right: 24px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.mic-button {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(22, 133, 107, 0.2);
  cursor: pointer;
}

.mic-button:hover:not(:disabled) {
  background: #0e715a;
}

.mic-button.recording {
  background: var(--live);
  box-shadow: 0 8px 20px rgba(231, 90, 74, 0.22);
}

.mic-button.recording svg {
  fill: currentColor;
}

.mic-button:disabled {
  color: #8f9996;
  background: #e0e6e4;
  box-shadow: none;
  cursor: not-allowed;
}

.mic-button svg {
  width: 25px;
  height: 25px;
}

.audio-button {
  justify-self: start;
  margin-left: 24px;
}

.audio-button.muted {
  color: var(--live);
}

.codec-status {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 6px;
  color: #ffffff;
  background: #26322f;
  box-shadow: 0 10px 24px rgba(20, 30, 27, 0.2);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px minmax(420px, 1fr);
  }

}

@media (max-width: 720px) {
  .auth-screen {
    place-items: start center;
    padding-top: max(42px, 10vh);
    background: #f3f6f5;
  }

  .auth-panel {
    padding: 28px 22px 24px;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .conversation {
    grid-template-rows: 64px minmax(0, 1fr) 214px;
  }

  .topbar {
    padding: 0 14px;
  }

  .title-block h1 {
    font-size: 15px;
  }

  .messages {
    padding: 20px 14px;
  }

  .voice-dock {
    padding-inline: 14px;
  }
}
