:root {
  --bg: #0e0f12;
  --surface: #16181d;
  --surface-2: #1d2027;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e9ecef;
  --text-muted: #94a3b8;
  --primary: #4f46e5;
  --success: #22c55e;
  --warn: #f59e0b;
  --error: #ef4444;
  --pending: #64748b;
  --radius: 8px;
  --sp: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: rgba(0, 0, 0, 0.08);
    --text: #0f172a;
    --text-muted: #475569;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.title-block {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  flex-shrink: 0;
}

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

.subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

#app-picker,
#reload-btn,
#ping-btn {
  margin-left: auto;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}

#app-picker {
  margin-left: auto;
}

#reload-btn,
#ping-btn {
  margin-left: 0;
}

#reload-btn:hover,
#ping-btn:hover,
#app-picker:hover {
  border-color: var(--text-muted);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 60dvh 1fr;
  }
}

.iframe-wrapper {
  position: relative;
  min-height: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}

#app-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.diag-panel {
  padding: 16px 18px;
  overflow: auto;
  background: var(--surface);
}

.diag-panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.diag-panel h3 {
  margin: 18px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

#checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#checks li {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.3;
}

#checks .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pending);
  display: block;
  margin: 3px;
}

#checks li[data-state='ok'] .dot {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent);
}

#checks li[data-state='warn'] .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent);
}

#checks li[data-state='ko'] .dot {
  background: var(--error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 25%, transparent);
}

#checks code {
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

#checks .value {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

#log {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11.5px;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  max-height: 220px;
  overflow: auto;
}

.manual {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.manual code {
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11.5px;
  color: var(--text);
}
