.widget-dialog {
  width: min(1080px, calc(100% - 32px));
  max-height: min(90dvh, 840px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(20, 20, 43, 0.32);
}

.widget-dialog::backdrop { background: rgba(15, 23, 42, 0.66); backdrop-filter: blur(4px); }
.widget-dialog:not([open]) { display: none; }
.widget-dialog-shell { max-height: inherit; overflow: auto; }
.widget-dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 28px 30px 20px; border-bottom: 1px solid var(--line); }
.widget-dialog-header h2 { margin: 5px 0 7px; font-size: clamp(1.55rem, 3vw, 2.25rem); line-height: 1.12; letter-spacing: -.035em; }
.widget-dialog-header p { max-width: 720px; margin: 0; color: var(--ink-soft); }
.widget-dialog-close { flex: 0 0 42px; width: 42px; height: 42px; min-height: 42px; padding: 0; border-radius: 50%; font-size: 1.5rem; line-height: 1; }
.widget-dialog-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 24px; padding: 26px 30px 30px; }
.widget-format-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f2f3f8;
}
.widget-format-tab {
  flex: 1 1 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
}
.widget-format-tab:hover { color: var(--ink); }
.widget-format-tab.is-active {
  background: #fff;
  color: #c34e16;
  box-shadow: 0 3px 12px rgba(15, 23, 42, .1);
}
.widget-format-tab:focus-visible { outline: 3px solid rgba(244, 114, 45, .28); outline-offset: 2px; }
[data-widget-format-panel][hidden] { display: none !important; }
.widget-code-panel label { display: block; margin-bottom: 8px; font-weight: 800; }
.widget-code-panel label span {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f0ebff;
  color: #5d43cf;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.widget-code {
  display: block;
  width: 100%;
  min-height: 255px;
  resize: vertical;
  padding: 15px;
  border: 2px solid #b9bfd0;
  border-radius: 12px;
  background: #f8fafc;
  color: #182033;
  font: 500 .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, .08);
}
.widget-code:focus { border-color: #f4722d; outline: 3px solid rgba(244, 114, 45, .2); }
.widget-code-split { min-height: 185px; }
.widget-code-note { min-height: 42px; margin: 10px 0 16px; color: var(--ink-soft); font-size: .86rem; }
.widget-wordpress-intro {
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid #d9d1ff;
  border-radius: 12px;
  background: #f7f4ff;
  color: var(--ink-soft);
  font-size: .87rem;
}
.widget-wordpress-intro strong { color: var(--ink); }
.widget-wordpress-intro code { color: #5038bd; font-size: .8em; }
.widget-snippet {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.widget-snippet + .widget-snippet { margin-top: 16px; }
.widget-snippet .widget-code-note { min-height: 0; margin-bottom: 12px; }
.widget-wordpress-warning {
  margin: 16px 0 0;
  padding: 11px 13px;
  border-left: 4px solid #f4722d;
  border-radius: 8px;
  background: #fff5ed;
  color: #6f3518;
  font-size: .82rem;
}
.widget-preview-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #f5f6fa; }
.widget-preview-card h3 { margin: 0 0 10px; font-size: 1rem; }
.widget-preview-frame { display: block; width: 100%; height: 390px; border: 0; border-radius: 10px; background: #0f172a; }
.widget-attribution-note { margin: 10px 2px 0; color: var(--ink-muted); font-size: .78rem; }

@media (width <= 820px) {
  .widget-dialog { width: min(720px, calc(100% - 20px)); }
  .widget-dialog-grid { grid-template-columns: 1fr; }
  .widget-preview-frame { height: 440px; }
}

@media (width <= 520px) {
  .widget-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); border-radius: 16px; }
  .widget-dialog-header { padding: 20px 18px 16px; }
  .widget-dialog-grid { padding: 18px; }
  .widget-code { min-height: 230px; font-size: .72rem; }
  .widget-code-split { min-height: 180px; }
  .widget-format-tabs { flex-direction: column; }
  .widget-dialog-grid .button-row { align-items: stretch; }
  .widget-dialog-grid .button-row .button { width: 100%; }
  .widget-preview-frame { height: 430px; }
}
