:root {
  --bg: #eceff3;
  --toolbar: #14171d;
  --toolbar-2: #1d222b;
  --text: #f5f7fb;
  --muted: #c3c9d4;
  --line: #343b48;
  --btn: #2a3140;
  --btn-hover: #3a4356;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --focus: #facc15;
  --frame: #ffffff;
  --shadow: 0 10px 30px rgba(15, 18, 24, 0.18);
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

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

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 20;
  background: var(--focus);
  color: #111;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
iframe:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(180deg, var(--toolbar), var(--toolbar-2));
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

.toolbar__eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbar__title {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
  font-weight: 700;
}

.toolbar__nav,
.toolbar__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar__nav {
  flex: 1 1 320px;
}

.toolbar__tools {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field label {
  font-size: 0.75rem;
  color: var(--muted);
}

.field--select {
  flex: 1 1 220px;
  min-width: 180px;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1218;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 0.95rem;
  color-scheme: dark;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--btn);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--btn-hover);
}

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

.btn--icon {
  width: 40px;
  padding: 0;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.is-active {
  background: #3b82f6;
  color: #fff;
}

.counter {
  margin: 0;
  min-width: 64px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.platform-switch,
.viewport-switch {
  display: flex;
  gap: 4px;
}

.platform-switch__btn {
  min-width: 88px;
  padding-inline: 14px;
}

.toolbar__platform {
  flex: 0 0 auto;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 12px;
}

.stage__frame {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 360px;
  margin: 0 auto;
  background: var(--frame);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 0.2s ease;
}

.stage__frame[data-viewport="desktop"] {
  width: 100%;
  flex-grow: 1;
}

.stage__frame[data-viewport="tablet"],
.stage__frame[data-viewport="mobile"] {
  flex-grow: 0;
}

.stage__frame[data-viewport="desktop"] {
  width: 100%;
}

.stage__frame[data-viewport="tablet"] {
  width: min(768px, 100%);
}

.stage__frame[data-viewport="mobile"] {
  width: min(390px, 100%);
}

.stage__loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  color: #111827;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

.preview-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  visibility: hidden;
  pointer-events: none;
}

.preview-frame.is-current {
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

.chooser {
  width: min(480px, calc(100vw - 32px));
  border: 0;
  border-radius: 14px;
  padding: 24px;
  color: #111827;
  box-shadow: var(--shadow);
}

.chooser::backdrop {
  background: rgba(15, 18, 24, 0.55);
}

.chooser h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.chooser p {
  margin: 0 0 12px;
  color: #374151;
}

.chooser__name {
  font-size: 1.4rem;
  font-weight: 800;
  color: #111827;
}

.chooser__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chooser .btn {
  color: #111827;
  background: #e5e7eb;
}

.chooser .btn--primary {
  background: var(--primary);
  color: #fff;
}

.stage:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -6px;
}

@media (max-width: 1100px) {
  .toolbar__tools,
  .toolbar__nav {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage__frame {
    transition: none;
  }
}
