* {
  box-sizing: border-box;
}

body {
  background: #101418;
  color: #f4f7f8;
  font-family: Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  padding: 24px 14px;
}

.app-shell {
  margin: 0 auto;
  max-width: 980px;
  width: 100%;
}

.app-header {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow {
  color: #7dd3fc;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 36px;
  line-height: 1.1;
  margin-bottom: 8px;
}

h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

p {
  color: #b9c4ce;
  line-height: 1.45;
}

.app-subtitle {
  margin-bottom: 0;
  max-width: 680px;
}

.mobile-steps {
  display: none;
}

.status-badge {
  background: #26303a;
  border: 1px solid #3d4a55;
  border-radius: 999px;
  color: #dbe6ee;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 12px;
}

.status-badge.connected {
  background: #12351f;
  border-color: #23663d;
  color: #9cf6bc;
}

.status-badge.error {
  background: #3a1717;
  border-color: #7f2a2a;
  color: #ffc6c6;
}

.panel {
  background: #1b2229;
  border: 1px solid #303b45;
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.26);
  margin-bottom: 14px;
  padding: 18px;
}

.hidden {
  display: none !important;
}

.section-header {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header p {
  margin-bottom: 0;
}

button {
  background: #00d4ff;
  border: 0;
  border-radius: 6px;
  color: #071014;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  min-height: 42px;
  padding: 10px 14px;
}

button:hover {
  background: #43e2ff;
}

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

input,
select {
  background: #11171d;
  border: 1px solid #3d4a55;
  border-radius: 6px;
  color: #f4f7f8;
  font-size: 15px;
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: #00d4ff;
  outline: 2px solid rgba(0, 212, 255, 0.2);
}

label {
  color: #d6e0e8;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
}

.candidate-list,
.groups-list {
  display: grid;
  gap: 10px;
}

.candidate-card,
.group-card {
  align-items: center;
  background: #222b33;
  border: 1px solid #35424d;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.candidate-main,
.group-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.group-main {
  flex: 1 1 auto;
}

.group-title-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.candidate-name,
.group-name {
  color: #f8fafc;
  display: block;
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.candidate-sub,
.group-sub,
.group-members {
  color: #aeb9c2;
  display: block;
  font-size: 13px;
  margin-top: 3px;
}

.group-members {
  color: #d6e0e8;
  overflow-wrap: anywhere;
}

.group-pill {
  background: #153d2b;
  border: 1px solid #2d8055;
  border-radius: 999px;
  color: #a9f5c8;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.group-pill.locked {
  background: #3a2b16;
  border-color: #8a6829;
  color: #ffd98a;
}

.empty-state,
.notice {
  background: #17222b;
  border: 1px solid #334756;
  border-radius: 8px;
  color: #c8d3dc;
  display: flex;
  flex-direction: column;
  gap: 5px;
  line-height: 1.45;
  padding: 12px;
}

.notice.danger {
  background: #3a1717;
  border-color: #7f2a2a;
  color: #ffc6c6;
}

.notice.subtle {
  background: #151d24;
  border-color: #293640;
  color: #afbac3;
  margin-top: 10px;
}

.command-pill {
  align-self: flex-start;
  background: #0d141a;
  border: 1px solid #3d4a55;
  border-radius: 6px;
  color: #f8fafc;
  font-family: monospace;
  font-size: 20px;
  letter-spacing: 0;
  padding: 8px 10px;
}

.button-row,
.group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.device-grid,
.control-grid,
.create-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.device-grid {
  margin-bottom: 14px;
}

.control-grid {
  align-items: end;
}

.mic-state,
.check-row {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 9px;
}

.check-row input {
  min-height: 0;
  width: auto;
}

#micIndicator {
  background: #4a5561;
  border-radius: 50%;
  display: inline-block;
  height: 13px;
  width: 13px;
}

#micIndicator.active {
  background: #41d173;
  box-shadow: 0 0 0 4px rgba(65, 209, 115, 0.15);
}

#muteBtn.unmuted {
  background: #41d173;
}

#muteBtn.muted,
#deafenBtn.active {
  background: #d64f4f;
  color: #fff;
}

.control-hint {
  color: #aeb9c2;
  line-height: 1.4;
}

.create-group {
  margin-top: 14px;
}

.create-group summary,
.debug-panel summary {
  color: #d6e0e8;
  cursor: pointer;
  font-weight: 800;
}

.create-grid {
  margin-top: 12px;
}

#log {
  background: #11171d;
  border: 1px solid #3d4a55;
  border-radius: 6px;
  color: #d6e0e8;
  font-family: monospace;
  font-size: 12px;
  height: 180px;
  margin: 10px 0;
  overflow-y: auto;
  padding: 10px;
  white-space: pre-wrap;
}

#status {
  color: #aeb9c2;
  font-size: 13px;
}

.app-footer {
  color: #7f8c96;
  font-size: 13px;
  padding: 8px 0 18px;
  text-align: center;
}

@media (max-width: 720px) {
  body {
    padding: 10px 10px calc(16px + env(safe-area-inset-bottom));
  }

  body.view-voice {
    padding-bottom: calc(98px + env(safe-area-inset-bottom));
  }

  .app-shell {
    max-width: 480px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
  }

  .eyebrow {
    font-size: 11px;
    margin-bottom: 4px;
  }

  h1 {
    font-size: 28px;
    margin-bottom: 6px;
  }

  h2 {
    font-size: 19px;
  }

  p {
    font-size: 14px;
  }

  .app-subtitle {
    font-size: 14px;
    line-height: 1.35;
  }

  .status-badge {
    align-self: flex-start;
    border-radius: 6px;
    font-size: 12px;
    padding: 8px 10px;
  }

  .mobile-steps {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
  }

  .mobile-steps li {
    align-items: center;
    background: #161f27;
    border: 1px solid #2b3843;
    border-radius: 8px;
    color: #d6e0e8;
    display: grid;
    font-size: 12px;
    font-weight: 800;
    gap: 5px;
    justify-items: center;
    line-height: 1.2;
    min-height: 62px;
    padding: 8px 4px;
    text-align: center;
  }

  .mobile-steps span {
    align-items: center;
    background: #00d4ff;
    border-radius: 50%;
    color: #071014;
    display: inline-flex;
    font-size: 12px;
    height: 22px;
    justify-content: center;
    width: 22px;
  }

  .panel {
    border-radius: 8px;
    box-shadow: none;
    margin-bottom: 10px;
    padding: 14px;
  }

  button {
    border-radius: 8px;
    font-size: 16px;
    min-height: 50px;
    padding: 12px 14px;
    width: 100%;
  }

  input,
  select {
    border-radius: 8px;
    font-size: 16px;
    min-height: 50px;
  }

  label {
    font-size: 13px;
  }

  .device-grid,
  .control-grid,
  .create-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .candidate-card,
  .group-card {
    align-items: stretch;
    border-radius: 8px;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .candidate-card button,
  .group-card button,
  .button-row button {
    width: 100%;
  }

  .candidate-name,
  .group-name {
    font-size: 17px;
  }

  .candidate-sub,
  .group-sub,
  .group-members {
    font-size: 13px;
    line-height: 1.35;
  }

  .notice,
  .empty-state {
    font-size: 14px;
    padding: 12px;
  }

  .command-pill {
    align-self: stretch;
    font-size: 22px;
    padding: 11px 12px;
    text-align: center;
  }

  .button-row,
  .group-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr;
  }

  body.view-voice .control-grid {
    background: #182129;
    border: 1px solid #31404c;
    border-radius: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
    left: 10px;
    margin: 0 auto;
    max-width: 480px;
    padding: 8px;
    position: fixed;
    right: 10px;
    z-index: 30;
  }

  body.view-voice .control-grid .mic-state {
    background: #101820;
    border: 1px solid #293640;
    border-radius: 8px;
    grid-column: 1 / -1;
    justify-content: center;
    min-height: 42px;
  }

  body.view-voice #muteBtn,
  body.view-voice #deafenBtn {
    min-height: 54px;
  }

  .device-grid {
    margin-bottom: 10px;
  }

  .create-group {
    margin-top: 10px;
  }

  .create-group summary,
  .debug-panel summary {
    min-height: 44px;
    padding-top: 10px;
  }

  #log {
    height: 140px;
  }
}

@media (max-width: 380px) {
  .mobile-steps {
    gap: 6px;
  }

  .mobile-steps li {
    font-size: 11px;
    min-height: 58px;
  }

  h1 {
    font-size: 26px;
  }
}
