.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 13, 14, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-100);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--brand-primary);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.brand-name {
  font-size: 18px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar-meta .badge {
  display: none;
}

.workspace {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-4);
  padding-bottom: var(--space-7);
}

.panel-controls {
  order: 2;
}

.panel-preview {
  order: 1;
}

.preview-sticky {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
}

.phone {
  width: min(100%, 340px);
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: var(--ink-800);
  box-shadow: var(--shadow-2);
}

.phone-screen {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: 20px;
  overflow: hidden;
  background: var(--ink-700);
}

.phone-screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guide-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.guide-layer[hidden] {
  display: none;
}

.preview-note {
  color: var(--text-500);
  font-size: 13px;
  text-align: center;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  margin-bottom: var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--ink-800);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-500);
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--ink-600);
  color: var(--text-100);
}

.controls {
  display: grid;
  gap: var(--space-4);
}

.field-group {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--ink-800);
}

.field-group[hidden] {
  display: none;
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field-inline .field-label {
  order: 1;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-300);
}

.field-hint {
  display: inline-block;
  margin-left: var(--space-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-500);
}

input[type="text"],
input[type="file"],
select {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ink-700);
  color: var(--text-100);
}

input[type="file"] {
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-500) 50%),
    linear-gradient(135deg, var(--text-500) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand-primary);
}

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

.colors-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.color-field {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-300);
}

.color-field input[type="color"] {
  width: 40px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ink-700);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-300);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chip.is-active {
  border-color: var(--brand-primary);
  background: rgba(199, 240, 74, 0.12);
  color: var(--brand-primary);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: var(--space-2);
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ink-700);
  overflow: hidden;
  cursor: pointer;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item.is-active {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(199, 240, 74, 0.3);
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text-500);
  font-size: 14px;
  text-align: center;
}

.guide {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 12px 10px 14px;
  color: #fff;
  font-family: var(--font-sans);
}

.guide-bars {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.guide-bars span {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
}

.guide-bars span:first-child {
  background: #fff;
}

.guide-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.guide-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.guide-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.25);
}

.guide-side {
  position: absolute;
  right: 12px;
  bottom: 120px;
  display: grid;
  gap: 16px;
  font-size: 11px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.guide-side b {
  display: block;
  font-size: 13px;
}

.guide-bottom {
  display: grid;
  gap: 8px;
  font-size: 11px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.guide-caption {
  line-height: 1.3;
}

.guide-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  font-size: 11px;
}

.ig-guide {
  position: absolute;
  inset: 0;
  color: #fff;
  font-family: var(--font-sans);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.ig-bars {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
}

.ig-bars span {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.4);
}

.ig-bars span.is-active {
  background: #fff;
}

.ig-top {
  position: absolute;
  top: 22px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.ig-profile {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ig-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
}

.ig-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ig-user {
  font-size: 11px;
}

.ig-top-actions svg {
  width: 16px;
  height: 16px;
}

.ig-safe-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.4);
  font-size: 8px;
}

.ig-safe-line::after {
  content: attr(data-label);
  position: absolute;
  right: 0;
  top: 2px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.4);
}

.ig-safe-top {
  top: 13%;
}

.ig-safe-bottom {
  top: 80%;
}

.ig-actions {
  position: absolute;
  right: 10px;
  top: 44%;
  display: grid;
  gap: 16px;
}

.ig-action svg {
  width: 22px;
  height: 22px;
}

.ig-bottom {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  display: grid;
  gap: 8px;
  font-size: 10px;
}

.ig-caption {
  display: flex;
  gap: 6px;
}

.ig-message {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
}

.ig-home {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 18px;
  height: 3px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.8);
}

@media (min-width: 900px) {
  .workspace {
    grid-template-columns: minmax(320px, 400px) 1fr;
    gap: var(--space-6);
    max-width: 1240px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-7);
    align-items: start;
  }

  .panel-controls {
    order: 1;
  }

  .panel-preview {
    order: 2;
    position: sticky;
    top: 84px;
  }

  .topbar-inner {
    padding: var(--space-3) var(--space-5);
  }

  .topbar-meta .badge {
    display: inline-flex;
  }
}
