* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
  background: #f5f5f5;
  color: #1d1d1f;
}

header {
  background: #1f2937;
  color: white;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

header h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

header h1 .accent {
  color: #f97316;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.status input[type="text"] {
  width: 220px;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  border: 1px solid #4b5563;
  background: #111827;
  color: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #6b7280;
  cursor: help;
  flex-shrink: 0;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.health-dot[data-state="up"] {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.health-dot[data-state="down"] {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.health-dot[data-state="unknown"] {
  background: #6b7280;
}

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 1px solid;
}

.badge[data-state="off"] {
  background: #374151;
  border-color: #4b5563;
  color: #9ca3af;
}

.badge[data-state="on"] {
  background: #064e3b;
  border-color: #10b981;
  color: #d1fae5;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  height: calc(100vh - 56px);
}

.iframe-wrap {
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.panel {
  overflow-y: auto;
  padding: 0.75rem;
  background: #1f2937;
}

fieldset {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.6rem 0.75rem 0.75rem;
  margin: 0 0 0.75rem 0;
  background: white;
}

fieldset legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4b5563;
  padding: 0 0.4rem;
}

button {
  background: #2563eb;
  color: white;
  border: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  margin: 0.15rem 0.15rem 0.15rem 0;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
}

button:disabled {
  background: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
}

button.small {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  background: #6b7280;
}

button.reset {
  background: #b91c1c;
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  margin-left: 0.5rem;
}

button.reset:hover:not(:disabled) {
  background: #991b1b;
}

button.help {
  background: transparent;
  color: #d1d5db;
  border: 1px solid #4b5563;
  padding: 0.2rem;
  margin-left: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.help:hover:not(:disabled) {
  background: #374151;
  color: white;
}

button.help .ic {
  width: 16px;
  height: 16px;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

.modal-dialog {
  position: relative;
  background: white;
  border-radius: 8px;
  width: min(900px, 90vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 8px 8px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
}

.modal-close {
  background: transparent;
  border: 1px solid transparent;
  color: #6b7280;
  padding: 0.2rem;
  margin: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover:not(:disabled) {
  background: #e5e7eb;
  color: #1f2937;
}

.modal-close .ic {
  width: 18px;
  height: 18px;
}

.modal-body {
  overflow-y: auto;
  padding: 1rem 1.25rem 1.25rem;
}

.modal-body section + section {
  margin-top: 1.25rem;
}

.modal-body h3 {
  margin: 0 0 0.4rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.help-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.help-list li {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  background: #f9fafb;
}

.help-list .help-label {
  font-size: 0.75rem;
  color: #4b5563;
  font-weight: 500;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.help-list .help-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 0.25rem;
}

.help-list pre,
.help-list code.help-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: #111827;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
}

.help-list .help-action {
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.help-list .help-action:hover:not(:disabled) {
  background: white;
  color: #2563eb;
  border-color: #93c5fd;
}

.help-list .help-action.copied {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.help-list .help-action:disabled,
.help-list .help-action.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: transparent;
  color: #6b7280;
  border-color: #e5e7eb;
}

.help-list .help-action:disabled:hover,
.help-list .help-action.disabled:hover {
  background: transparent;
  color: #6b7280;
  border-color: #e5e7eb;
}

.help-list .help-action .ic {
  width: 12px;
  height: 12px;
}

.help-list .help-hint {
  font-size: 0.7rem;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
}

.help-list .help-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: transparent;
  padding: 0;
  color: #92400e;
}

.help-list code.help-url.has-placeholder {
  background: #fffbeb;
  border-color: #fde68a;
}

button.copy-curl {
  background: transparent;
  color: #6b7280;
  padding: 0.2rem;
  border: 1px solid transparent;
  border-radius: 4px;
  margin: 0 0.15rem 0 0;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

button.copy-curl:hover:not(:disabled) {
  background: #f3f4f6;
  color: #2563eb;
  border-color: #d1d5db;
}

button.copy-curl .ic {
  width: 14px;
  height: 14px;
  display: block;
}

button.copy-curl.copied {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

button.copy-curl.copied::after {
  content: "copied";
  position: absolute;
  top: -1.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: #047857;
  color: white;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

details summary button.copy-curl,
fieldset legend button.copy-curl {
  margin-left: 0.25rem;
}

label {
  display: block;
  font-size: 0.8rem;
  color: #374151;
  margin: 0.4rem 0 0;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-top: 0.2rem;
}

textarea {
  resize: vertical;
}

details {
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

details summary {
  cursor: pointer;
  color: #4b5563;
  user-select: none;
}

pre {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 0.5rem;
  font-size: 0.75rem;
  overflow-x: auto;
  margin: 0.4rem 0 0;
  max-height: 180px;
  overflow-y: auto;
}

pre.placeholder {
  color: #9ca3af;
  font-style: italic;
}

.muted {
  color: #6b7280;
  font-size: 0.8rem;
  margin-left: 0.4rem;
}

.muted-block {
  display: block;
  color: #6b7280;
  font-size: 0.75rem;
  margin-top: 0.4rem;
  line-height: 1.35;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #374151;
  margin-top: 0.4rem;
}

.inline-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.muted-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f3f4f6;
  padding: 0 0.2rem;
  border-radius: 2px;
}

#event-log {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
  max-height: 220px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
}

#event-log li {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid #f3f4f6;
  white-space: pre-wrap;
  word-break: break-all;
}

#event-log li.evt-error {
  color: #b91c1c;
}

#event-log li.evt-saved {
  color: #047857;
}

#event-log li.evt-ready,
#event-log li.evt-editor-ready {
  color: #1d4ed8;
}

#event-log li time {
  color: #9ca3af;
  margin-right: 0.4rem;
}

/* ---------------------------------------------------------------------------
 * Right aside (.panel) dark theme — same surface color as the header so the
 * two read as one continuous chrome around the iframe. Boxes are recessed
 * cards, legends use the orange "Embedded Host" accent, inputs and panes are
 * tuned for dark backgrounds.
 * ------------------------------------------------------------------------- */

.panel fieldset {
  background: #111827;
  border-color: #374151;
}

.panel fieldset legend {
  color: #ffffff;
  font-size: 0.95rem;
}

.panel label {
  color: #d1d5db;
}

.panel input[type="text"],
.panel textarea {
  background: #0b1220;
  color: #f9fafb;
  border-color: #374151;
}

.panel input[type="text"]::placeholder,
.panel textarea::placeholder {
  color: #6b7280;
}

.panel details summary {
  color: #d1d5db;
}

.panel pre {
  background: #0b1220;
  border-color: #374151;
  color: #e5e7eb;
}

.panel pre.placeholder {
  color: #6b7280;
}

.panel .muted,
.panel .muted-block {
  color: #9ca3af;
}

.panel button:disabled {
  background: #374151;
  color: #9ca3af;
}

.panel button.copy-curl {
  color: #9ca3af;
}

.panel button.copy-curl:hover:not(:disabled) {
  background: #1f2937;
  color: #f97316;
  border-color: #374151;
}

.panel button.copy-curl.copied {
  background: #064e3b;
  color: #d1fae5;
  border-color: #10b981;
}

.panel #event-log li {
  border-bottom-color: #1f2937;
  color: #e5e7eb;
}

.panel #event-log li.evt-error {
  color: #fca5a5;
}

.panel #event-log li.evt-saved {
  color: #6ee7b7;
}

.panel #event-log li.evt-ready,
.panel #event-log li.evt-editor-ready {
  color: #93c5fd;
}

.panel #event-log li.evt-close {
  color: #fcd34d;
}
