/* Базовая типографика и сброс */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: #e8ecf4;
  background: linear-gradient(160deg, #0a0e18 0%, #121a2e 45%, #0d1220 100%);
}

.hidden {
  display: none !important;
}

/* Редактор */
.app-editor {
  min-height: 100vh;
  padding: 0 12px 32px;
}

.top-header {
  text-align: center;
  padding: 20px 0 8px;
}

.main-title {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f2f5ff;
}

.editor-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
  align-items: start;
}

@media (min-width: 900px) {
  .editor-main {
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.1fr);
  }
}

.panel {
  background: rgba(18, 26, 44, 0.72);
  border: 1px solid rgba(120, 160, 255, 0.12);
  border-radius: 16px;
  padding: 18px 16px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.panel-form {
  touch-action: pan-y;
}

.field-group {
  margin-bottom: 14px;
}

.field-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #a8b4d4;
}

.field-group input,
.field-group textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(100, 130, 200, 0.25);
  background: rgba(8, 12, 24, 0.85);
  color: #eef2ff;
  font: inherit;
}

.field-group input:focus,
.field-group textarea:focus {
  outline: none;
  border-color: rgba(130, 170, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(80, 120, 220, 0.2);
}

.upload-block {
  margin: 18px 0;
  padding-top: 14px;
  border-top: 1px solid rgba(100, 130, 200, 0.15);
}

.upload-heading {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: #c8d4f4;
}

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

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #5b8cff;
}

.check-row label {
  margin: 0;
  color: #b8c6e8;
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #3d6ff0, #5b8cff);
  color: #fff;
  box-shadow: 0 6px 20px rgba(70, 120, 255, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 8px 26px rgba(70, 120, 255, 0.45);
}

.btn-secondary {
  background: rgba(60, 90, 160, 0.35);
  color: #e8eeff;
  border: 1px solid rgba(120, 160, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(70, 100, 180, 0.45);
}

.btn-ghost {
  background: transparent;
  color: #9eb4e8;
  border: 1px solid rgba(120, 140, 200, 0.25);
}

.btn-ghost:hover {
  color: #d0dcff;
  border-color: rgba(150, 170, 230, 0.4);
}

.btn-danger {
  background: rgba(180, 60, 70, 0.45);
  color: #ffe8ea;
  border: 1px solid rgba(255, 120, 130, 0.35);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.publish-result {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(100, 130, 200, 0.2);
}

.publish-label {
  margin: 0 0 8px;
  font-size: 13px;
  color: #a8b8e0;
}

.publish-url-wrap {
  margin-bottom: 10px;
}

.publish-url-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(100, 130, 200, 0.3);
  background: rgba(6, 10, 22, 0.9);
  color: #b8d0ff;
  font-size: 13px;
}

/* Макет */
.panel-layout {
  position: sticky;
  top: 12px;
  touch-action: pan-y;
}

.layout-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #dce6ff;
  text-align: center;
}

.layout-canvas-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 4px 0 8px;
}

.layout-canvas {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 9 / 16;
  max-height: min(72vh, 640px);
  background: radial-gradient(120% 80% at 50% 0%, #1a2540 0%, #0c1222 70%);
  border-radius: 20px;
  border: 1px solid rgba(100, 140, 220, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.layout-canvas.drag-active {
  cursor: grabbing;
}

.layout-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: #7a8cb8;
  text-align: center;
}

.layout-item {
  position: absolute;
  min-width: 36px;
  min-height: 28px;
  border-radius: 10px;
  z-index: 1;
  transition: box-shadow 0.15s ease;
}

.layout-item.is-dragging,
.layout-item.is-resizing {
  z-index: 50;
  box-shadow:
    0 0 0 2px rgba(100, 160, 255, 0.45),
    0 12px 32px rgba(0, 0, 0, 0.4);
}

.layout-item-inner {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.layout-item .resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(120, 160, 255, 0.5));
  border: 1px solid rgba(200, 220, 255, 0.45);
  cursor: nwse-resize;
  z-index: 3;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.layout-guide {
  position: absolute;
  background: rgba(120, 180, 255, 0.35);
  pointer-events: none;
  z-index: 40;
  border-radius: 2px;
}

.layout-guide-h {
  height: 2px;
  left: 0;
  right: 0;
}

.layout-guide-v {
  width: 2px;
  top: 0;
  bottom: 0;
}

/* Рамки изображений в редакторе */
.img-frame-off .layout-img {
  border: none;
  box-shadow: none;
}

.img-frame-on .layout-img {
  border: 2px solid rgba(200, 215, 255, 0.55);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.layout-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  pointer-events: none;
}

.layout-text {
  font-size: clamp(10px, 2.8vw, 14px);
  color: #e8eeff;
  text-align: center;
  padding: 4px 6px;
  word-break: break-word;
  line-height: 1.25;
}

.layout-name {
  font-weight: 700;
  font-size: clamp(12px, 3.4vw, 16px);
}

.layout-phone {
  font-size: clamp(11px, 3vw, 14px);
  color: #b8c8f0;
}

.layout-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 4px;
}

.social-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.social-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.layout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: clamp(10px, 2.6vw, 13px);
  font-weight: 600;
  text-align: center;
  background: linear-gradient(135deg, #3a62e0, #5b8cff);
  color: #fff;
  box-shadow: 0 4px 14px rgba(60, 100, 220, 0.35);
}

/* Публичная страница */
.app-view {
  min-height: 100vh;
  padding: 12px 12px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.public-page {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.public-card {
  position: relative;
  width: 100%;
  background: linear-gradient(165deg, #0f1628 0%, #0a0f1c 55%, #080c18 100%);
  border-radius: 24px;
  border: 2px solid rgba(130, 160, 230, 0.35);
  box-shadow:
    0 0 0 1px rgba(40, 60, 120, 0.4),
    0 24px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 18px 16px 20px;
  overflow: hidden;
}

.public-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.public-card-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  min-height: 360px;
}

.pub-item {
  position: absolute;
  border-radius: 12px;
  overflow: visible;
}

.pub-item:focus,
.pub-item:focus-visible,
.pub-item *:focus {
  outline: none;
}

.pub-img-wrap {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
}

.pub-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.pub-frame-off .pub-img-wrap {
  border: none;
  box-shadow: none;
}

.pub-frame-on .pub-img-wrap {
  border: 2px solid rgba(190, 205, 255, 0.5);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.pub-text {
  font-size: clamp(12px, 3.5vw, 15px);
  color: #dde6ff;
  text-align: center;
  padding: 4px 8px;
  line-height: 1.35;
  word-break: break-word;
}

.pub-name {
  font-weight: 700;
  font-size: clamp(17px, 5vw, 22px);
  letter-spacing: 0.02em;
}

.pub-phone-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.pub-phone {
  display: inline-block;
  max-width: 100%;
  font-size: clamp(14px, 4vw, 16px);
  color: #a8c4ff;
  text-decoration: none;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(60, 90, 160, 0.25);
  border: 1px solid rgba(120, 160, 255, 0.25);
}

.pub-phone:hover {
  border-color: rgba(160, 190, 255, 0.45);
}

.pub-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  padding: 6px 4px;
}

.pub-socials a {
  display: flex;
  text-decoration: none;
  border-radius: 12px;
  transition: transform 0.12s ease;
}

.pub-socials a:active {
  transform: scale(0.96);
}

.contact-row {
  display: flex;
  justify-content: center;
  width: 100%;
}

.btn-contact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  background: linear-gradient(135deg, #2d52d0, #4a78ff);
  color: #fff;
  box-shadow: 0 8px 24px rgba(50, 90, 220, 0.4);
  width: 100%;
  max-width: 280px;
  touch-action: manipulation;
}

.btn-contact:hover {
  box-shadow: 0 10px 28px rgba(50, 90, 220, 0.5);
}

.actions-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  padding: 0 2px;
}

.btn-action-pair {
  min-height: 48px;
  padding: 12px 10px;
  border-radius: 12px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #334a98, #4d6ee0);
  color: #f4f7ff;
  box-shadow: 0 6px 18px rgba(40, 60, 140, 0.4);
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.btn-action-pair:hover {
  box-shadow: 0 8px 22px rgba(50, 70, 160, 0.45);
}

/* Модалки */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  max-height: 90vh;
  overflow: auto;
  background: linear-gradient(180deg, #141c32 0%, #0e1426 100%);
  border: 1px solid rgba(120, 160, 255, 0.25);
  border-radius: 18px;
  padding: 20px 18px 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  touch-action: pan-y;
}

.modal-panel-compact {
  width: min(100%, 340px);
}

.modal-title {
  margin: 0 0 14px;
  font-size: 1.1rem;
  text-align: center;
  color: #e8eeff;
}

.modal-card-wrap {
  max-height: 65vh;
  overflow: auto;
  border-radius: 16px;
  margin-bottom: 14px;
  touch-action: pan-y;
}

.modal-card-inner {
  position: relative;
  min-height: 200px;
}

.modal-close-btn {
  width: 100%;
  margin-top: 4px;
}

.write-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.write-option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(120, 150, 220, 0.3);
  background: rgba(30, 42, 72, 0.6);
  color: #e8eeff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  touch-action: manipulation;
}

.write-option-btn:hover {
  border-color: rgba(160, 190, 255, 0.45);
  background: rgba(40, 54, 90, 0.75);
}

.write-option-btn .social-icon {
  width: 40px;
  height: 40px;
}


.font-controls{
  display:grid;
  grid-template-columns:1fr 96px;
  gap:8px;
  margin-top:8px;
}
.pub-single-social{
  display:flex;
  width:100%;
  height:100%;
  align-items:center;
  justify-content:center;
  text-decoration:none;
}
.pub-single-social .social-icon,
.layout-item .social-icon{
  width:100%;
  height:100%;
}
.pub-single-social .social-icon svg,
.layout-item .social-icon svg{
  width:100%;
  height:100%;
}


.rich-editor{
  min-height:84px;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(100,130,200,.25);
  background:rgba(8,12,24,.85);
  color:#eef2ff;
  outline:none;
  line-height:1.45;
}
.rich-editor:focus{
  border-color: rgba(130, 170, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(80, 120, 220, 0.2);
}
.font-controls{
  display:grid;
  grid-template-columns:1fr 96px;
  gap:8px;
  margin-top:8px;
}
.btn-small{
  min-height:40px;
}
.layout-btn-secondary{
  background: linear-gradient(135deg, #4a4f63, #6a7087);
  box-shadow: 0 4px 14px rgba(80, 86, 110, 0.35);
}
.btn-action-pair-secondary{
  background: linear-gradient(135deg, #4a4f63, #6a7087);
  box-shadow: 0 6px 18px rgba(80, 86, 110, 0.35);
}


.rich-editor-single{
  min-height:48px;
}

.btn-action-pair-secondary{
  background: linear-gradient(135deg, #4a4f63, #6a7087);
  box-shadow: 0 6px 18px rgba(80, 86, 110, 0.35);
}


.social-icon{
  width: 40px !important;
  height: 40px !important;
}
.layout-item .social-icon,
.pub-single-social .social-icon{
  width: 100% !important;
  height: 100% !important;
  display:flex;
  align-items:center;
  justify-content:center;
}
.layout-item .social-icon svg,
.pub-single-social .social-icon svg{
  width:100% !important;
  height:100% !important;
  display:block;
}

.rich-editor b,
.rich-editor strong{
  font-weight:700;
}


.layout-btn{
  width:100%;
  height:100%;
  padding:0 10px;
}
.btn-action-pair{
  width:100%;
  height:100%;
  min-height:0;
}


.max-icon-image{
  width:100% !important;
  height:100% !important;
  display:block !important;
  object-fit:cover !important;
  border-radius:12px;
}


.layout-phone{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  max-width:100%;
  padding:2px 10px;
  border-radius:999px;
  background: rgba(60, 90, 160, 0.25);
  border: 1px solid rgba(120, 160, 255, 0.25);
  color:#a8c4ff;
}


#btn-bold-phone.active{
  outline: 2px solid rgba(120,160,255,.45);
  background: linear-gradient(135deg, rgba(87,146,255,.22), rgba(87,146,255,.1));
}


.contact-row{
  width:100%;
  height:100%;
}
.btn-contact{
  width:100%;
  height:100%;
  min-height:0;
}


.developer-showcase{
  position:absolute;
  left:14px;
  right:14px;
  bottom:12px;
  z-index:40;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.developer-toggle{
  width:100%;
  border:none;
  border-radius:16px;
  padding:14px 16px;
  font:inherit;
  font-weight:700;
  color:#eef4ff;
  background:linear-gradient(135deg, rgba(25,39,74,.95), rgba(15,22,42,.95));
  box-shadow:0 10px 26px rgba(0,0,0,.28), inset 0 0 0 1px rgba(120,160,255,.15);
  cursor:pointer;
}

.developer-panel.hidden{
  display:none;
}

.developer-panel{
  border-radius:18px;
  padding:10px;
  background:linear-gradient(135deg, rgba(10,15,30,.96), rgba(13,24,46,.96));
  box-shadow:0 12px 32px rgba(0,0,0,.35), inset 0 0 0 1px rgba(120,160,255,.12);
}

.developer-card-link{
  display:flex;
  align-items:center;
  gap:12px;
  text-decoration:none;
  color:#eef4ff;
}

.developer-card-image{
  width:56px;
  height:56px;
  border-radius:14px;
  object-fit:cover;
  flex:0 0 auto;
}

.developer-card-text{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.developer-card-text strong{
  font-size:16px;
  line-height:1.1;
}

.developer-card-text span{
  font-size:13px;
  opacity:.82;
}


.editor-developer-wrap{
  max-width: 1280px;
  margin: 0 auto 28px;
  padding: 0 20px 24px;
}

.editor-only-showcase{
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
}

.editor-only-showcase > summary{
  list-style: none;
}
.editor-only-showcase > summary::-webkit-details-marker{
  display:none;
}

.editor-only-showcase .developer-panel.hidden{
  display:block;
}
