:root {
  color-scheme: light dark;
  --bg: #0b0d0e;
  --fg: #f5f7f8;
  --muted: #9aa4a9;
  --line: #273033;
  --panel: #14181a;
  --panel-2: #101315;
  --field: #090b0c;
  --accent: #f5f7f8;
  --accent-fg: #090b0c;
  --danger: #d4d8da;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
  overflow: hidden;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  min-width: 0;
}

.topbar-title {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
}

.topbar-title.no-icon {
  grid-template-columns: minmax(0, 1fr);
}

.topbar-kicker {
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.title-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.integration-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FFFFFF;
  object-fit: contain;
  padding: 5px;
}

.topbar-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-controls,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-actions {
  justify-content: flex-end;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line) transparent;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

main {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

h1 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.topbar label {
  min-width: 150px;
}

.viewport-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.viewport-presets {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar .viewport-preset {
  width: 34px;
  padding: 0;
}

.viewport-preset[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.viewport-symbol {
  border: 2px solid currentColor;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.viewport-symbol.portrait {
  width: 13px;
  height: 22px;
}

.viewport-symbol.landscape {
  width: 22px;
  height: 13px;
}

.viewport-control select {
  width: 190px;
}

select,
input,
textarea,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

select,
input,
textarea {
  background: var(--field);
  color: var(--fg);
}

select,
input {
  height: 38px;
  padding: 0 10px;
}

.topbar select,
.topbar input {
  height: 34px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

button {
  height: 38px;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 650;
  white-space: nowrap;
}

.topbar button {
  width: auto;
  height: 34px;
  padding: 0 11px;
}

.button-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  flex: 0 0 auto;
}

.button-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.status {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.4;
  background: var(--panel-2);
}

.status strong {
  display: block;
  margin-bottom: 2px;
}

.frame-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: auto;
}

.device {
  background: #000000;
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.18);
  position: relative;
  width: var(--preview-width);
  height: var(--preview-height);
}

iframe,
.rendered-preview {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #FFFFFF;
}

.rendered-preview {
  object-fit: contain;
}

iframe[hidden],
.rendered-preview[hidden] {
  display: none;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.field-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  text-transform: uppercase;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

details {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  list-style: none;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transform-origin: 50% 50%;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

summary .button-icon {
  color: var(--accent);
}

details > .details-body {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}

a {
  color: var(--accent);
}

.settings-page-frame {
  width: 100%;
  height: 220px;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFFFF;
}

.renderer-preview {
  display: grid;
  gap: 10px;
}

.renderer-preview .actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.manifest-preview {
  display: grid;
  gap: 10px;
}

.variants-header {
  display: grid;
  gap: 8px;
}

.variants-header .actions {
  grid-template-columns: 1fr;
}

.variants-list {
  display: grid;
  gap: 10px;
}

.variant-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--field);
}

.variant-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
}

.variant-card-header button {
  width: auto;
  padding: 0 10px;
}

.variant-title {
  color: var(--fg);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.variant-settings {
  margin: 0;
  padding: 0 8px 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.variant-screenshots {
  display: grid;
  gap: 8px;
  padding: 0 8px 8px;
}

.variant-screenshot {
  display: grid;
  gap: 5px;
  margin: 0;
}

.variant-screenshot img {
  width: 100%;
  aspect-ratio: 5 / 3;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #FFFFFF;
  object-fit: contain;
}

.variant-screenshot figcaption {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 2px;
}

@media (max-width: 820px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-controls,
  .topbar-actions {
    flex-wrap: wrap;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .topbar label {
    min-width: min(180px, 100%);
    flex: 1 1 180px;
  }

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

  .sidebar {
    max-height: 52vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  main {
    padding: 14px;
    min-height: 48vh;
  }
}
