:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #11151d;
  --panel-soft: #171c26;
  --line: #252c39;
  --text: #f3f5f8;
  --muted: #99a2b2;
  --accent: #8b7cff;
  --accent-bright: #a99eff;
  --green: #4cdb9b;
  --red: #ff6b7b;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 5%, rgba(91, 70, 255, 0.2), transparent 30%),
    radial-gradient(circle at 90% 90%, rgba(37, 190, 140, 0.11), transparent 30%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: rgba(10, 13, 19, 0.86);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.19em;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 43px);
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.connection {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 13px;
  white-space: nowrap;
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #626c7e;
}

#status-dot[data-state="connecting"] {
  background: #f4bd4f;
  box-shadow: 0 0 12px rgba(244, 189, 79, 0.7);
}

#status-dot[data-state="online"] {
  background: var(--green);
  box-shadow: 0 0 12px rgba(76, 219, 155, 0.7);
}

#status-dot[data-state="error"] {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 18px;
  height: 530px;
  max-height: 530px;
  min-height: 0;
  overflow: hidden;
}

.video-panel,
.conversation-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.video-panel {
  position: relative;
  display: grid;
  height: 530px;
  max-height: 530px;
  min-height: 0;
  place-items: center;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #0c0f15;
  background-size: 28px 28px;
}

#preview {
  position: absolute;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

#preview:not(.active) {
  display: none;
}

.video-placeholder {
  color: #697386;
  text-align: center;
}

.video-placeholder span {
  display: inline-grid;
  width: 68px;
  height: 50px;
  margin-bottom: 12px;
  place-items: center;
  border: 1px solid #343c4b;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.video-placeholder p {
  margin: 0;
  font-size: 13px;
}

.video-badge {
  position: absolute;
  z-index: 3;
  right: 14px;
  bottom: 14px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  color: #dce1e9;
  background: rgba(7, 9, 13, 0.68);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
}

.conversation-panel {
  display: flex;
  height: 530px;
  max-height: 530px;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  contain: layout size;
}

.transcript {
  flex: 1 1 0;
  overflow-y: auto;
  width: 100%;
  height: 0;
  max-height: none;
  min-height: 0;
  padding: 20px;
  overscroll-behavior: contain;
}

.welcome {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
}

.welcome-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #6958ff, #a46dff);
}

.welcome h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.welcome p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 88%;
  margin: 18px 0;
}

.message.user {
  margin-left: auto;
  align-items: flex-end;
}

.message-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.message-content {
  overflow-wrap: anywhere;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px 13px 13px 4px;
  background: var(--panel-soft);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user .message-content {
  border-color: rgba(139, 124, 255, 0.38);
  border-radius: 13px 13px 4px 13px;
  background: rgba(109, 89, 255, 0.18);
}

.notice,
.error {
  margin: 12px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.error {
  color: #ff96a2;
}

.text-input {
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #0d1118;
}

.text-input input {
  min-width: 0;
  flex: 1;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: var(--panel-soft);
}

.text-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.12);
}

.text-input input:disabled {
  opacity: 0.55;
}

.send-button,
.primary-button,
.stop-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 120ms ease,
    opacity 120ms ease,
    background 120ms ease;
}

.send-button {
  padding: 0 16px;
  border-radius: 10px;
  color: #fff;
  background: #6859df;
}

.session-settings {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(320px, 1.25fr);
  gap: 12px;
  margin-top: 18px;
}

.setting-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 21, 29, 0.86);
}

.setting-field[hidden] {
  display: none;
}

.setting-label {
  color: #dfe3eb;
  font-size: 12px;
  font-weight: 750;
}

.setting-field select,
.setting-field input[type="file"] {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid #343c4b;
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: var(--panel-soft);
}

.setting-field select {
  padding: 0 11px;
}

.setting-field input[type="file"] {
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
}

.setting-field input[type="file"]::file-selector-button {
  height: 28px;
  margin-right: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: #6859df;
  cursor: pointer;
}

.setting-field select:focus,
.setting-field input[type="file"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.12);
}

.setting-field select:disabled,
.setting-field input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.setting-field small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
}

.camera-option {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.camera-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.button-group {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.primary-button,
.stop-button {
  min-height: 44px;
  padding: 0 19px;
  border-radius: 12px;
  font-weight: 700;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: white;
  background: linear-gradient(135deg, #6c5df0, #8d63ee);
  box-shadow: 0 8px 28px rgba(102, 80, 230, 0.25);
}

.mic-icon {
  position: relative;
  width: 11px;
  height: 16px;
  border: 2px solid white;
  border-radius: 7px;
}

.mic-icon::after {
  position: absolute;
  right: -5px;
  bottom: -5px;
  left: -5px;
  height: 8px;
  border: 2px solid white;
  border-top: 0;
  border-radius: 0 0 9px 9px;
  content: "";
}

.stop-button {
  border: 1px solid #3a4251;
  color: #d7dce5;
  background: #1b212c;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.privacy-note {
  justify-self: end;
  margin: 0;
  color: #6f7888;
  font-size: 11px;
}

@media (max-width: 850px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    margin: 10px auto;
    padding: 18px;
  }

  header,
  .controls {
    align-items: flex-start;
  }

  header {
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    max-height: none;
    overflow: visible;
  }

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

  .video-panel {
    height: min(70vw, 420px);
    max-height: 420px;
    min-height: 330px;
  }

  .conversation-panel {
    height: 420px;
    max-height: 420px;
    min-height: 0;
  }

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

  .button-group {
    grid-row: 1;
    justify-content: flex-start;
  }

  .privacy-note {
    justify-self: start;
  }
}
