:root {
  color-scheme: dark;
  --bg: #05060b;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f7f9ff;
  --muted: #b7c1d6;
  --blue: #0a4de8;
  --cyan: #39a9ff;
  --danger: #ff4d67;
  --ok: #27d07d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(10, 77, 232, 0.28), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(57, 169, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #05060b 0%, #081329 48%, #05060b 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.phone-page {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.phone-nav,
.phone-hero,
.panel-card,
.log-card {
  border: 1px solid var(--line);
  background: rgba(5, 8, 18, 0.72);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.phone-nav {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  border-radius: 18px;
  padding: 10px 12px;
}

.phone-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}

.phone-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, #063fd1, #39a9ff);
}

.phone-nav-pill,
.mini-badge {
  border: 1px solid rgba(57, 169, 255, 0.26);
  border-radius: 999px;
  background: rgba(57, 169, 255, 0.1);
  color: #dcefff;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 900;
}

.phone-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 22px;
  margin-top: 18px;
  border-radius: 24px;
  padding: clamp(22px, 4vw, 42px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 82px);
  line-height: 0.95;
}

.phone-hero p {
  max-width: 660px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.connect-card {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  padding: 18px;
}

.connection-state {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 68px;
}

.connection-state span:not(.status-dot) {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  margin-top: 3px;
}

.status-dot {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 999px;
  background: #667085;
  box-shadow: 0 0 0 8px rgba(102, 112, 133, 0.14);
}

.status-dot.connected {
  background: var(--ok);
  box-shadow: 0 0 0 8px rgba(39, 208, 125, 0.14);
}

.primary-button,
.ghost-button,
.soft-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(135deg, var(--blue), #39a9ff);
}

.ghost-button,
.soft-button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.danger-button {
  border-color: rgba(255, 77, 103, 0.32);
  background: rgba(255, 77, 103, 0.14);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

.warning {
  margin: 0;
  color: #ffd166;
  font-size: 13px;
  line-height: 18px;
}

.compat-notice {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(255, 209, 102, 0.36);
  border-radius: 16px;
  background: rgba(255, 209, 102, 0.1);
  color: #ffe8a3;
  padding: 12px;
  font-size: 13px;
  line-height: 18px;
}

.compat-notice[hidden] {
  display: none;
}

.compat-notice strong {
  color: #fff4c7;
  font-size: 14px;
}

.wifi-card {
  display: grid;
  gap: 9px;
  border: 1px solid rgba(39, 208, 125, 0.3);
  border-radius: 16px;
  background: rgba(39, 208, 125, 0.1);
  color: #dfffee;
  padding: 13px;
  font-size: 13px;
  line-height: 18px;
}

.wifi-card strong {
  color: #f4fff9;
  font-size: 14px;
}

.wifi-card ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
}

.wifi-card span {
  color: #bdebd4;
}

.wifi-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(39, 208, 125, 0.24);
  color: #ffffff;
  font-weight: 900;
  text-decoration: none;
}

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

.panel-card,
.log-card {
  border-radius: 22px;
  padding: 18px;
}

.messages-card {
  grid-row: span 2;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 900;
}

.info-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  padding-bottom: 10px;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  text-align: right;
  font-weight: 900;
}

.audio-player {
  width: 100%;
  margin-bottom: 12px;
}

.button-row,
.recorder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-drop {
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px dashed rgba(57, 169, 255, 0.42);
  border-radius: 16px;
  margin: 14px 0;
  background: rgba(57, 169, 255, 0.08);
  color: #dcefff;
  font-weight: 900;
  text-align: center;
}

.file-drop input {
  display: none;
}

.messages-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.message-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  padding: 12px;
}

.message-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.message-actions button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 12px;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.config-form {
  display: grid;
  gap: 13px;
}

.config-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.config-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 12px;
  font-weight: 800;
}

.log-card {
  margin-top: 16px;
}

#activityLog {
  min-height: 130px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  color: #dcefff;
  white-space: pre-wrap;
}

@media (max-width: 840px) {
  .phone-page {
    width: min(100% - 20px, 520px);
    padding-bottom: 28px;
  }

  .phone-hero,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .phone-hero {
    padding: 20px;
  }

  .messages-card {
    grid-row: auto;
  }

  .message-item {
    grid-template-columns: 1fr;
  }

  .message-actions {
    justify-content: stretch;
  }

  .message-actions button,
  .button-row button,
  .recorder-row button {
    flex: 1 1 120px;
  }
}
