:root {
  color: #1c2430;
  background: #eef1f4;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: #eef1f4;
  color: #1c2430;
}

button,
textarea,
input {
  font: inherit;
  letter-spacing: 0;
}

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

.page-shell {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 56px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-header p {
  margin: 7px 0 0;
  color: #637083;
  font-size: 14px;
}

.connection {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #cbd2dc;
  border-radius: 6px;
  background: #f8fafb;
  color: #4b586a;
  font-size: 13px;
  font-weight: 600;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a2b1;
}

.connection-dot.online {
  background: #16825d;
  box-shadow: 0 0 0 3px #d7f0e6;
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: #ffffff;
}

.auth-summary h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.auth-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 8px;
  color: #6a7687;
  font-size: 11px;
}

.auth-state {
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf0f3;
  color: #596575;
  font-weight: 700;
}

.auth-state.ready {
  background: #dff3e9;
  color: #126747;
}

.auth-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.auth-config-missing {
  color: #7d5a1f;
  font-size: 12px;
  font-weight: 600;
}

.notice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px 18px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.notice.warning {
  border-color: #e8c781;
  background: #fff9e9;
  color: #634917;
}

.notice.error {
  border-color: #e7a8aa;
  background: #fff4f4;
  color: #7c282e;
}

.notice code {
  padding: 1px 4px;
  border-radius: 3px;
  background: rgb(0 0 0 / 7%);
}

.workspace {
  overflow: hidden;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgb(31 42 55 / 7%);
}

.section {
  padding: 24px;
  border-bottom: 1px solid #dde2e8;
}

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

.section-kicker {
  margin: 0 0 5px;
  color: #788496;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.section h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0;
}

.icon-link,
.text-button {
  border: 0;
  background: transparent;
  color: #315f8e;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.icon-link:hover,
.text-button:hover {
  color: #173f68;
  text-decoration: underline;
}

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

.device-list {
  display: grid;
  gap: 8px;
}

.device-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 13px;
  border: 1px solid #d9dee5;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.device-row:hover {
  border-color: #8da9c5;
  background: #f8fafc;
}

.device-row.selected {
  border-color: #4679aa;
  background: #f2f7fb;
  box-shadow: inset 3px 0 #4679aa;
}

.device-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: #2e669c;
}

.device-main {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.device-name {
  font-size: 14px;
  font-weight: 700;
}

.device-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: #687487;
  font-size: 12px;
}

.device-state {
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8ebef;
  color: #596575;
  font-size: 11px;
  font-weight: 700;
}

.device-state.available {
  background: #dff3e9;
  color: #126747;
}

.device-state.unavailable {
  background: #f5e2e3;
  color: #8a3036;
}

.device-main code {
  overflow-wrap: anywhere;
  color: #8993a2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  min-width: 112px;
  background: #23679f;
  color: #ffffff;
}

.button.primary:hover:not(:disabled) {
  background: #174f7d;
}

.button.secondary {
  justify-self: start;
  border-color: #bdc8d5;
  background: #f7f9fb;
  color: #34475c;
}

.button.secondary:hover {
  border-color: #8ba0b7;
  background: #eef3f7;
}

.button:disabled,
.quick-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.selected-device {
  max-width: 45%;
  overflow: hidden;
  color: #526174;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-form {
  display: grid;
  gap: 10px;
}

textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid #cfd6df;
  border-radius: 6px;
  outline: 0;
  color: #202a37;
  font-size: 14px;
  line-height: 1.6;
}

textarea:focus {
  border-color: #3979b4;
  box-shadow: 0 0 0 3px #e1edf7;
}

textarea:disabled {
  background: #f3f5f7;
}

.message-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.limit {
  color: #8993a1;
  font-size: 11px;
}

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

.quick-grid form:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.quick-button {
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid #d7dde4;
  border-radius: 6px;
  background: #f8f9fb;
  color: #4a5869;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.quick-button:hover:not(:disabled) {
  border-color: #8ea8c1;
  background: #eff5f9;
  color: #234f78;
}

.log-list {
  display: grid;
  max-height: 250px;
  gap: 6px;
  overflow-y: auto;
}

.log-entry {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-left: 3px solid #9ba6b4;
  background: #f6f7f9;
  color: #3e4a59;
  font-size: 12px;
  line-height: 1.5;
}

.log-entry time {
  color: #7e8997;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.log-entry.success {
  border-color: #25815f;
  background: #edf8f3;
  color: #155b43;
}

.log-entry.error {
  border-color: #b44950;
  background: #fff1f1;
  color: #812e34;
}

.log-entry.warn {
  border-color: #c58a28;
  background: #fff8e8;
  color: #745016;
}

.empty-state {
  margin: 0;
  padding: 26px 12px;
  border: 1px dashed #ccd3dc;
  border-radius: 6px;
  color: #778394;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.empty-state.compact {
  padding: 15px;
}

.diagnostics {
  padding: 17px 24px;
  background: #f7f8fa;
}

.diagnostics summary {
  color: #455366;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.diagnostics-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 16px;
  color: #566375;
  font-size: 12px;
}

.diagnostics h3 {
  margin: 0 0 8px;
  color: #344255;
  font-size: 12px;
}

.diagnostics ul {
  margin: 0;
  padding-left: 18px;
}

.diagnostics pre {
  grid-column: 1 / -1;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 13px;
  border: 1px solid #d9dee5;
  border-radius: 5px;
  background: #ffffff;
  color: #394658;
  font-size: 11px;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 880px);
    padding: 20px 0 32px;
  }

  .page-header {
    align-items: flex-start;
  }

  .page-header h1 {
    font-size: 21px;
  }

  .page-header p {
    max-width: 220px;
  }

  .connection {
    min-height: 32px;
    padding: 0 9px;
  }

  .auth-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .auth-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-actions .button,
  .auth-actions form {
    width: 100%;
  }

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

  .section {
    padding: 19px 15px;
  }

  .section-header {
    gap: 10px;
  }

  .selected-device {
    max-width: 48%;
  }

  .quick-grid,
  .diagnostics-body {
    grid-template-columns: 1fr;
  }

  .quick-grid form:last-child:nth-child(odd),
  .diagnostics pre {
    grid-column: auto;
  }

  .message-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .log-entry {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 7px;
  }
}
