:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

.demo-shell {
  min-height: 100vh;
  padding: 18px;
  background: #eef4fb;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.repair-photo-widget {
  --rp-panel: #f8fbff;
  --rp-card: rgba(255, 255, 255, 0.78);
  --rp-strong: #ffffff;
  --rp-ink: #1f3358;
  --rp-muted: #66748a;
  --rp-line: #c8d8f0;
  --rp-line-soft: #dce7f6;
  --rp-accent: #2f6df6;
  --rp-accent-2: #5b45e9;
  --rp-danger: #d92d52;
  --rp-ok: #087443;

  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #edf4fd 100%);
  color: var(--rp-ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.repair-photo-widget button,
.repair-photo-widget input {
  font: inherit;
}

.rp-head,
.rp-upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rp-title,
.rp-subtitle,
.rp-section-title,
.rp-upload-title {
  margin: 0;
}

.rp-title {
  font-size: 22px;
  line-height: 1.2;
}

.rp-upload-title {
  font-size: 16px;
  font-weight: 800;
}

.rp-subtitle,
.rp-meta,
.rp-status,
.rp-storage {
  color: var(--rp-muted);
  font-size: 13px;
}

.rp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: var(--rp-strong);
  color: var(--rp-ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
  white-space: nowrap;
}

.rp-btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--rp-accent), var(--rp-accent-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.22);
}

.rp-btn-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.rp-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.rp-type-panel,
.rp-camera-card,
.rp-upload-card {
  min-width: 0;
  margin-top: 14px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: var(--rp-card);
  padding: 14px;
}

.rp-field-title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 800;
}

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

.rp-type-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--rp-line);
  border-radius: 8px;
  background: var(--rp-strong);
  color: var(--rp-ink);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.rp-type-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rp-type-chip.is-selected {
  border-color: #356df3;
  background: #eaf1ff;
  color: #214fb9;
  box-shadow: inset 0 0 0 1px rgba(53, 109, 243, 0.16);
}

.rp-capture-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 14px;
}

.rp-camera-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 260px;
  border: 1px solid #172846;
  border-radius: 8px;
  background: #111827;
}

.rp-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111827;
}

.rp-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #d6e2f2;
  font-weight: 700;
}

.rp-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.rp-quality-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--rp-muted);
  font-size: 13px;
}

.rp-quality-row input[type="range"] {
  width: 100%;
}

.rp-watermark-note {
  margin-top: 8px;
  color: var(--rp-muted);
  font-size: 12px;
}

.rp-status {
  min-height: 20px;
  margin-top: 10px;
}

.rp-ok {
  color: var(--rp-ok);
}

.rp-error {
  color: var(--rp-danger);
}

.rp-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  max-height: 492px;
  overflow: auto;
  padding-right: 2px;
}

.rp-empty-gallery {
  display: grid;
  min-height: 140px;
  place-items: center;
  border: 1px dashed var(--rp-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.rp-section-title {
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
}

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

.rp-thumb {
  overflow: hidden;
  border: 1px solid var(--rp-line-soft);
  border-radius: 8px;
  background: var(--rp-strong);
}

.rp-thumb-link {
  display: block;
  text-decoration: none;
}

.rp-thumb img,
.rp-thumb video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #111827;
}

.rp-thumb .rp-meta {
  padding: 6px;
  text-align: center;
}

.rp-thumb-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--rp-line-soft);
}

.rp-text-btn,
.rp-icon-btn {
  border: 0;
  background: transparent;
  color: var(--rp-accent);
  cursor: pointer;
  font-weight: 800;
}

.rp-text-btn {
  min-height: 34px;
}

.rp-text-btn + .rp-text-btn {
  border-left: 1px solid var(--rp-line-soft);
}

.rp-danger-btn {
  color: var(--rp-danger);
}

.rp-editor[hidden] {
  display: none;
}

.rp-editor {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.62);
}

.rp-editor-panel {
  width: min(920px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}

.rp-editor-head,
.rp-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rp-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--rp-ink);
  font-size: 24px;
  line-height: 1;
}

.rp-editor-canvas {
  display: block;
  width: 100%;
  max-height: 64vh;
  margin: 12px 0;
  border: 1px solid var(--rp-line-soft);
  border-radius: 8px;
  background: #111827;
  object-fit: contain;
}

.rp-editor-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 700px) {
  .repair-photo-widget {
    min-height: auto;
  }

  .rp-capture-grid {
    grid-template-columns: 1fr;
  }

  .rp-gallery {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .repair-photo-widget {
    padding: 10px;
  }

  .rp-head,
  .rp-upload-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .rp-camera-frame {
    min-height: 220px;
  }

  .rp-action-row {
    grid-template-columns: 1fr;
  }

  .rp-editor-actions .rp-btn {
    flex: 1 1 calc(50% - 10px);
  }
}

@media (max-width: 420px) {
  .rp-type-grid,
  .rp-thumb-grid {
    grid-template-columns: 1fr;
  }
}
