:root {
  --zbtool-shell-padding: 12px;
  --zbtool-workspace-gap: 12px;
  --ph-ink: #243449;
  --ph-muted: #6b7a90;
  --ph-line: #d7e0ea;
  --ph-soft: #f5f8fc;
  --ph-primary: #0f766e;
  --ph-danger: #b42318;
  --ph-shadow: 0 24px 56px -42px rgba(21, 39, 71, 0.55);
}

.ph-layout,
.zbtool-shell .ph-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.04fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.ph-editor-card,
.ph-preview-card {
  position: relative;
  border: 1px solid var(--ph-line);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: var(--ph-shadow);
  padding: 20px;
}

.ph-preview-card {
  display: flex;
  flex-direction: column;
}

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

.ph-card-head.compact {
  margin-bottom: 12px;
}

.ph-card-head h2,
.ph-card-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 18px 10px 16px;
  color: var(--ph-ink);
  font-size: 21px;
  line-height: 1.2;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.1) 0%, rgba(255, 255, 255, 0.96) 100%);
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.ph-card-head h2::before,
.ph-card-head h3::before {
  content: "";
  width: 4px;
  height: 1.15em;
  border-radius: 999px;
  background: linear-gradient(180deg, #0f766e 0%, #1aa49a 100%);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

.ph-card-head.compact h3 {
  font-size: 16px;
  padding: 8px 14px 8px 12px;
  border-radius: 14px;
}

.ph-card-head p {
  margin: 7px 0 0;
  color: var(--ph-muted);
  font-size: 14px;
  line-height: 1.7;
}

.ph-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: #edf7f5;
  color: var(--ph-primary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.ph-status-badge.is-error {
  background: #fff1f1;
  color: var(--ph-danger);
}

.ph-status-badge.is-ready {
  background: #eef8ec;
  color: #216a3f;
}

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

.ph-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ph-field > span {
  color: var(--ph-ink);
  font-size: 14px;
  font-weight: 600;
}

.ph-field-textarea {
  margin-top: 16px;
}

.ph-input-wrap,
.ph-color-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--ph-line);
  border-radius: 16px;
  background: #fff;
  min-height: 50px;
  padding: 0 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ph-input-wrap:focus-within,
.ph-color-wrap:focus-within,
.ph-field textarea:focus {
  border-color: rgba(15, 118, 110, 0.48);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
}

.ph-input-wrap input,
.ph-color-wrap input[type="text"],
.ph-field textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ph-ink);
  font-size: 15px;
}

.ph-input-wrap em {
  color: var(--ph-muted);
  font-style: normal;
  font-size: 12px;
  white-space: nowrap;
}

.ph-color-wrap input[type="color"] {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}

.ph-color-wrap input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.ph-color-wrap input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(36, 52, 73, 0.18);
  border-radius: 999px;
}

.ph-field textarea {
  min-height: 118px;
  border: 1px solid var(--ph-line);
  border-radius: 18px;
  background: #fff;
  padding: 14px 16px;
  line-height: 1.7;
  resize: vertical;
  box-sizing: border-box;
}

.ph-presets-card,
.ph-tips-card {
  margin-top: 14px;
  border: 1px solid var(--ph-line);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--ph-soft) 0%, #fff 100%);
  padding: 16px;
}

.ph-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ph-presets button,
.ph-actions button {
  border: 1px solid #c8d5e4;
  border-radius: 999px;
  background: #fff;
  color: #2f4157;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.ph-presets button:hover,
.ph-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.55);
  color: var(--ph-primary);
  box-shadow: 0 10px 22px -18px rgba(15, 43, 80, 0.8);
}

.ph-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.ph-actions button.is-primary {
  border-color: rgba(15, 118, 110, 0.12);
  background: linear-gradient(135deg, #0f766e 0%, #15938a 100%);
  color: #fff;
  box-shadow: 0 18px 34px -24px rgba(15, 118, 110, 0.85);
}

.ph-actions button.is-primary:hover:not(:disabled) {
  color: #fff;
  border-color: rgba(15, 118, 110, 0.12);
}

.ph-actions button.is-quiet {
  background: #fff7f5;
  color: var(--ph-danger);
  border-color: rgba(180, 35, 24, 0.2);
}

.ph-actions button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  box-shadow: none;
}

.ph-notice {
  min-height: 22px;
  margin: 12px 2px 0;
  color: var(--ph-muted);
  font-size: 13px;
  line-height: 1.6;
}

.ph-notice.is-ok {
  color: #146c43;
}

.ph-notice.is-warn {
  color: var(--ph-danger);
}

.ph-preview-stage {
  position: relative;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #c7d4e3;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.05) 0%, rgba(217, 119, 6, 0.06) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.5) 0, rgba(255, 255, 255, 0.5) 12px, rgba(245, 248, 252, 0.85) 12px, rgba(245, 248, 252, 0.85) 24px);
  overflow: hidden;
}

.ph-preview-empty {
  max-width: 260px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ph-muted);
  text-align: center;
  line-height: 1.8;
  pointer-events: none;
}

.ph-preview-stage img[hidden] {
  display: none !important;
}

.ph-preview-stage img {
  display: block;
  max-width: 100%;
  max-height: 540px;
  width: auto;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 26px 54px -36px rgba(22, 39, 69, 0.65);
  background: #fff;
}

.ph-result-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 0;
}

.ph-result-meta div {
  border: 1px solid var(--ph-line);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
}

.ph-result-meta dt {
  margin: 0 0 6px;
  color: var(--ph-muted);
  font-size: 12px;
}

.ph-result-meta dd {
  margin: 0;
  color: var(--ph-ink);
  font-size: 15px;
  font-weight: 600;
  word-break: break-all;
}

.ph-tips {
  margin: 0;
  padding-left: 18px;
  color: var(--ph-muted);
  line-height: 1.8;
}

.ph-tips li + li {
  margin-top: 6px;
}

@media (max-width: 1180px) {
  .ph-layout,
  .zbtool-shell .ph-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .ph-editor-card,
  .ph-preview-card {
    border-radius: 18px;
    padding: 16px;
  }

  .ph-card-head {
    display: block;
  }

  .ph-card-head h2,
  .ph-card-head h3 {
    width: fit-content;
    max-width: 100%;
  }

  .ph-status-badge {
    margin-top: 10px;
  }

  .ph-form-grid,
  .ph-result-meta {
    grid-template-columns: 1fr;
  }

  .ph-preview-stage {
    min-height: 260px;
    border-radius: 18px;
  }

  .ph-preview-stage img {
    border-radius: 14px;
  }
}

@media (max-width: 420px) {
  .ph-actions button,
  .ph-presets button {
    flex-basis: 100%;
  }
}
