﻿:root {
  color-scheme: light;
  --bg: #eef5f7;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #687987;
  --line: #d8e5ea;
  --brand: #0f7b8f;
  --brand-strong: #0d6d7f;
  --ok: #11a878;
  --danger: #bd4b45;
  --soft: #f5fafb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

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

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 28px 18px 36px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 138px;
  align-items: start;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  font-size: 34px;
  line-height: 1.15;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
}

.status-badge span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #a8b5bf;
}

.status-badge.connected {
  color: #08745a;
  border-color: #7bd2ba;
  background: #edf9f5;
}

.status-badge.connected span { background: var(--ok); }
.status-badge.connecting span { background: var(--brand); }

.panel {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head.fixed-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 16px;
}

.panel-head.compact { margin-bottom: 14px; }

.panel-copy { min-width: 0; }

.panel-copy h2 {
  margin-bottom: 6px;
  font-size: 24px;
  line-height: 1.2;
}

.panel-copy p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.primary-button,
.ghost-button {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.primary-button {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.primary-button:hover { background: var(--brand-strong); }
.primary-button:active,
.ghost-button:active,
.command-button:active,
.device-card:active {
  transform: scale(0.985);
  opacity: 0.82;
}

.ghost-button {
  color: var(--danger);
  background: #fff;
}

.ghost-button:disabled {
  color: #a5b0b8;
  cursor: not-allowed;
  opacity: 0.7;
}

.device-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.device-card.connected {
  border-color: #7bd2ba;
  background: #edf9f5;
}

.device-card.connecting {
  border-color: #83cbd5;
  background: #eef9fb;
}

.device-card.muted { color: var(--muted); }

.device-card h3 {
  margin-bottom: 8px;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-card p {
  color: var(--muted);
  line-height: 1.45;
  word-break: break-all;
}

.time-status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.time-status span {
  color: var(--muted);
  font-size: 16px;
}

.time-status strong {
  color: var(--brand);
  font-size: 32px;
  line-height: 1;
}

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

.command-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdfe;
  box-shadow: 0 4px 10px rgba(20, 32, 51, 0.04);
  cursor: pointer;
  text-align: left;
  transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.command-button:hover {
  border-color: var(--brand);
  background: #eef9fb;
}

.command-button:disabled {
  color: #95a3ad;
  background: #fbfbfc;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.62;
}

.command-button span {
  min-width: 0;
  width: 100%;
}

.command-button strong,
.command-button small,
.command-button code {
  display: block;
}

.command-button strong {
  overflow: hidden;
  font-size: 21px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-button small {
  overflow: hidden;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-button code {
  color: var(--brand);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
}

.logs {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.log-item,
.empty-log {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f5f8fa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.empty-log {
  display: block;
  color: var(--muted);
  font-family: inherit;
  text-align: center;
}

.log-type { color: #5b6d7a; text-transform: uppercase; }
.log-text { word-break: break-word; }
.log-send .log-type,
.log-send .log-text { color: var(--brand); }
.log-receive .log-type,
.log-receive .log-text { color: #08745a; }
.log-error .log-type,
.log-error .log-text { color: var(--danger); }

footer {
  padding: 22px 0 4px;
  color: #7a8a96;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 640px) {
  .app-shell { padding: 22px 12px 30px; }
  .hero { grid-template-columns: minmax(0, 1fr) 126px; }
  h1 { font-size: 30px; }
  .panel { padding: 18px; }
  .panel-head.fixed-action { grid-template-columns: minmax(0, 1fr) 160px; }
  .device-card { grid-template-columns: minmax(0, 1fr); }
  .device-card .ghost-button { width: 150px; }
  .command-grid { gap: 12px; }
  .command-button { min-height: 104px; padding: 14px; }
  .command-button strong { font-size: 19px; }
}

@media (max-width: 420px) {
  .hero { grid-template-columns: 1fr; }
  .status-badge { width: 126px; }
  .panel-head.fixed-action { grid-template-columns: 1fr; }
  .primary-button { width: 100%; }
  .command-grid { grid-template-columns: 1fr; }
}
