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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Noto Sans SC', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(17, 24, 39, 0.08), transparent 22%),
    linear-gradient(180deg, #eef5f4 0%, #f8fafc 55%, #ffffff 100%);
  color: #102A2D;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

a {
  touch-action: manipulation;
}

.studio-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.72);
  position: sticky;
  top: 0;
  z-index: 20;
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.studio-brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0F766E, #155EEF);
  color: #fff;
  font-family: 'Sora', 'Noto Sans SC', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 14px 32px rgba(15, 118, 110, 0.24);
}

.studio-brand h1 {
  margin: 0;
  font-family: 'Sora', 'Noto Sans SC', sans-serif;
  font-size: 1.18rem;
}

.studio-brand p {
  margin: 4px 0 0;
  color: rgba(16, 42, 45, 0.7);
  font-size: 0.9rem;
}

.studio-header-actions,
.preview-toolbar-actions,
.result-actions,
.publish-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border: 0;
  border-radius: 16px;
  min-height: 42px;
  padding: 0 16px;
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(145deg, #0F766E, #155EEF);
  color: #fff;
  box-shadow: 0 12px 26px rgba(21, 94, 239, 0.22);
  font-weight: 700;
}

.ghost-btn,
.icon-btn {
  background: rgba(255, 255, 255, 0.84);
  color: #102A2D;
}

.studio-link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 1.2rem;
}

.studio-main {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 18px;
  min-height: calc(100vh - 95px);
}

.studio-sidebar,
.preview-stage,
.modal-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(10px);
}

.studio-sidebar {
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  min-height: 0;
  overflow: auto;
}

.studio-sidebar-right {
  overflow: hidden;
}

.panel-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(245, 248, 250, 0.84);
}

.panel-block-stretch {
  flex: 1;
  min-height: 0;
}

.panel-heading h2 {
  margin: 0;
  font-family: 'Sora', 'Noto Sans SC', sans-serif;
  font-size: 0.98rem;
}

.panel-heading span,
.preview-toolbar p,
.field-note,
.helper-text,
.empty-inspector p {
  color: rgba(16, 42, 45, 0.68);
  font-size: 0.82rem;
  line-height: 1.65;
}

.quick-form,
.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(16, 42, 45, 0.78);
}

.field-input,
.field-select,
.field-textarea,
.code-area {
  width: 100%;
  border: 1px solid rgba(16, 42, 45, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 14px;
  color: #102A2D;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus,
.code-area:focus {
  outline: 2px solid rgba(21, 94, 239, 0.14);
  border-color: rgba(21, 94, 239, 0.3);
}

.field-textarea,
.code-area {
  min-height: 102px;
  resize: vertical;
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-list,
.theme-picker,
.module-library {
  display: grid;
  gap: 10px;
}

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

.template-card,
.module-card {
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid transparent;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.template-card:hover,
.module-card:hover,
.theme-swatch:hover {
  transform: translateY(-1px);
  border-color: rgba(21, 94, 239, 0.3);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.template-card strong,
.module-card strong {
  display: block;
  margin-bottom: 6px;
}

.template-card span,
.module-card span,
.theme-swatch span {
  display: block;
  color: rgba(16, 42, 45, 0.7);
  font-size: 0.78rem;
  line-height: 1.55;
}

.template-preview {
  height: 74px;
  margin-bottom: 10px;
  border-radius: 18px;
  padding: 12px;
  background:
    linear-gradient(160deg, rgba(21, 94, 239, 0.14), rgba(15, 118, 110, 0.05)),
    #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-preview .line {
  height: 8px;
  border-radius: 999px;
  background: rgba(16, 42, 45, 0.12);
}

.template-preview .line.short {
  width: 56%;
}

.theme-picker {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.theme-swatch {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px;
}

.theme-swatch.is-active,
.template-card.is-active {
  border-color: rgba(21, 94, 239, 0.4);
  box-shadow: 0 12px 24px rgba(21, 94, 239, 0.12);
}

.theme-swatch-mark {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.theme-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
}

.module-library {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.module-card {
  text-align: left;
}

.module-card em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 12px;
  font-style: normal;
  background: rgba(15, 118, 110, 0.08);
  color: #0F766E;
}

.studio-preview-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 12px;
}

.preview-toolbar strong {
  display: block;
  font-family: 'Sora', 'Noto Sans SC', sans-serif;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  border-radius: 32px;
  position: relative;
  padding: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.phone-frame {
  width: min(100%, 420px);
  min-height: 780px;
  padding: 20px 14px 14px;
  border-radius: 46px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
  position: relative;
}

.phone-notch {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 120px;
  height: 24px;
  transform: translateX(-50%);
  background: #020617;
  border-radius: 999px;
}

.phone-screen {
  overflow: auto;
  height: 744px;
  border-radius: 34px;
  background: linear-gradient(180deg, #EFF7F5 0%, #F8FAFC 100%);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.drop-helper {
  position: absolute;
  right: 24px;
  bottom: 24px;
  max-width: 240px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(16, 42, 45, 0.78);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.65;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: #0F766E;
  font-size: 0.78rem;
  font-weight: 700;
}

.inspector-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.inspector-group {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
}

.inspector-group h3 {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.array-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.array-item {
  padding: 12px;
  border: 1px solid rgba(16, 42, 45, 0.08);
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.92);
}

.array-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.array-item-head strong {
  font-size: 0.82rem;
}

.array-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-btn {
  border: 0;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(16, 42, 45, 0.08);
  font-size: 0.78rem;
}

.mini-btn[data-array-action="remove"],
.editor-block-actions [data-editor-action="delete"] {
  background: rgba(239, 68, 68, 0.12);
  color: #c53030;
}

.empty-inspector {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
}

.empty-inspector h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.upload-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-preview-card,
.upload-empty {
  border-radius: 18px;
  overflow: hidden;
  background: rgba(248, 250, 252, 0.92);
  border: 1px dashed rgba(16, 42, 45, 0.12);
}

.upload-preview-card {
  aspect-ratio: 1 / 1;
}

.upload-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.upload-empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  color: rgba(16, 42, 45, 0.58);
  font-size: 0.8rem;
  line-height: 1.7;
}

.upload-row .ghost-btn {
  min-height: 40px;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.52);
  z-index: 40;
}

.modal-shell.is-open {
  display: flex;
}

.modal-card {
  width: min(100%, 620px);
  border-radius: 28px;
  padding: 22px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
  font-family: 'Sora', 'Noto Sans SC', sans-serif;
}

.modal-head p {
  margin: 6px 0 0;
  color: rgba(16, 42, 45, 0.68);
  font-size: 0.82rem;
}

.publish-result {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-state {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 118, 110, 0.08);
  color: #0F766E;
  font-size: 0.82rem;
  line-height: 1.6;
}

.code-area {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
}

.result-qr-box {
  min-height: 170px;
  border-radius: 24px;
  background: rgba(248, 250, 252, 0.9);
  display: grid;
  place-items: center;
}

.result-qr-box table {
  margin: 0 auto;
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}

.toast-item {
  min-width: 220px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(16, 42, 45, 0.88);
  color: #fff;
  line-height: 1.6;
  font-size: 0.82rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

@media (max-width: 1320px) {
  .studio-main {
    grid-template-columns: 290px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 1100px) {
  .studio-main {
    grid-template-columns: 1fr;
  }

  .studio-sidebar {
    order: 2;
  }

  .studio-preview-area {
    order: 1;
  }

  .studio-sidebar-right {
    order: 3;
  }

  .phone-frame {
    min-height: 720px;
  }

  .phone-screen {
    height: 684px;
  }
}

@media (max-width: 720px) {
  .studio-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
  }

  .studio-main {
    padding: 12px;
  }

  .preview-stage {
    padding: 16px;
    min-height: 0;
  }

  .phone-frame {
    width: 100%;
    min-height: 680px;
    padding: 18px 10px 10px;
    border-radius: 34px;
  }

  .phone-screen {
    height: 650px;
    border-radius: 28px;
  }

  .drop-helper {
    position: static;
    margin-top: 12px;
    max-width: none;
  }

  .inline-grid,
  .theme-picker,
  .module-library,
  .template-list {
    grid-template-columns: 1fr;
  }
}
