:root {
  color-scheme: light;
  --bg: #edf6f3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --text: #15302c;
  --muted: #68807b;
  --line: #d7e6e1;
  --primary: #0f766e;
  --primary-dark: #0b5d57;
  --primary-soft: #d9f4ed;
  --danger: #c93d4b;
  --danger-soft: #fff0f1;
  --warning: #a16207;
  --warning-soft: #fef9c3;
  --shadow: 0 18px 55px rgba(26, 71, 63, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 8% 5%, rgba(45, 212, 191, 0.16), transparent 28rem),
    radial-gradient(circle at 92% 18%, rgba(14, 165, 233, 0.10), transparent 26rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 10px 4px;
}

.eyebrow,
.section-index {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

.hero-state {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
}

.state-dot {
  width: 9px;
  height: 9px;
  background: #94a3b8;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.15);
}

.state-dot.online {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.state-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(201, 61, 75, 0.13);
}

.card {
  margin-bottom: 18px;
  padding: 24px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
}

.two-column > .card {
  margin-bottom: 0;
  height: 100%;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

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

.field {
  display: block;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: #38554f;
  font-size: 0.86rem;
  font-weight: 700;
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  color: var(--text);
  background: #fbfefd;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  border-color: #4fb8aa;
  box-shadow: 0 0 0 4px rgba(79, 184, 170, 0.13);
}

input[readonly] {
  color: var(--primary-dark);
  background: #f0faf7;
}

.button {
  min-height: 40px;
  padding: 9px 15px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
}

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

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

.button-primary {
  color: white;
  background: var(--primary);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.button-secondary {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.button-ghost {
  color: #42615b;
  background: #eff6f4;
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button-full {
  width: 100%;
  margin-top: 18px;
}

.notice {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 0.84rem;
  line-height: 1.5;
  border-radius: 10px;
}

.notice.show {
  display: block;
}

.notice.info {
  color: #075985;
  background: #e7f5ff;
}

.notice.success {
  color: #047857;
  background: #e7f8f0;
}

.notice.error {
  color: #a12432;
  background: var(--danger-soft);
}

.binding-summary {
  min-height: 67px;
  margin-bottom: 15px;
  padding: 14px;
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.binding-summary p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 999px;
}

.status-neutral {
  color: #64748b;
  background: #e9eef2;
}

.status-success {
  color: #047857;
  background: #d7f5e8;
}

.status-error {
  color: #a12432;
  background: #ffe1e4;
}

.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.action-panel h3 {
  margin-bottom: 3px;
  font-size: 0.96rem;
}

.action-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.bind-code {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 13px 16px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 12px;
}

.bind-code strong {
  font-size: 1.8rem;
  letter-spacing: 0.22em;
}

.bind-code span {
  color: var(--muted);
  font-size: 0.78rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: #9aaba7;
  font-size: 0.75rem;
}

.divider::before,
.divider::after {
  height: 1px;
  flex: 1;
  content: "";
  background: var(--line);
}

.inline-control {
  display: flex;
  gap: 10px;
}

.inline-control input {
  letter-spacing: 0.18em;
  font-size: 1.05rem;
}

.recorder-card {
  min-height: 465px;
}

.timer {
  color: var(--primary);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.record-area {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  min-height: 310px;
}

.record-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 178px;
  height: 178px;
  padding: 0;
  color: white;
  background: linear-gradient(145deg, #16998d, #0b655f);
  border: 9px solid #e2f7f2;
  border-radius: 50%;
  box-shadow: 0 17px 38px rgba(15, 118, 110, 0.27);
  cursor: pointer;
  outline: none;
  touch-action: none;
  user-select: none;
}

.record-button strong,
.record-button small {
  position: absolute;
  left: 0;
  width: 100%;
  pointer-events: none;
}

.record-button strong {
  top: 100px;
  font-size: 0.95rem;
}

.record-button small {
  top: 123px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.7rem;
}

.record-icon {
  position: absolute;
  top: 42px;
  width: 31px;
  height: 43px;
  border: 4px solid white;
  border-radius: 16px;
}

.record-icon::before {
  position: absolute;
  right: -12px;
  bottom: -12px;
  left: -12px;
  height: 24px;
  content: "";
  border: 4px solid white;
  border-top: 0;
  border-radius: 0 0 20px 20px;
}

.record-icon::after {
  position: absolute;
  bottom: -18px;
  left: 9px;
  width: 6px;
  height: 10px;
  content: "";
  background: white;
  border-radius: 4px;
}

.record-button.recording {
  background: linear-gradient(145deg, #e55360, #b7283a);
  border-color: #ffe4e7;
  box-shadow: 0 17px 42px rgba(201, 61, 75, 0.35);
  transform: scale(0.97);
}

.record-button.recording .record-rings {
  position: absolute;
  inset: -16px;
  border: 2px solid rgba(201, 61, 75, 0.33);
  border-radius: 50%;
  animation: pulse 1.25s ease-out infinite;
}

@keyframes pulse {
  from { opacity: 0.9; transform: scale(0.92); }
  to { opacity: 0; transform: scale(1.2); }
}

#recordHint {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.meter {
  height: 6px;
  overflow: hidden;
  background: #e5efec;
  border-radius: 999px;
}

.meter div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #14b8a6, #f59e0b, #dc3348);
  border-radius: inherit;
  transition: width 0.08s linear;
}

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

.message-list,
.voice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voice-list {
  max-height: calc(5 * 72px + 4 * 10px);
  overflow-y: auto;
  padding-right: 4px;
}

.voice-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.voice-row.mine {
  flex-direction: row-reverse;
}

.voice-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  color: #fff;
  background: #0f766e;
  border-radius: 50%;
  font-size: 0.92rem;
  font-weight: 800;
}

.voice-row.mine .voice-avatar {
  background: #0ea5e9;
}

.voice-bar {
  min-width: 96px;
  max-width: min(72%, 280px);
  padding: 11px 14px;
  color: var(--text);
  text-align: left;
  background: #e2e8f0;
  border: 0;
  border-radius: 16px 16px 16px 6px;
  cursor: pointer;
}

.voice-row.mine .voice-bar {
  background: #99f6e4;
  border-radius: 16px 16px 6px 16px;
}

.voice-bar strong {
  display: block;
  font-size: 0.92rem;
}

.voice-bar small {
  color: var(--muted);
  font-size: 0.75rem;
}

.avatar-preview {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--primary);
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 800;
}

.peer-label-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.empty-state {
  padding: 34px 12px;
  color: var(--muted);
  text-align: center;
  background: #f8fbfa;
  border: 1px dashed var(--line);
  border-radius: 13px;
}

.empty-state span {
  color: #47615c;
  font-weight: 800;
}

.empty-state p {
  margin: 6px 0 0;
  font-size: 0.8rem;
}

.message-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px 15px;
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.message-item.mine {
  background: #e7f8f0;
}

.message-item h3 {
  margin-bottom: 5px;
  font-size: 0.92rem;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 13px;
  color: var(--muted);
  font-size: 0.75rem;
}

.audio-player {
  width: 100%;
  margin-top: 14px;
}

.log-card pre {
  max-height: 230px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #c9f4e8;
  background: #102d29;
  border-radius: 12px;
  font: 0.78rem/1.65 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

@media (max-width: 780px) {
  .page-shell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .two-column,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .card {
    padding: 19px;
    border-radius: 16px;
  }

  .section-heading {
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .section-heading,
  .action-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .mqtt-actions {
    justify-content: space-between;
  }

  .inline-control {
    flex-direction: column;
  }

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

  .message-item .button {
    width: 100%;
  }
}

.soft-bg {
  min-height: 100vh;
  background: linear-gradient(145deg, #e0f2fe 0%, #f1f5f9 48%, #ecfdf5 100%);
  color: #1e293b;
}

.manage-shell,
.admin-shell {
  display: block;
  max-width: 720px;
  padding: 30px 16px 56px;
}

.admin-shell {
  max-width: 1120px;
}

.manage-shell .card,
.admin-shell .card {
  margin-bottom: 16px;
  border-radius: 14px;
}

.soft-bg .hero {
  display: block;
  margin-bottom: 22px;
  padding: 0;
}

.soft-bg .hero h1 {
  margin: 0.15rem 0;
}

.soft-bg .hero p,
.hint {
  color: #64748b;
}

.soft-bg .hero p {
  margin: 0;
}

.soft-bg .pill {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 99px;
  background: #dce4df;
}

.soft-bg .pill.on {
  background: #d2f5e6;
  color: #087c58;
}

.soft-bg button {
  cursor: pointer;
  color: #fff;
  background: #12966d;
  border: 0;
  border-radius: 10px;
  padding: 11px 13px;
  font-weight: 700;
}

.soft-bg button:hover {
  filter: brightness(0.94);
}

.soft-bg input {
  width: auto;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 9px;
}

.kv span {
  color: #64748b;
}

.binding-state {
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 15px;
  font-weight: 700;
}

.binding-state.bound {
  background: #ecfdf5;
  color: #047857;
}

.binding-state.unbound {
  background: #fff7ed;
  color: #c2410c;
}

.code-panel {
  margin: 18px 0;
  padding: 18px;
  text-align: center;
  border-radius: 14px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
}

.code-panel span,
.code-panel small {
  display: block;
  color: #64748b;
}

.code-panel strong {
  display: block;
  margin: 8px 0;
  font-size: 2.2rem;
  letter-spacing: 0.32em;
  color: #0f766e;
}

.ghost {
  background: #f1f5f9;
  color: #334155;
}

.status {
  display: none;
  padding: 11px 14px;
  border-radius: 9px;
}

.status.show {
  display: block;
}

.status.info {
  background: #ecfeff;
  color: #0e7490;
}

.status.success {
  background: #ecfdf5;
  color: #047857;
}

.status.error {
  background: #fef2f2;
  color: #dc2626;
}

.footer-link {
  text-align: center;
}

.footer-link a {
  color: #0f766e;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

th {
  background: #f8fafc;
  color: #64748b;
  font-size: 0.84rem;
}

td {
  font-size: 0.92rem;
}

td code {
  white-space: nowrap;
}

.online {
  color: #047857;
  font-weight: 700;
}

.offline {
  color: #64748b;
}

.bound {
  color: #047857;
}

.unbound {
  color: #dc2626;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
}

.empty {
  text-align: center;
  color: #64748b;
  padding: 26px;
}

.danger {
  background: #cf4a52;
}

@media (max-width: 760px) {
  .manage-shell,
  .admin-shell {
    padding: 18px 12px 40px;
  }

  .code-panel strong {
    font-size: 1.7rem;
  }

  .toolbar {
    align-items: flex-start;
  }
}
