: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.84);
  --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: none;
  margin: 0 auto;
  padding: 12px;
  border: 1px solid rgba(102, 155, 239, 0.34);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(248,251,255,.98), rgba(235,246,255,.96) 52%, rgba(245,241,255,.94)),
    linear-gradient(rgba(37,117,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,117,255,.07) 1px, transparent 1px);
  background-size: auto, 30px 30px, 30px 30px;
  color: var(--rp-ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  box-shadow: 0 18px 42px rgba(22, 61, 126, 0.16), inset 0 1px rgba(255,255,255,.9);
  position: relative;
  overflow: hidden;
}

.repair-photo-widget::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #2478ff, #00b8c9, #18b66a, #7c3cff, #2478ff);
  background-size: 200% 100%;
  animation: rp-spectrum 7s linear infinite;
}

@keyframes rp-spectrum {
  to { background-position: 200% 0; }
}

.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;
  position: relative;
}

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

.rp-title {
  font-size: 20px;
  line-height: 1.2;
  background: linear-gradient(90deg, #173b74, #2478ff, #087f5b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

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

.rp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(98,142,218,.3);
  border-radius: 11px;
  background: rgba(255,255,255,.88);
  color: var(--rp-ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0 12px;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(31, 73, 138, 0.08), inset 0 1px rgba(255,255,255,.8);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.rp-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(36, 120, 255, .46);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.16), inset 0 1px rgba(255,255,255,.8);
}

.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: 10px;
  border: 1px solid rgba(98,142,218,.28);
  border-radius: 14px;
  background: var(--rp-card);
  padding: 10px;
  box-shadow: 0 10px 24px rgba(28, 65, 125, .08);
}

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

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

.rp-type-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(98,142,218,.28);
  border-radius: 11px;
  background: rgba(255,255,255,.86);
  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: #2478ff;
  background: linear-gradient(135deg, rgba(37,120,255,.13), rgba(20,184,166,.09));
  color: #155bd6;
  box-shadow: inset 0 0 0 1px rgba(53, 109, 243, 0.16), 0 6px 16px rgba(37, 99, 235, .12);
}

.rp-capture-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(230px, 0.92fr);
  gap: 10px;
}

.repair-photo-widget.rp-gallery-only .rp-capture-grid {
  grid-template-columns: 1fr;
}

.repair-photo-widget.rp-gallery-only .rp-upload-card {
  margin-top: 14px;
}

.repair-photo-widget.rp-gallery-only .rp-gallery {
  max-height: none;
}

.repair-photo-widget.rp-gallery-only .rp-thumb-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.repair-photo-widget.rp-readonly .rp-thumb-actions {
  grid-template-columns: 1fr;
}

.repair-photo-widget.rp-readonly .rp-text-btn {
  min-height: 40px;
}

.rp-camera-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 8;
  min-height: 180px;
  max-height: 320px;
  border: 1px solid #172846;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 42%, rgba(45, 126, 255, .2), transparent 34%),
    #101827;
  box-shadow: inset 0 0 0 1px rgba(124, 217, 255, .12);
}

.rp-camera-close {
  display: none;
}

.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;
  text-align: center;
  padding: 10px;
}

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

.rp-device-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid rgba(98,142,218,.24);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255,255,255,.9), rgba(238,248,255,.82));
}

.rp-device-upload strong {
  display: block;
  color: var(--rp-ink);
  font-size: 14px;
}

.rp-device-upload p {
  margin: 5px 0 0;
  color: var(--rp-muted);
  font-size: 12px;
  line-height: 1.45;
}

.rp-file-btn {
  min-width: 148px;
}

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

.rp-quality-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 9px;
  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: 8px;
}

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

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

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

.rp-empty-gallery {
  display: grid;
  min-height: 96px;
  place-items: center;
  border: 1px dashed rgba(98,142,218,.4);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.48);
  text-align: center;
  padding: 14px;
}

.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: 7px;
}

.rp-thumb {
  overflow: hidden;
  border: 1px solid rgba(98,142,218,.22);
  border-radius: 12px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 18px rgba(28, 65, 125, .07);
}

.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(auto-fit, minmax(76px, 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;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.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: 16px;
  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) {
  body.rp-camera-modal-lock {
    overflow: hidden;
  }

  .repair-photo-widget {
    padding: 8px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(248,251,255,.98), rgba(238,247,255,.96));
    box-shadow: 0 8px 20px rgba(22, 61, 126, 0.1);
  }

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

  .rp-title {
    font-size: 18px;
  }

  .rp-subtitle,
  .rp-meta,
  .rp-status,
  .rp-storage {
    font-size: 11px;
  }

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

  .rp-type-panel,
  .rp-camera-card,
  .rp-upload-card {
    margin-top: 8px;
    padding: 8px;
    border-radius: 12px;
  }

  .rp-type-chip {
    min-height: 40px;
    border-radius: 10px;
    font-size: 14px;
  }

  .repair-photo-widget.rp-gallery-only .rp-thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rp-camera-frame {
    height: clamp(390px, 58svh, 560px);
    min-height: 0;
    max-height: calc(100svh - 250px);
    aspect-ratio: 9 / 16;
    border-radius: 12px;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card {
    position: fixed;
    z-index: 99999;
    left: 50%;
    top: 50%;
    display: flex;
    flex-direction: column;
    width: min(430px, 100vw);
    height: min(932px, 100svh);
    max-height: 100svh;
    margin: 0;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: #05070d;
    box-shadow: 0 24px 80px rgba(0,0,0,.58);
    transform: translate(-50%, -50%);
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card::before {
    content: "";
    position: fixed;
    z-index: -1;
    inset: -100vmax;
    background: rgba(2, 6, 23, .76);
    backdrop-filter: blur(8px);
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-camera-close {
    position: absolute;
    z-index: 10;
    top: max(16px, env(safe-area-inset-top));
    right: 12px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px;
    background: rgba(15,23,42,.66);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    box-shadow: 0 8px 24px rgba(0,0,0,.28);
    cursor: pointer;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-camera-frame {
    flex: 1 1 auto;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    border: 0;
    border-radius: 0;
    background: #000;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-preview {
    object-fit: cover;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-action-row {
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 7px !important;
    margin: 10px 0 0 !important;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-action-row .rp-btn {
    min-height: 48px !important;
    border-color: rgba(255,255,255,.18);
    border-radius: 14px;
    background: linear-gradient(135deg,#2478ff,#6d4df5);
    color: #fff;
    font-size: 14px !important;
    font-weight: 900;
    line-height: 1.15 !important;
    white-space: normal !important;
    box-shadow: 0 10px 24px rgba(36,120,255,.25);
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-device-upload,
  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-quality-row,
  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-watermark-note {
    display: none;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card .rp-status {
    flex: 0 0 auto;
    min-height: 18px;
    margin-top: 7px;
    color: rgba(255,255,255,.76);
    text-align: center;
  }

  .rp-preview {
    object-fit: cover;
  }

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

  .rp-btn {
    width: 100%;
    min-height: 42px;
    border-radius: 11px;
    font-size: 13px;
    line-height: 1.15;
    white-space: normal;
  }

  .rp-device-upload {
    grid-template-columns: 1fr;
    padding: 9px;
  }

  .rp-device-upload p {
    display: none;
  }

  .rp-quality-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .rp-file-btn {
    width: 100%;
  }

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

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

  .rp-thumb img,
  .rp-thumb video {
    aspect-ratio: 1 / 1;
    object-fit: cover;
  }

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

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

  .rp-thumb-grid,
  .repair-photo-widget.rp-gallery-only .rp-thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rp-camera-frame {
    height: clamp(360px, 56svh, 520px);
    max-height: calc(100svh - 238px);
    min-height: 0;
  }

  body.rp-camera-modal-lock .rp-camera-card.rp-camera-modal-card {
    width: 100vw;
    height: 100svh;
  }
}
