:root {
  color-scheme: dark;
  --page: #000000;
  --panel: #11142a;
  --panel-strong: #0d111c;
  --panel-soft: #171b3b;
  --text: #ffffff;
  --muted: #9da8b7;
  --border: #29324b;
  --cyan: #009eee;
  --pink: #ff1493;
  --violet: #a86cff;
  --green: #16b83d;
  --danger: #ff6480;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 0;
  background: var(--page);
  color: var(--text);
}

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

button,
select,
input[type="checkbox"],
.add-photos-button {
  cursor: pointer;
}

.photo-magnet-calculator {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0 18px;
  font-weight: 700;
}

.photo-magnet-layout {
  display: grid;
  grid-template-columns: minmax(205px, 0.72fr) minmax(480px, 1.75fr) minmax(260px, 0.92fr);
  gap: 12px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  min-height: 620px;
  padding: 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 20px;
  font-size: 1rem;
  line-height: 1.25;
}

.panel h2::after {
  content: "";
  display: block;
  width: 38px;
  height: 2px;
  margin-top: 8px;
  background: linear-gradient(90deg, var(--pink) 0 52%, var(--cyan) 52% 100%);
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-size: 0.78rem;
  font-weight: 900;
}

select,
textarea,
input[type="number"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

select,
input[type="number"] {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 76px;
  padding: 10px 11px;
  resize: vertical;
}

select:focus,
textarea:focus,
input:focus-visible,
button:focus-visible,
.add-photos-button:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 158, 238, 0.18);
}

.limits-list,
.summary-list {
  display: grid;
  gap: 0;
  margin: 22px 0 0;
}

.limits-list div,
.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.limits-list dt,
.summary-list dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.limits-list dd,
.summary-list dd {
  margin: 0;
  color: var(--text);
  font-size: 0.74rem;
  text-align: right;
}

.order-guide {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-guide li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.order-guide li > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--violet);
  border-radius: 50%;
  color: #c695ff;
  font-size: 0.72rem;
  font-weight: 950;
}

.order-guide strong {
  display: block;
  font-size: 0.76rem;
  line-height: 1.25;
}

.order-guide p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.35;
}

.settings-note {
  display: grid;
  gap: 5px;
  margin-top: 20px;
  padding: 12px;
  border: 1px solid rgba(0, 158, 238, 0.45);
  border-radius: 8px;
  background: rgba(0, 158, 238, 0.08);
  line-height: 1.35;
}

.settings-note strong {
  font-size: 0.78rem;
}

.builder-panel {
  display: flex;
  flex-direction: column;
}

.builder-heading,
.upload-progress > div:first-child,
.photo-card-top,
.photo-card-actions,
.quantity-stepper,
.photo-meta-row {
  display: flex;
  align-items: center;
}

.builder-heading {
  justify-content: space-between;
  gap: 14px;
}

.builder-heading h2 {
  margin-bottom: 4px;
}

.builder-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.add-photos-button {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  padding: 0 13px;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid #c28aff;
  border-radius: 8px;
  background: var(--violet);
  color: #10131f;
  font-size: 0.76rem;
  font-weight: 950;
}

.add-photos-button > span {
  font-size: 1.15rem;
  line-height: 1;
}

.add-photos-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-progress {
  margin-top: 15px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0d2030;
}

.upload-progress > div:first-child {
  justify-content: space-between;
  gap: 12px;
  color: #bce9ff;
  font-size: 0.7rem;
}

.progress-track {
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.11);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 0.2s ease;
}

.card-action,
.quantity-stepper button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #1b2337;
  color: var(--text);
  font-weight: 900;
}

.photo-list {
  display: grid;
  gap: 9px;
  max-height: 462px;
  margin-top: 12px;
  padding-right: 3px;
  overflow-y: auto;
}

.photo-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
}

.photo-card.is-error {
  border-color: rgba(255, 100, 128, 0.8);
}

.photo-thumbnail {
  position: relative;
  width: 76px;
  height: 76px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #080b12;
}

.photo-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-upload-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 22px;
  padding: 3px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  font-size: 0.58rem;
  text-align: center;
}

.photo-upload-badge.is-ready {
  background: #08772a;
}

.photo-upload-badge.is-error {
  background: #8b1730;
}

.photo-content {
  min-width: 0;
}

.photo-card-top {
  justify-content: space-between;
  gap: 8px;
}

.photo-name {
  overflow: hidden;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-photo {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
}

.remove-photo:hover {
  color: var(--danger);
  background: rgba(255, 100, 128, 0.08);
}

.photo-meta-row {
  gap: 7px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
}

.photo-fields {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(90px, 1fr) minmax(100px, 0.9fr);
  gap: 8px;
  margin-top: 9px;
}

.photo-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.62rem;
}

.photo-fields input,
.photo-fields select {
  min-height: 34px;
  padding: 0 8px;
  font-size: 0.7rem;
}

.photo-card-actions {
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.photo-card-actions > strong {
  color: var(--text);
  font-size: 0.62rem;
}

.quantity-stepper {
  gap: 0;
}

.quantity-stepper button {
  width: 31px;
  padding: 0;
  font-size: 0.95rem;
}

.quantity-stepper input {
  width: 78px;
  min-height: 34px;
  border-radius: 0;
  text-align: center;
}

.photo-validation {
  min-height: 14px;
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 0.61rem;
  line-height: 1.25;
}

.empty-state {
  display: grid;
  min-height: 310px;
  place-content: center;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.empty-state-mark {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  color: var(--cyan);
  font-size: 1.5rem;
}

.empty-state strong {
  color: var(--text);
  font-size: 0.86rem;
}

.empty-state > span:last-child {
  font-size: 0.68rem;
}

.error-message {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 0.72rem;
  line-height: 1.35;
}

.price-block {
  display: grid;
  gap: 5px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.price-block span,
.price-block small {
  color: var(--muted);
  font-size: 0.7rem;
}

.price-block strong {
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  line-height: 1;
}

.summary-list {
  margin-top: 8px;
}

.notes-field {
  margin-top: 16px;
}

.add-to-cart-button {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  font-weight: 950;
}

.add-to-cart-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.add-to-cart-button.is-loading {
  background: #167a31;
}

.cart-status {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
  font-size: 0.7rem;
  line-height: 1.35;
}

.cart-status.is-success {
  border-color: rgba(31, 191, 74, 0.6);
  color: #8bf0a4;
}

.cart-status.is-error {
  border-color: rgba(255, 100, 128, 0.7);
  color: #ff9baf;
}

.cart-status.is-hiding {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (max-width: 1040px) {
  .photo-magnet-layout {
    grid-template-columns: minmax(190px, 0.75fr) minmax(430px, 1.65fr);
  }

  .summary-panel {
    grid-column: 1 / -1;
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .photo-magnet-calculator {
    width: min(100% - 14px, 620px);
    padding-top: 7px;
  }

  .photo-magnet-layout {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 0;
    padding: 15px;
  }

  .photo-list {
    max-height: none;
    overflow: visible;
  }

  .summary-panel {
    grid-column: auto;
  }

  .builder-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .add-photos-button {
    justify-content: center;
  }

  .photo-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .photo-thumbnail {
    width: 64px;
    height: 64px;
  }

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

  .photo-fields label:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 450px) {
  .photo-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .photo-thumbnail {
    grid-column: auto;
    width: 100%;
    height: 120px;
  }

  .photo-content {
    grid-column: auto;
  }
}
