body.modal-open {
  overflow: hidden;
}

.editor-modal {
  width: min(720px, calc(100vw - 24px));
  max-width: 720px;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(42, 29, 22, 0.34);
}

.editor-modal::backdrop {
  background: rgba(42, 29, 22, 0.62);
  backdrop-filter: blur(3px);
}

.editor-modal-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 24px);
  padding: 10px;
}

.editor-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 15px;
  border-bottom: 1px solid var(--line);
}

.editor-modal-meta {
  margin: 0 0 3px;
  color: var(--ink-faint);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-modal-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.modal-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.modal-close:hover {
  color: var(--ink);
  background: var(--surface-strong);
  border-color: var(--line-strong);
}

.editor-modal-body {
  flex: 1 1 auto;
  padding: 18px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.editor-modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.primary-button,
.secondary-button,
.danger-button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.primary-button {
  color: #fffaf2;
  background: var(--terracotta);
  border-color: var(--terracotta);
}

.primary-button:hover {
  background: var(--terracotta-deep);
  border-color: var(--terracotta-deep);
}

.secondary-button {
  color: var(--ink-soft);
  background: var(--surface-strong);
  border-color: var(--line);
}

.secondary-button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.danger-button {
  color: #fff8f2;
  background: #8f3527;
  border-color: #8f3527;
}

.danger-button:hover {
  background: #72281d;
  border-color: #72281d;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.upload-button:active {
  transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.upload-button {
  color: #fffaf2;
  background: var(--olive);
  border-color: var(--olive);
  cursor: pointer;
}

.upload-button:hover {
  background: #303a2b;
  border-color: #303a2b;
}

.photo-editor {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 13px;
  background: rgba(255, 253, 248, 0.7);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.photo-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 10px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, #fffaf2 0%, #eddfcc 60%, #d8c1a6 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
}

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

.photo-preview img.is-photo {
  object-fit: cover;
  border-radius: 9px;
}

.photo-placeholder {
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.photo-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.editor-remove-photo {
  padding: 0;
  border: 0;
  font-size: 0.75rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.photo-help {
  margin: 2px 0 0;
  color: var(--ink-faint);
  font-size: 0.75rem;
  line-height: 1.45;
}

.photo-status {
  margin: 0;
  color: var(--terracotta-deep);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
}

.photo-status.is-error {
  color: #8f3527;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.field-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.field > span,
.dimensions-fieldset legend {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  font-size: 0.88rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.field input:focus {
  border-color: var(--terracotta-soft);
  box-shadow: 0 0 0 3px rgba(178, 84, 47, 0.1);
}

.dimensions-fieldset {
  margin: 16px 0 0;
  padding: 12px;
  background: rgba(255, 253, 248, 0.55);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.dimensions-fieldset legend {
  padding: 0 6px;
}

.dimensions-fieldset .field-grid {
  margin-top: 2px;
}

.editor-warning-inline {
  margin: 16px 0 0;
  padding: 9px 11px;
  color: #70441f;
  background: #f6e8ce;
  border: 1px solid #e6cfa8;
  border-radius: 10px;
  font-size: 0.75rem;
  line-height: 1.4;
}

.editor-warning-inline code {
  padding: 1px 4px;
  background: rgba(112, 68, 31, 0.08);
  border-radius: 4px;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.9em;
}

.editor-message {
  flex: 1 1 100%;
  min-height: 1.1em;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

.editor-message.is-error {
  color: #8f3527;
}

.editor-message.is-success {
  color: #3d6b46;
}

@media (max-width: 680px) {
  .editor-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .editor-modal-card {
    height: 100dvh;
    max-height: 100dvh;
    padding: 10px;
  }

  .editor-modal-head {
    padding: 13px 14px 11px;
  }

  .editor-modal-title {
    font-size: 1.45rem;
  }

  .editor-modal-body {
    padding: 12px 14px;
  }

  .editor-modal-actions {
    position: sticky;
    bottom: 0;
    gap: 6px;
    padding: 10px 14px;
  }

  .photo-editor {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .photo-preview {
    max-width: 138px;
    width: 100%;
  }

  .field-grid,
  .field-grid-3 {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-top: 12px;
  }

  .field-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field input {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 0.84rem;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .upload-button {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 0.73rem;
  }

  .editor-warning-inline {
    margin-top: 12px;
    font-size: 0.75rem;
  }

  .editor-message {
    font-size: 0.75rem;
  }
}
