:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --panel: #12151f;
  --border: #232838;
  --text: #e6e9f0;
  --muted: #8790a3;
  --accent: #5eead4;
  --online: #4ade80;
  --offline: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.topbar {
  padding: 24px 20px 16px;
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.tagline {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

main.layout {
  max-width: 1100px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

@media (min-width: 760px) {
  main.layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.col-left,
.col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header-row h2 {
  margin: 0;
}

.status-line {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-online { background: var(--online); box-shadow: 0 0 8px var(--online); }
.dot-offline { background: var(--offline); }

.device-list, .activity-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.device-card .name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-card .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.activity-item {
  font-size: 13px;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.activity-item .time {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.activity-item .message {
  white-space: pre-wrap;
}

.panel-compact .activity-list {
  max-height: 220px;
  overflow-y: auto;
}

.analysis-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.analysis-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.analysis-item summary::-webkit-details-marker {
  display: none;
}

.analysis-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.delete-analysis-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 15px;
  cursor: pointer;
}

.delete-analysis-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.analysis-item summary .time {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  white-space: nowrap;
}

.analysis-item .analysis-text {
  font-size: 14px;
  line-height: 1.55;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.analysis-text p {
  margin: 0 0 10px;
}

.analysis-text p:last-child {
  margin-bottom: 0;
}

.analysis-text h1,
.analysis-text h2,
.analysis-text h3,
.analysis-text h4 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.analysis-text h1:first-child,
.analysis-text h2:first-child,
.analysis-text h3:first-child,
.analysis-text h4:first-child {
  margin-top: 0;
}

.analysis-text strong {
  color: var(--text);
  font-weight: 700;
}

.analysis-text code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

.analysis-text ul,
.analysis-text ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.analysis-text li {
  margin-bottom: 4px;
}

.analysis-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.md-table-wrap {
  overflow-x: auto;
  margin: 0 0 10px;
}

.analysis-text table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.analysis-text th,
.analysis-text td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}

.analysis-text th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.device-card {
  cursor: pointer;
  transition: border-color 0.15s;
}

.device-card:hover {
  border-color: var(--accent);
}

.command-form {
  display: flex;
  gap: 8px;
}

.command-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}

.command-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.command-form button {
  background: var(--accent);
  color: #0b0e14;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.command-response {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 16px;
}

.command-response.thinking {
  color: var(--accent);
}

.command-response.thinking::after {
  content: "";
  display: inline-block;
  width: 1em;
  text-align: left;
  animation: thinking-dots 1.2s steps(4, end) infinite;
}

@keyframes thinking-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.detail-status {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-row:last-of-type {
  border-bottom: none;
}

.detail-row .label {
  color: var(--muted);
}

.capability-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.capability-list li {
  font-size: 14px;
}

.capability-list li::before {
  content: "✓ ";
  color: var(--online);
}

.monitoring-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.mini-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: var(--accent);
}

.mini-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pairing-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.screenshot-img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 8px;
}
